diff options
author | Markus Schorn | 2009-07-28 08:58:59 +0000 |
---|---|---|
committer | Markus Schorn | 2009-07-28 08:58:59 +0000 |
commit | fe7b9b95c27fb3b4681ae99c60a73a23434a209c (patch) | |
tree | 8492db809043b92d85519cff5411b0e712ee0f16 | |
parent | af187fe16bdf292272edebb94acb23115f5c0ed9 (diff) | |
download | org.eclipse.cdt-fe7b9b95c27fb3b4681ae99c60a73a23434a209c.tar.gz org.eclipse.cdt-fe7b9b95c27fb3b4681ae99c60a73a23434a209c.tar.xz org.eclipse.cdt-fe7b9b95c27fb3b4681ae99c60a73a23434a209c.zip |
Instantiation of default template argument, bug 284683.
3 files changed, 28 insertions, 5 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java index 9378641687a..944ebca0911 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java @@ -30,6 +30,7 @@ import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; @@ -1608,4 +1609,24 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa public void testParentScopeOfSpecialization_267013() throws Exception { ITypedef ti= getBindingFromASTName("TInt", 4, ITypedef.class); } + + // template<typename T> class op { + // public: + // inline static int DO(T key, T key2) { + // return false; + // } + // }; + // + // template<typename T, int KVT_KeyCompareProc(T key, T key2)=op<T>::DO> class Noder1 {}; + + // template<typename T, int KVT_KeyCompareProc(T key, T key2)=op<T>::DO> class Noder2 {}; + // + // void test() { + // Noder1<int> f; + // Noder2<int> g; + // } + public void testInstantiationOfValue_284683() throws Exception { + getBindingFromASTName("Noder1<int>", 11, ICPPClassSpecialization.class); + getBindingFromASTName("Noder2<int>", 11, ICPPClassSpecialization.class); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java index a957e9bfe77..3482ce4a0dc 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java @@ -63,7 +63,7 @@ public class CPPTemplateNonTypeParameter extends CPPTemplateParameter implements return null; IValue val= Value.create(d, Value.MAX_RECURSION_DEPTH); - IType t= CPPVisitor.createType(d); + IType t= getType(); return new CPPTemplateArgument(val, t); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java index 02999758053..8ef3d00f95d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java @@ -920,11 +920,13 @@ public class CPPTemplates { private static ICPPTemplateArgument instantiateArgument(ICPPTemplateArgument arg, ICPPTemplateParameterMap tpMap, ICPPClassSpecialization within) { if (arg.isNonTypeValue()) { - final IValue orig= arg.getNonTypeValue(); - final IValue inst= instantiateValue(orig, tpMap, within, Value.MAX_RECURSION_DEPTH); - if (orig == inst) + final IValue origValue= arg.getNonTypeValue(); + final IType origType= arg.getTypeOfNonTypeValue(); + final IValue instValue= instantiateValue(origValue, tpMap, within, Value.MAX_RECURSION_DEPTH); + final IType instType= instantiateType(origType, tpMap, within); + if (origType == instType && origValue == instValue) return arg; - return new CPPTemplateArgument(inst, arg.getTypeOfNonTypeValue()); + return new CPPTemplateArgument(instValue, instType); } final IType orig= arg.getTypeValue(); |