Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2017-11-26 04:57:38 +0000
committerNathan Ridge2017-12-01 16:31:09 +0000
commit193cb87bfaab25efeb1f75d789ca13cc63f61b4f (patch)
tree633305ee318bc7bcd607f638c9d38ca4cbbb9acd
parentabf1b13e6bf9943565f371ea91b6291eca071c39 (diff)
downloadorg.eclipse.cdt-193cb87bfaab25efeb1f75d789ca13cc63f61b4f.tar.gz
org.eclipse.cdt-193cb87bfaab25efeb1f75d789ca13cc63f61b4f.tar.xz
org.eclipse.cdt-193cb87bfaab25efeb1f75d789ca13cc63f61b4f.zip
Bug 527697 - Size of parameter pack where arguments themselves contain a pack
-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 c26b40da2c..24de5150d1 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
@@ -9035,6 +9035,24 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testDependentPackExpansionInFunctionType_526684() throws Exception {
parseAndCheckBindings();
}
+
+ // template <int> struct __make;
+ // template <> struct __make<2> { typedef int type; };
+ //
+ // template <typename... T>
+ // using type_pack_element = typename __make<sizeof...(T)>::type;
+ //
+ // template <typename... T>
+ // struct tuple_element {
+ // typedef type_pack_element<T...> type;
+ // };
+ //
+ // typedef tuple_element<int, int>::type Waldo;
+ public void testSizeofParameterPack_527697() throws Exception {
+ BindingAssertionHelper helper = getAssertionHelper();
+ ITypedef waldo = helper.assertNonProblem("Waldo");
+ assertSameType(CommonCPPTypes.int_, waldo);
+ }
// 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 5ae163e256..12346969e2 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
@@ -1221,8 +1221,17 @@ public class CPPTemplates {
static int determinePackSize(ICPPTemplateParameter tpar, ICPPTemplateParameterMap tpMap) {
if (tpar.isParameterPack()) {
ICPPTemplateArgument[] args= tpMap.getPackExpansion(tpar);
- if (args != null)
+ if (args != null) {
+ // The arguments could be dependent, so they could themselves
+ // contain pack expansions.
+ for (ICPPTemplateArgument arg : args) {
+ if (arg.isPackExpansion()) {
+ return PACK_SIZE_DEFER;
+ }
+ }
+
return args.length;
+ }
return PACK_SIZE_DEFER;
}
return PACK_SIZE_NOT_FOUND;

Back to the top