aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.c
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2021-10-28 10:46:46 -0400
committerPatrick Palka <ppalka@redhat.com>2021-10-28 10:46:46 -0400
commitf70f17d03630fd948bc15a646ebe7e784125c4d4 (patch)
treec8a7da7cf918f8f6d565f41a3962aa6c38655759 /gcc/cp/parser.c
parente5ddbbf992b909d8e38851bd3179d29389e6ac97 (diff)
downloadgcc-f70f17d03630fd948bc15a646ebe7e784125c4d4.zip
gcc-f70f17d03630fd948bc15a646ebe7e784125c4d4.tar.gz
gcc-f70f17d03630fd948bc15a646ebe7e784125c4d4.tar.bz2
c++: CTAD within template argument [PR102933]
Here when checking for erroneous occurrences of 'auto' inside a template argument (which is allowed by the concepts TS for class templates), extract_autos_r picks up the CTAD placeholder for X{T{0}} which causes check_auto_in_tmpl_args to reject this valid template argument. This patch fixes this by making extract_autos_r ignore CTAD placeholders. However, it seems we don't need to call check_auto_in_tmpl_args at all outside of the concepts TS since using 'auto' as a type-id is otherwise rejected more generally at parse time. So this patch makes the function just exit early if !flag_concepts_ts. Similarly, I think the concepts code paths in do_auto_deduction and type_uses_auto are only necessary for the concepts TS, so this patch also restricts these code paths accordingly. PR c++/102933 gcc/cp/ChangeLog: * parser.c (cp_parser_simple_type_specifier): Adjust diagnostic for using auto in parameter declaration. * pt.c (extract_autos_r): Ignore CTAD placeholders. (extract_autos): Use range-based for. (do_auto_deduction): Use extract_autos only for the concepts TS and not also for standard concepts. (type_uses_auto): Likewise with for_each_template_parm. (check_auto_in_tmpl_args): Just return false outside of the concepts TS. Simplify. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/nontype-class50.C: New test. * g++.dg/cpp2a/nontype-class50a.C: New test.
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r--gcc/cp/parser.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 93335c8..4c20757 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -19513,7 +19513,7 @@ cp_parser_simple_type_specifier (cp_parser* parser,
else if (!flag_concepts)
pedwarn (token->location, 0,
"use of %<auto%> in parameter declaration "
- "only available with %<-fconcepts-ts%>");
+ "only available with %<-std=c++20%> or %<-fconcepts%>");
}
else
type = make_auto ();