-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Closed
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"questionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Description
In the example below, foo
is reported to be undeclared unless one of the arguments is the class type.
struct S {
friend void foo(){};
friend void foo(void*){};
friend void foo(void*, void*){};
};
void test() {
foo(); // use of undeclared identifier 'foo'
foo(nullptr); // use of undeclared identifier 'foo'
foo((S*)nullptr); // no error
foo(nullptr, nullptr); // use of undeclared identifier 'foo'
foo((S*)nullptr, nullptr); // no error
foo(nullptr, (S*)nullptr); // no error
foo((S*)nullptr, (S*)nullptr); // no error
}
I think that in all the cases, foo
should be declared (and also defined), so the program should be valid.
https://eel.is/c++draft/class.friend#example-6 provides an example of defining friend function within the class.
Metadata
Metadata
Assignees
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"questionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!