From 7cbd08766ce78cc0735c242fb231dfd933ccad69 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Mon, 29 Sep 2014 05:57:29 +0000 Subject: [PATCH] Fix "unsupported friend" diagnostic to also appear for friend functions with dependent scopes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@218590 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDeclCXX.cpp | 6 +++++- test/CXX/temp/temp.decls/temp.friend/p5.cpp | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index acf7f2ac96..16e1b2f6f2 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -12242,8 +12242,12 @@ NamedDecl *Sema::ActOnFriendFunctionDecl(Scope *S, Declarator &D, } // Mark templated-scope function declarations as unsupported. - if (FD->getNumTemplateParameterLists()) + if (FD->getNumTemplateParameterLists() && SS.isValid()) { + Diag(FD->getLocation(), diag::warn_template_qualified_friend_unsupported) + << SS.getScopeRep() << SS.getRange() + << cast(CurContext); FrD->setUnsupportedFriend(true); + } } return ND; diff --git a/test/CXX/temp/temp.decls/temp.friend/p5.cpp b/test/CXX/temp/temp.decls/temp.friend/p5.cpp index b26abb64f8..c4f9d63b7c 100644 --- a/test/CXX/temp/temp.decls/temp.friend/p5.cpp +++ b/test/CXX/temp/temp.decls/temp.friend/p5.cpp @@ -20,7 +20,7 @@ namespace test1 { class C { static void foo(); - template friend void A::f(); + template friend void A::f(); // expected-warning {{not supported}} }; template struct A { @@ -42,7 +42,7 @@ namespace test2 { class C { static void foo(); - template friend void A::g(); + template friend void A::g(); // expected-warning {{not supported}} }; template struct A { @@ -86,7 +86,7 @@ namespace test4 { template template - friend void X::operator+=(U); + friend void X::operator+=(U); // expected-warning {{not supported}} }; void test() { @@ -96,7 +96,7 @@ namespace test4 { namespace test5 { template