diff options
author | Patrick Palka <ppalka@redhat.com> | 2021-04-24 00:01:42 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2021-04-24 00:01:42 -0400 |
commit | 5f1a2cb9c2dc09eed53da5d5787d14bec700b10b (patch) | |
tree | 85a21d55f999cadbe0f7972b05965eeab684cc55 /gcc/cp | |
parent | 05ec629f05646837301820b89354a64673185224 (diff) | |
download | gcc-5f1a2cb9c2dc09eed53da5d5787d14bec700b10b.zip gcc-5f1a2cb9c2dc09eed53da5d5787d14bec700b10b.tar.gz gcc-5f1a2cb9c2dc09eed53da5d5787d14bec700b10b.tar.bz2 |
c++: Hard error with tentative parse and CTAD [PR87709]
When parsing e.g. the operand of sizeof, where both types and
expressions are accepted, if during the tentative type parse we
encounter an unexpected template placeholder, we must simulate
an error rather than issue a real error because the expression
parse can still succeed.
gcc/cp/ChangeLog:
PR c++/87709
* parser.c (cp_parser_type_id_1): If we see a template
placeholder, first try simulating an error before issuing
a real error.
gcc/testsuite/ChangeLog:
PR c++/87709
* g++.dg/cpp1z/class-deduction86.C: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/parser.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index fba516e..e1b1617 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -23270,10 +23270,13 @@ cp_parser_type_id_1 (cp_parser *parser, cp_parser_flags flags, location_t loc = type_specifier_seq.locations[ds_type_spec]; if (tree tmpl = CLASS_PLACEHOLDER_TEMPLATE (auto_node)) { - error_at (loc, "missing template arguments after %qT", - auto_node); - inform (DECL_SOURCE_LOCATION (tmpl), "%qD declared here", - tmpl); + if (!cp_parser_simulate_error (parser)) + { + error_at (loc, "missing template arguments after %qT", + auto_node); + inform (DECL_SOURCE_LOCATION (tmpl), "%qD declared here", + tmpl); + } } else if (parser->in_template_argument_list_p) error_at (loc, "%qT not permitted in template argument", |