c++: Diagnose when "requires" is used instead of "requires requires" [PR94306]
authorPatrick Palka <ppalka@redhat.com>
Sat, 28 Mar 2020 12:57:11 +0000 (08:57 -0400)
committerPatrick Palka <ppalka@redhat.com>
Sat, 28 Mar 2020 12:57:11 +0000 (08:57 -0400)
commit7981c06ae92548bd66f07121db1802eb6aec73ed
treec5c9ddcf1dd284be44597236b30a683b91ba4ddd
parenta7ea3d2ced786c4544fa625f34f515d89ed074fe
c++: Diagnose when "requires" is used instead of "requires requires" [PR94306]

This adds support to detect and recover from the case where an opening brace
immediately follows the start of a requires-clause.  So rather than emitting the
error

  error: expected primary-expression before '{' token

followed by a slew of irrevelant errors, we now assume the user had intended to
write "requires requires {" and diagnose and recover accordingly.

gcc/cp/ChangeLog:

PR c++/94306
* parser.c (cp_parser_requires_clause_opt): Diagnose and recover from
"requires {" when "requires requires {" was probably intended.

gcc/testsuite/ChangeLog:

PR c++/94306
* g++.dg/concepts/diagnostic8.C: New test.
gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/concepts/diagnostic8.C [new file with mode: 0644]