diff options
-rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 6 | ||||
-rw-r--r-- | clang/test/CXX/temp/temp.decls/temp.friend/p5.cpp | 8 |
2 files changed, 9 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index acf7f2ac960..16e1b2f6f2c 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/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<CXXRecordDecl>(CurContext); FrD->setUnsupportedFriend(true); + } } return ND; diff --git a/clang/test/CXX/temp/temp.decls/temp.friend/p5.cpp b/clang/test/CXX/temp/temp.decls/temp.friend/p5.cpp index b26abb64f83..c4f9d63b7c6 100644 --- a/clang/test/CXX/temp/temp.decls/temp.friend/p5.cpp +++ b/clang/test/CXX/temp/temp.decls/temp.friend/p5.cpp @@ -20,7 +20,7 @@ namespace test1 { class C { static void foo(); - template <class T> friend void A<T>::f(); + template <class T> friend void A<T>::f(); // expected-warning {{not supported}} }; template <class T> struct A { @@ -42,7 +42,7 @@ namespace test2 { class C { static void foo(); - template <class T> friend void A<T>::g(); + template <class T> friend void A<T>::g(); // expected-warning {{not supported}} }; template <class T> struct A { @@ -86,7 +86,7 @@ namespace test4 { template <class V> template <class U> - friend void X<V>::operator+=(U); + friend void X<V>::operator+=(U); // expected-warning {{not supported}} }; void test() { @@ -96,7 +96,7 @@ namespace test4 { namespace test5 { template<template <class> class T> struct A { - template<template <class> class U> friend void A<U>::foo(); + template<template <class> class U> friend void A<U>::foo(); // expected-warning {{not supported}} }; template <class> struct B {}; |