Open cjdb opened 1 year ago
Hello @cjdb, I have written a local fix but not sure if this is alsong the expected lines of work, here the diagnostic can be changed accordingly I have added the following code to ExprResult Parser::ParseCastExpression
in the clang/lib/Parse/ParseExpr.cpp
case tok::kw_concept:{
if(getLangOpts().CPlusPlus20 || getLangOpts().C23)
Diag(Tok.getLocation(),diag::err_concept_decls_may_only_appear_in_global_namespace_scope);
}
working :
/home/happy/c++/n1.cpp:9:9: error: concept declarations may only appear in global or namespace scope
9 | void f(concept int);
| ^
Given
void f(concept int);
, Clang will emit the following:Neither of these diagnostics describe the two problems with the source. Better diagnostics would look like:
I'd personally prefer for the second one to be
expected an unqualified identifier, got keyword 'int'
, but that's beyond the scope of this commit due to how much it impacts.