Hi,
Attaching patch for bug 19095. Please help in reviewing the same.
Also, I haven't attached a test case yet in the patch as i am not sure how
it should be and in which file it should be.
In my opinion, the test case would go into *tools/clang/test/SemaCXX/friend.cpp
*would be something like below (similar to that mentioned in the bug)
*template <class T>void f(T);*
*void h(T);*
*template <class U>class C{ template <class T> friend void f(T) {*
* int x = 1;*
* }*
* template <class T>*
* friend void h(T); *
* public : void g() { f(3.0); // OK*
* h(2.0); // error : undefined reference to function h*
* } int i;};void h (){ f(7); // OK*
* h(6); // error : undefined reference to function h*
* C<double> c; c.g();}*
Please help in reviewing the patch as well as the test case.
--
With regards,
Suyog Sarda
Index: SemaTemplateInstantiateDecl.cpp
===================================================================
--- SemaTemplateInstantiateDecl.cpp (revision 203929)
+++ SemaTemplateInstantiateDecl.cpp (working copy)
@@ -1331,9 +1331,7 @@
FunctionTemplate->setLexicalDeclContext(LexicalDC);
- if (isFriend && D->isThisDeclarationADefinition()) {
- // TODO: should we remember this connection regardless of whether
- // the friend declaration provided a body?
+ if (isFriend && D->isThisDeclarationADefinition() && !D->hasBody()) {
FunctionTemplate->setInstantiatedFromMemberTemplate(
D->getDescribedFunctionTemplate());
}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits