A class template partial specialization cannot be a friend. Fixes PR8649.

llvm-svn: 122325
This commit is contained in:
Douglas Gregor 2010-12-21 08:14:57 +00:00
parent 7ecd19ecde
commit ec9518be89
3 changed files with 17 additions and 0 deletions

View File

@ -474,6 +474,8 @@ def err_tagless_friend_type_template : Error<
"friend type templates must use an elaborated type">;
def err_no_matching_local_friend : Error<
"no matching function found in local scope">;
def err_partial_specialization_friend : Error<
"partial specialization cannot be declared as a friend">;
def err_abstract_type_in_decl : Error<
"%select{return|parameter|variable|field}0 type %1 is an abstract class">;

View File

@ -4087,6 +4087,12 @@ Sema::ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec,
if (TemplateParams && TemplateParams->size() > 0) {
isPartialSpecialization = true;
if (TUK == TUK_Friend) {
Diag(KWLoc, diag::err_partial_specialization_friend)
<< SourceRange(LAngleLoc, RAngleLoc);
return true;
}
// C++ [temp.class.spec]p10:
// The template parameter list of a specialization shall not
// contain default template argument values.

View File

@ -207,3 +207,12 @@ namespace PR7013b {
}
}
namespace PR8649 {
template<typename T, typename U, unsigned N>
struct X {
template<unsigned M> friend class X<T, U, M>; // expected-error{{partial specialization cannot be declared as a friend}}
};
X<int, float, 7> x;
}