diff options
author | Patrick Palka <ppalka@redhat.com> | 2020-03-28 08:57:11 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2020-03-28 08:57:11 -0400 |
commit | 7981c06ae92548bd66f07121db1802eb6aec73ed (patch) | |
tree | c5c9ddcf1dd284be44597236b30a683b91ba4ddd /gcc/testsuite/g++.dg | |
parent | a7ea3d2ced786c4544fa625f34f515d89ed074fe (diff) | |
download | gcc-7981c06ae92548bd66f07121db1802eb6aec73ed.zip gcc-7981c06ae92548bd66f07121db1802eb6aec73ed.tar.gz gcc-7981c06ae92548bd66f07121db1802eb6aec73ed.tar.bz2 |
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.
Diffstat (limited to 'gcc/testsuite/g++.dg')
-rw-r--r-- | gcc/testsuite/g++.dg/concepts/diagnostic8.C | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/concepts/diagnostic8.C b/gcc/testsuite/g++.dg/concepts/diagnostic8.C new file mode 100644 index 0000000..70d7e4a --- /dev/null +++ b/gcc/testsuite/g++.dg/concepts/diagnostic8.C @@ -0,0 +1,6 @@ +// PR c++/94306 +// { dg-do compile { target c++2a } } + +template<typename T> struct S { }; +template<typename T> requires { typename T::type; } struct S<T> { }; +// { dg-error "missing additional .requires." "" { target *-*-* } .-1 } |