https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92044
Bug ID: 92044 Summary: Poor diagnostics for concept that should be a qualified-id Product: gcc Version: 9.1.1 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: --- namespace N { template<typename T> concept foo = true; } template<typename T> requires N::foo<T> void ok(T) { } template<typename T> requires foo<T> void bad1(T) { } template<typename T> requires (foo<T>) void bad2(T) { } dym.cc:9:34: error: expression after 'requires' must be enclosed in parentheses 9 | template<typename T> requires foo<T> | ^ dym.cc:9:34: error: expression after 'requires' must be enclosed in parentheses dym.cc:9:34: error: expected unqualified-id before '<' token dym.cc:12:32: error: 'foo' was not declared in this scope; did you mean 'concept foo'? 12 | template<typename T> requires (foo<T>) | ^~~ | concept foo dym.cc:3:13: note: 'concept foo' declared here 3 | concept foo = true; | ^~~ dym.cc:12:32: error: 'foo' was not declared in this scope; did you mean 'concept foo'? 12 | template<typename T> requires (foo<T>) | ^~~ | concept foo dym.cc:3:13: note: 'concept foo' declared here 3 | concept foo = true; | ^~~ dym.cc:12:22: error: expression after 'requires' must be enclosed in parentheses 12 | template<typename T> requires (foo<T>) | ^~~~~~~~ dym.cc:12:35: error: expected ')' before '<' token 12 | template<typename T> requires (foo<T>) | ~ ^ | ) The first error is misleading, the expression doesn't need to be enclosed in parentheses, it needs to be qualified (but the compiler doesn't know that so thinks it's a less-than expression). The second error is a duplicate of the first. The third is reasonable, given the first error, but it would be nice if it could be suppressed. Ideally the compiler would look for 'foo' and suggest qualifying it instead of adding the parentheses (which wouldn't actually fix anything). The fourth error should say "did you mean 'N::foo'?" not 'concept foo'. The fifth error is just nonsense, it *is* enclosed in parentheses. Could that and the sixth error be suppressed after the earlier "did you mean"?