From: Nathaniel Shead Date: Fri, 30 Jun 2023 07:05:24 +0000 (+1000) Subject: c++: Fix ICE with parameter pack of decltype(auto) [PR103497] X-Git-Tag: basepoints/gcc-15~7325 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ca912a39cccdd990ef705768faa7311ac210b3f3;p=thirdparty%2Fgcc.git c++: Fix ICE with parameter pack of decltype(auto) [PR103497] 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 --- diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 9e39fe91986f..36344dcf91b3 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -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 index 000000000000..cedd661710cd --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/decltype-auto-103497.C @@ -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(); +}