c++: Find parameter pack in typedef in lambda [92909].
authorJason Merrill <jason@redhat.com>
Sat, 14 Mar 2020 21:10:39 +0000 (17:10 -0400)
committerJason Merrill <jason@redhat.com>
Sat, 14 Mar 2020 21:13:25 +0000 (17:13 -0400)
find_parameter_packs_r doesn't look through typedefs, which is normally
correct, but that means we need to handle their declarations specially.

gcc/cp/ChangeLog
2020-03-14  Jason Merrill  <jason@redhat.com>

PR c++/92909
* pt.c (find_parameter_packs_r): [DECL_EXPR]: Walk
DECL_ORIGINAL_TYPE of a typedef.

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

index b4fa15047b58e38822e12fd020bbcbc620b8b68f..bb7f590ea0b71c4756a46654786ffc18df075617 100644 (file)
@@ -1,3 +1,9 @@
+2020-03-14  Jason Merrill  <jason@redhat.com>
+
+       PR c++/92909
+       * pt.c (find_parameter_packs_r): [DECL_EXPR]: Walk
+       DECL_ORIGINAL_TYPE of a typedef.
+
 2020-03-14  Jason Merrill  <jason@redhat.com>
 
        PR c++/93248
index 0f3c2ad8fecebe68a61a6b874ed1d8eb04a9c56e..bd2f9be82eae7da675f7c0c4ac45984a6e927780 100644 (file)
@@ -3916,10 +3916,18 @@ find_parameter_packs_r (tree *tp, int *walk_subtrees, void* data)
       return NULL_TREE;
 
     case DECL_EXPR:
-      /* Ignore the declaration of a capture proxy for a parameter pack.  */
-      if (is_capture_proxy (DECL_EXPR_DECL (t)))
-       *walk_subtrees = 0;
-      return NULL_TREE;
+      {
+       tree decl = DECL_EXPR_DECL (t);
+       /* Ignore the declaration of a capture proxy for a parameter pack.  */
+       if (is_capture_proxy (decl))
+         *walk_subtrees = 0;
+       if (is_typedef_decl (decl))
+         /* Since we stop at typedefs above, we need to look through them at
+            the point of the DECL_EXPR.  */
+         cp_walk_tree (&DECL_ORIGINAL_TYPE (decl),
+                       &find_parameter_packs_r, ppd, ppd->visited);
+       return NULL_TREE;
+      }
 
     case TEMPLATE_DECL:
       if (!DECL_TEMPLATE_TEMPLATE_PARM_P (t))
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-variadic10.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-variadic10.C
new file mode 100644 (file)
index 0000000..052283e
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/92909
+// { dg-do compile { target c++11 } }
+
+template <class ... Ts>
+void foo()
+{
+    []
+    {
+        using T = Ts;
+    }();                       // { dg-error "not expanded" }
+}
+template void foo<>();