-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Instantiating class template with friend declaration of C::f() hides in-line definition of C::f(). #9161
Comments
If I add a "return 0" after the comment but before the call to Visit here // All of the Visit implementations for the various potential friend in TemplateDeclInstantiator::VisitFriendDecl(), the problem goes away. +rjmccall who added the comment – maybe it's obvious to him what needs to be done here. |
Further down the stack, removing this block if (isFriend) {
} from TemplateDeclInstantiator::VisitCXXMethodDecl() helps. |
Proposed patch (will add a test case): Index: lib/Sema/SemaTemplateInstantiateDecl.cpp--- lib/Sema/SemaTemplateInstantiateDecl.cpp (revision 121783)
|
Probably better proposed patch: @@ -1436,9 +1435,7 @@
|
Patch attempt at http://lists.cs.uiuc.edu/pipermail/cfe-dev/2010-December/012590.html |
I fixed this in a totally different way in r121833. |
Our builders are happy again – thanks! |
…ce-to-20240723 [cherry-pick][stable/20240723] [lldb][ClangExpressionParser] Implement ExternalSemaSource::ReadUndefinedButUsed
Extended Description
Compiling and linking the following code with Clang built from trunk r121764 fails:
template
class ClassTemplate {
friend void T::func();
};
class C {
public:
void func() {
ClassTemplate ct;
}
};
int main() {
C c;
c.func();
}
$ clang++ /tmp/c.cc
/usr/bin/ld: /tmp/cc-QB69fY.o: in function main:/tmp/c.cc(.text+0x14): error: undefined reference to 'C::func()'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
If C::func() is defined out-of-line, it works.
It seems like instantiating ClassTemplate<> with its friend declaration of T::func() somehow makes the in-line definition of C::func() disappear.
The text was updated successfully, but these errors were encountered: