[Bug c++/94306] New: Improve diagnostic when "requires" used instead of "requires requires" and add fix-it
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Mar 24 17:55:57 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94306
Bug ID: 94306
Summary: Improve diagnostic when "requires" used instead of
"requires requires" and add fix-it
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
template<typename T> struct S { };
template<typename T> requires { typename T::type; } struct S<T> { };
This gives:
c.cc:2:31: error: expected primary-expression before '{' token
2 | template<typename T> requires { typename T::type; } struct S<T> { };
| ^
c.cc:2:31: error: expected unqualified-id before '{' token
c.cc:2:62: error: 'T' was not declared in this scope
2 | template<typename T> requires { typename T::type; } struct S<T> { };
| ^
c.cc:2:63: error: template argument 1 is invalid
2 | template<typename T> requires { typename T::type; } struct S<T> { };
| ^
c.cc:2:53: error: an explicit specialization must be preceded by 'template <>'
2 | template<typename T> requires { typename T::type; } struct S<T> { };
| ^~~~~~~~~~~
| template <>
The first error is right. The second seems redundant with the first.
The rest of the errors seem bogus. T has been declared, the template argument
is valid, and the specialization is preceded by a template-head.
It would be good to suggest that it should say "requires requires {" and show a
fix-it hint.
More information about the Gcc-bugs
mailing list