diff options
author | Nathaniel Shead <nathanieloshead@gmail.com> | 2023-06-30 17:05:24 +1000 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2023-07-26 23:44:54 -0400 |
commit | ca912a39cccdd990ef705768faa7311ac210b3f3 (patch) | |
tree | c2da8c5f6512ef59161c3996c082ff4a070f60eb /gcc | |
parent | 9890d4e8bcda1f34b8eefb481935ef0e4cd8069e (diff) | |
download | gcc-ca912a39cccdd990ef705768faa7311ac210b3f3.zip gcc-ca912a39cccdd990ef705768faa7311ac210b3f3.tar.gz gcc-ca912a39cccdd990ef705768faa7311ac210b3f3.tar.bz2 |
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 <nathanieloshead@gmail.com>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/pt.cc | 7 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp1y/decltype-auto-103497.C | 8 |
2 files changed, 14 insertions, 1 deletions
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 9e39fe9..36344dc 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 0000000..cedd661 --- /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(); +} |