-
Notifications
You must be signed in to change notification settings - Fork 13.6k
"friends can only be classes or functions" should also be diagnosed when trying to befriend a concept #45182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think we have to fix parser first to not emit this wrong error message - error: expected member name or ';' after declaration specifiers llvm-project/clang/lib/Parse/ParseDecl.cpp Lines 6252 to 6590 in fb40c34
and let then sema to handle the error - error: friends can only be classes or function here - llvm-project/clang/lib/Sema/SemaDeclCXX.cpp Lines 17155 to 17469 in fb40c34
|
@Sirraide any chance you want to look at this one? |
Having looked at the code that parses |
Diagnose this early after parsing declaration specifiers; this allows us to issue a better diagnostic. This also checks for `concept friend` and concept declarations w/o a template-head because it’s easiest to do that at the same time. Fixes llvm#45182.
Extended Description
https://godbolt.org/z/jntYnj
Given this code:
struct S {
template
friend concept fooable;
};
Clang produces this harsh syntax error:
error: expected member name or ';' after declaration specifiers
friend concept fooable;
^
If you try to befriend any other kind of entity -- for example, a variable or variable template -- Clang gives a much friendlier error message, indicating that it understands what you were trying to do:
error: friends can only be classes or functions
friend bool fooable_v;
^
People are already trying to befriend concepts in the field, so it would be nice if Clang gave that same friendly error message (diag::err_unexpected_friend) for the
concept
case, as well.The text was updated successfully, but these errors were encountered: