Skip to main content
summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMarkus Schorn2009-07-28 04:58:59 -0400
committerMarkus Schorn2009-07-28 04:58:59 -0400
commitfe7b9b95c27fb3b4681ae99c60a73a23434a209c (patch)
tree8492db809043b92d85519cff5411b0e712ee0f16 /core
parentaf187fe16bdf292272edebb94acb23115f5c0ed9 (diff)
downloadorg.eclipse.cdt-fe7b9b95c27fb3b4681ae99c60a73a23434a209c.tar.gz
org.eclipse.cdt-fe7b9b95c27fb3b4681ae99c60a73a23434a209c.tar.xz
org.eclipse.cdt-fe7b9b95c27fb3b4681ae99c60a73a23434a209c.zip
Instantiation of default template argument, bug 284683.
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java21
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateNonTypeParameter.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java10
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 9378641687..944ebca091 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 a957e9bfe7..3482ce4a0d 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 0299975805..8ef3d00f95 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();

Back to the top