]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: Fix ICE with parameter pack of decltype(auto) [PR103497]
authorNathaniel Shead <nathanieloshead@gmail.com>
Fri, 30 Jun 2023 07:05:24 +0000 (17:05 +1000)
committerJason Merrill <jason@redhat.com>
Thu, 27 Jul 2023 03:44:54 +0000 (23:44 -0400)
This patch ensures 'type_uses_auto' also checks for usages of 'auto' in
parameter packs.

PR c++/103497

gcc/cp/ChangeLog:

* pt.cc (type_uses_auto): Check inside parameter packs.

gcc/testsuite/ChangeLog:

* g++.dg/cpp1y/decltype-auto-103497.C: New test.

Signed-off-by: Nathaniel Shead <nathanieloshead@gmail.com>
gcc/cp/pt.cc
gcc/testsuite/g++.dg/cpp1y/decltype-auto-103497.C [new file with mode: 0644]

index 9e39fe91986fe10232da1188328b290b23c50644..36344dcf91b35bbc988ffbc00ea3363af7b089bd 100644 (file)
@@ -31183,7 +31183,12 @@ type_uses_auto (tree type)
 {
   if (type == NULL_TREE)
     return NULL_TREE;
-  else if (flag_concepts_ts)
+
+  /* For parameter packs, check the contents of the pack.  */
+  if (PACK_EXPANSION_P (type))
+    type = PACK_EXPANSION_PATTERN (type);
+
+  if (flag_concepts_ts)
     {
       /* The Concepts TS allows multiple autos in one type-specifier; just
         return the first one we find, do_auto_deduction will collect all of
diff --git a/gcc/testsuite/g++.dg/cpp1y/decltype-auto-103497.C b/gcc/testsuite/g++.dg/cpp1y/decltype-auto-103497.C
new file mode 100644 (file)
index 0000000..cedd661
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/103497
+// { dg-do compile { target c++14 } }
+
+void foo(decltype(auto)... args);  // { dg-error "cannot declare a parameter with .decltype.auto.." }
+
+int main() {
+  foo();
+}