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 83a901a3d23..d3a3e495dc6 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 @@ -5668,4 +5668,13 @@ public class AST2TemplateTests extends AST2BaseTest { public void testResolvingAutoTypeWithDependentExpression_367472() throws Exception { parseAndCheckBindings(); } + + // void foo(int, int); + // template void bar(Args... args) { + // foo(1,2,args...); + // foo(args...); + // } + public void testPackExpansionsAsArguments_367560() throws Exception { + parseAndCheckBindings(); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java index 102acf013a7..8641f5e5c6e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java @@ -2276,7 +2276,8 @@ public class CPPSemantics { private static ICPPFunction[] selectByArgumentCount(LookupData data, ICPPFunction[] functions) throws DOMException { assert data.forDeclaration() == null; - int argumentCount = data.getFunctionArgumentCount(); + final int argumentCount = data.getFunctionArgumentCount(); + final int packExpansionCount= data.getFunctionArgumentPackExpansionCount(); // Trim the list down to the set of viable functions ICPPFunction[] result= new ICPPFunction[functions.length]; @@ -2300,11 +2301,11 @@ public class CPPSemantics { numArgs--; boolean ok; - if (numArgs > numPars) { - // more arguments than parameters --> need ellipsis or parameter pack + if (numArgs-packExpansionCount > numPars) { + // More arguments than parameters --> need ellipsis or parameter pack ok= fn.takesVarArgs() || fn.hasParameterPack(); } else { - ok = numArgs >= fn.getRequiredArgumentCount(); + ok = numArgs >= fn.getRequiredArgumentCount() || packExpansionCount > 0; } if (ok) { if (fn instanceof IIndexBinding) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java index 852200c56f1..90bbd338099 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java @@ -52,6 +52,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerList; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPackExpansionExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId; @@ -533,6 +534,17 @@ public class LookupData { return 0; } + public int getFunctionArgumentPackExpansionCount() { + int count= 0; + if (functionArgs != null) { + for (IASTInitializerClause arg : functionArgs) { + if (arg instanceof ICPPASTPackExpansionExpression) + count++; + } + } + return count; + } + public boolean hasFunctionArguments() { return functionArgs != null; }