]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: parse error with -std=c++14 -fconcepts [PR116071]
authorJason Merrill <jason@redhat.com>
Wed, 24 Jul 2024 20:20:33 +0000 (16:20 -0400)
committerThomas Koenig <tkoenig@gcc.gnu.org>
Sun, 28 Jul 2024 17:05:53 +0000 (19:05 +0200)
commitea94dde1aa58bd337772f74787f821b34f866c4a
tree5484d1e35ac51cd2f320ae142b4b5fb8551e0fff
parent2e6caf0f849f92332e95c468d6d989699301db77
c++: parse error with -std=c++14 -fconcepts [PR116071]

cp_parser_simple_type_specifier tries a variety of different things that
might qualify as a user-defined type: an actual type-name, a constrained
auto, a CTAD placeholder.  In a context where a type-specifier is optional,
this is all tentative.  With -std=c++14 -fconcepts, we try type-name and
constrained auto in sub-tentative parses, and when we run out of things to
try we haven't found anything but also haven't failed the outer tentative
parse, so parse_definitely succeeds, discarding the nested-name-specifier.

Fixed by failing if we didn't find anything.

I said in r14-3203 that we should disable this combination of flags if
further problems arise, but this seems like a more general problem that only
happened to occur with just this combination of flags.  So it lives on.

PR c++/116071

gcc/cp/ChangeLog:

* parser.cc (cp_parser_simple_type_specifier): Call
cp_parser_simulate_error if nothing worked.

gcc/testsuite/ChangeLog:

* g++.dg/parse/pr116071.C: New test.
gcc/cp/parser.cc
gcc/testsuite/g++.dg/parse/pr116071.C [new file with mode: 0644]