diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java index 31a9337ca88..27d75405018 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java @@ -7351,29 +7351,4 @@ public class AST2TemplateTests extends AST2TestBase { public void testVariadicNonTypeTemplateParameter_401400() throws Exception { parseAndCheckBindings(); } - - // template struct tuple_indices {}; - // template - // struct make_indices_imp; - // template - // struct make_indices_imp, Ep> { - // typedef typename make_indices_imp, Ep>::type type; - // }; - // template - // struct make_indices_imp, Ep> { - // typedef tuple_indices type; - // }; - // template - // struct make_tuple_indices { - // typedef typename make_indices_imp, Ep>::type type; - // }; - // template - // class async_func { - // void operator()() { - // typedef typename make_tuple_indices<1 + sizeof...(Args), 1>::type Index; - // } - // }; - public void testVariadicTemplatesNPE_401743() throws Exception { - parseAndCheckBindings(); - } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java index 49dfa213641..700f42d10e1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java @@ -402,18 +402,6 @@ public class Value implements IValue { public static boolean isDependentValue(IValue nonTypeValue) { if (nonTypeValue == null) return false; - // Unknown values may or may not be dependent. In the case of a template with - // a non-type template argument, whether or not the argument's value is dependent - // determines whether or not the template gets instantiated. In light of this, - // it's safer to assume that an unknown value is dependent because: - // 1. Instantiating a template with a non-type template argument whose value is - // unknown is useless. - // 2. Instantiating such a template can lead to an infinite recursion of - // instantiations (e.g. consider a template A that delegates to A, - // with A<0> being specialized to end the recursion - if N is unknown, - // N - 1 will be unknown as well, and we get an infinite recursion). - if (nonTypeValue == UNKNOWN) - return true; ICPPEvaluation eval = nonTypeValue.getEvaluation(); return eval != null && eval.isValueDependent(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java index ab9474476a7..cd6b3f000fd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalBinding.java @@ -279,11 +279,6 @@ public class EvalBinding extends CPPDependentEvaluation { value= ((IVariable) fBinding).getInitialValue(); } else if (fBinding instanceof IEnumerator) { value= ((IEnumerator) fBinding).getValue(); - } else if (fBinding instanceof IFunction) { - // If a function passed as a non-type template parameter is constexpr, - // it can be used inside the template as a constexpr function, so it's - // important to preserve the binding in the value. - value = Value.create(this); } if (value == null) value = Value.UNKNOWN; @@ -341,11 +336,9 @@ public class EvalBinding extends CPPDependentEvaluation { ICPPClassSpecialization within, int maxdepth, IASTNode point) { IBinding origBinding = getBinding(); if (origBinding instanceof ICPPTemplateNonTypeParameter) { - if (tpMap != null) { - ICPPTemplateArgument argument = tpMap.getArgument((ICPPTemplateNonTypeParameter) origBinding, packOffset); - if (argument != null && argument.isNonTypeValue()) { - return argument.getNonTypeEvaluation(); - } + ICPPTemplateArgument argument = tpMap.getArgument((ICPPTemplateNonTypeParameter) origBinding, packOffset); + if (argument != null && argument.isNonTypeValue()) { + return argument.getNonTypeEvaluation(); } } else if (origBinding instanceof ICPPParameter) { ICPPParameter parameter = (ICPPParameter) origBinding; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java index 73ce2393dad..bf6318bced9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java @@ -354,8 +354,10 @@ public class EvalID extends CPPDependentEvaluation { return new EvalFunctionSet(new CPPFunctionSet(functions, templateArgs, null), fAddressOf, getTemplateDefinition()); } IBinding binding = bindings.length == 1 ? bindings[0] : null; - if (binding instanceof IEnumerator || binding instanceof ICPPMember) { + if (binding instanceof IEnumerator) { return new EvalBinding(binding, null, getTemplateDefinition()); + } else if (binding instanceof ICPPMember) { + return new EvalMemberAccess(nameOwner, ValueCategory.PRVALUE, binding, false, getTemplateDefinition()); } else if (binding instanceof CPPFunctionSet) { return new EvalFunctionSet((CPPFunctionSet) binding, fAddressOf, getTemplateDefinition()); }