]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
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>
Sun, 15 Mar 2020 16:24:27 +0000 (12:24 -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 e81e39d177066b1218e6da8873ab9302a9de77e5..8edc445e70e98e7e17b5aeb9a15accb87a8d3832 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++/92068
index 2ceace5ea1a8256a696be21d37d91fd51808be11..3e4fc235f7a8f9bfb16d68f1f5176cee1ca2fa65 100644 (file)
@@ -3773,10 +3773,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) && TYPE_ALIAS_P (TREE_TYPE (decl)))
+         /* Since we stop at aliases 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 RECORD_TYPE:
       if (TYPE_PTRMEMFUNC_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<>();