[gcc(refs/vendors/redhat/heads/gcc-8-branch)] c++: Find parameter pack in typedef in lambda [92909].
Jakub Jelinek
jakub@gcc.gnu.org
Thu Sep 17 16:51:34 GMT 2020
https://gcc.gnu.org/g:c345977c94648453647f835f0200ef04baa9dffd
commit c345977c94648453647f835f0200ef04baa9dffd
Author: Jason Merrill <jason@redhat.com>
Date: Sat Mar 14 17:10:39 2020 -0400
c++: Find parameter pack in typedef in lambda [92909].
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.
Diff:
---
gcc/cp/ChangeLog | 6 ++++++
gcc/cp/pt.c | 16 ++++++++++++----
gcc/testsuite/g++.dg/cpp0x/lambda/lambda-variadic10.C | 12 ++++++++++++
3 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index ed2405e6f33..5668ce6a758 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index a7a5fa06d05..527d6f9f9b1 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -3814,10 +3814,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
index 00000000000..052283e6caa
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-variadic10.C
@@ -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<>();
More information about the Gcc-cvs
mailing list