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 75a6432cfe8..2008a13a293 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 @@ -7560,7 +7560,7 @@ public class AST2TemplateTests extends AST2TestBase { public void testSfinaeInNewExpressionWithDeletedConstructor_430230() throws Exception { parseAndCheckBindings(); } - + // template // struct M { // template @@ -7869,6 +7869,41 @@ public class AST2TemplateTests extends AST2TestBase { public void testVariadicTemplatesAndFunctionObjects_401479() throws Exception { parseAndCheckBindings(); } + + // template + // _Tp declval() noexcept; + // + // template + // struct is_convertible {}; + // + // template + // class function; + // + // template + // class function<_Res(_ArgTypes...)> { + // template + // using _Invoke = decltype(declval<_Functor&>()(declval<_ArgTypes>()...)); + // + // public: + // template>::type> + // function(_Functor); + // }; + // + // class A {}; + // + // struct B { + // B(const char* s); + // }; + // + // template void waldo(const B& response); + // template void waldo(function generator); + // + // void test() { + // waldo(""); // problem on waldo + // } + public void testPackExpansionInNestedTemplate_459844() throws Exception { + parseAndCheckBindings(); + } // struct S { // void kind(); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPDependentEvaluation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPDependentEvaluation.java index 967ba84a635..b5138240a70 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPDependentEvaluation.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPDependentEvaluation.java @@ -115,11 +115,11 @@ public abstract class CPPDependentEvaluation extends CPPEvaluation { ICPPEvaluation origEval = subexpressions[i]; ICPPEvaluation newEval; if (origEval instanceof EvalParameterPack) { - origEval = ((EvalParameterPack) origEval).getExpansionPattern(); - if (origEval == null) { + ICPPEvaluation pattern = ((EvalParameterPack) origEval).getExpansionPattern(); + if (pattern == null) { newEval = EvalFixed.INCOMPLETE; } else { - int packSize = origEval.determinePackSize(tpMap); + int packSize = pattern.determinePackSize(tpMap); if (packSize == CPPTemplates.PACK_SIZE_FAIL || packSize == CPPTemplates.PACK_SIZE_NOT_FOUND) { newEval = EvalFixed.INCOMPLETE; } else if (packSize == CPPTemplates.PACK_SIZE_DEFER) { @@ -129,7 +129,7 @@ public abstract class CPPDependentEvaluation extends CPPEvaluation { ICPPEvaluation[] newResult = new ICPPEvaluation[subexpressions.length + resultShift + shift]; System.arraycopy(result, 0, newResult, 0, i + resultShift); for (int j = 0; j < packSize; ++j) { - newEval = origEval.instantiate(tpMap, j, within, maxdepth, point); + newEval = pattern.instantiate(tpMap, j, within, maxdepth, point); newResult[i + resultShift + j] = newEval; } result = newResult; 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 f4e45332690..85ff8210ddd 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 @@ -1214,9 +1214,8 @@ public class CPPTemplates { ICPPTemplateArgument origArg = args[i]; ICPPTemplateArgument newArg; if (origArg.isPackExpansion()) { - ICPPTemplateArgument unexpanded= origArg; - origArg= origArg.getExpansionPattern(); - int packSize= determinePackSize(origArg, tpMap); + ICPPTemplateArgument pattern= origArg.getExpansionPattern(); + int packSize= determinePackSize(pattern, tpMap); if (packSize == PACK_SIZE_FAIL || packSize == PACK_SIZE_NOT_FOUND) { throw new DOMException(new ProblemBinding(point, IProblemBinding.SEMANTIC_INVALID_TEMPLATE_ARGUMENTS, null)); } else if (packSize == PACK_SIZE_DEFER) { @@ -1226,11 +1225,11 @@ public class CPPTemplates { ICPPTemplateArgument[] newResult= new ICPPTemplateArgument[args.length + resultShift + shift]; System.arraycopy(result, 0, newResult, 0, i + resultShift); for (int j= 0; j < packSize; j++) { - newArg = instantiateArgument(origArg, tpMap, j, within, point); + newArg = instantiateArgument(pattern, tpMap, j, within, point); if (!isValidArgument(newArg)) { if (strict) return null; - result[i + resultShift] = unexpanded; + result[i + resultShift] = origArg; newResult = result; shift = 0; break;