Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2017-10-31 22:55:39 +0000
committerNathan Ridge2017-11-07 17:11:24 +0000
commitdaad877559bfd72e3f7ed64e11fd98e495cdec3c (patch)
tree09ad0cdc33c4e5bd4e838a6865ce2b6f87af1b5d
parent76e1842644f2af46213ab01a8a428a234d965f39 (diff)
downloadorg.eclipse.cdt-daad877559bfd72e3f7ed64e11fd98e495cdec3c.tar.gz
org.eclipse.cdt-daad877559bfd72e3f7ed64e11fd98e495cdec3c.tar.xz
org.eclipse.cdt-daad877559bfd72e3f7ed64e11fd98e495cdec3c.zip
Bug 526684 - Use InstantiationContext.setExpandPack() in CPPTemplates.instantiateTypes() if appropriate
InstantiationContext.setExpandPack() and related methods were introduced in bug 486971 to ensure that when instantiating a type list that contains a pack expansion, with a parameter map that maps the template parameter pack that appears in the expansion to another parameter pack (which can happen when e.g. instantiating an alias template with dependent arguments), the pack is expanded in the correct place. However, bug 486971 only added use of this machinery to CPPTemplates. instantiateArguments(). We can also instantiate a type list in instantiateTypes() (used e.g. when instantiating the parameter types of a function type), so the machinery needs to be used there as well. Change-Id: Iabb458e8e3166c15ed922656fc0729a4a8cf8bbf
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java18
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java11
2 files changed, 28 insertions, 1 deletions
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 ef03eefa2bc..c26b40da2c0 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
@@ -9017,6 +9017,24 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testDecltypeInPackExpansion_486425b() throws Exception {
parseAndCheckBindings();
}
+
+ // template <typename T>
+ // class meta {
+ // typedef T type;
+ // };
+ //
+ // template <typename... Ts>
+ // using Alias = void(typename meta<Ts>::type...);
+ //
+ // template <typename... Ts>
+ // Alias<Ts...>* async(Ts...);
+ //
+ // int main() {
+ // async(); // ERROR: Invalid arguments
+ // }
+ public void testDependentPackExpansionInFunctionType_526684() throws Exception {
+ parseAndCheckBindings();
+ }
// template <typename T>
// struct A {};
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 afb93a6fa51..5ae163e256a 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
@@ -1304,12 +1304,21 @@ public class CPPTemplates {
IType[] newResult= new IType[result.length + packSize - 1];
System.arraycopy(result, 0, newResult, 0, j);
result= newResult;
+ context.setExpandPack(true);
int oldPackOffset = context.getPackOffset();
for (int k= 0; k < packSize; k++) {
context.setPackOffset(k);
- result[j++]= instantiateType(innerType, context);
+ IType instantiated = instantiateType(innerType, context);
+ if (context.isPackExpanded()) {
+ if (instantiated != null) {
+ instantiated = new CPPParameterPackType(instantiated);
+ }
+ }
+ result[j++]= instantiated;
+
}
context.setPackOffset(oldPackOffset);
+ context.setExpandPack(false);
continue;
}
} else {

Back to the top