c++: unexpanded pack in enum in lambda [PR100109]
authorJason Merrill <jason@redhat.com>
Tue, 20 Apr 2021 04:50:49 +0000 (00:50 -0400)
committerJason Merrill <jason@redhat.com>
Tue, 20 Apr 2021 12:35:14 +0000 (08:35 -0400)
Another construct we need to look inside.

gcc/cp/ChangeLog:

PR c++/100109
* pt.c (find_parameter_packs_r): Look into enum initializers.

gcc/testsuite/ChangeLog:

PR c++/100109
* g++.dg/cpp0x/lambda/lambda-variadic14.C: New test.

gcc/cp/pt.c
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-variadic14.C [new file with mode: 0644]

index 19fdafa..7bcbe6d 100644 (file)
@@ -4066,12 +4066,18 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data)
       return NULL_TREE;
 
     case TAG_DEFN:
-      /* Local class, need to look through the whole definition.  */
       t = TREE_TYPE (t);
       if (CLASS_TYPE_P (t))
+       /* Local class, need to look through the whole definition.  */
        for (tree bb : BINFO_BASE_BINFOS (TYPE_BINFO (t)))
          cp_walk_tree (&BINFO_TYPE (bb), &find_parameter_packs_r,
                        ppd, ppd->visited);
+      else
+       /* Enum, look at the values.  */
+       for (tree l = TYPE_VALUES (t); l; l = TREE_CHAIN (l))
+         cp_walk_tree (&DECL_INITIAL (TREE_VALUE (l)),
+                       &find_parameter_packs_r,
+                       ppd, ppd->visited);
       return NULL_TREE;
 
     case FUNCTION_TYPE:
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-variadic14.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-variadic14.C
new file mode 100644 (file)
index 0000000..185aa03
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/100109
+// { dg-do compile { target c++11 } }
+
+template <int... E>
+void f() {
+  [] { enum e { e = E }; };    // { dg-error "not expanded" }
+}
+template void f<>();