diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-10-20 15:58:54 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-10-20 15:58:54 +0000 |
commit | ba4ee9a9b6e4cffc12bb6b395a58b89c189bb07e (patch) | |
tree | 981f20d4883bb0a8f793196dc127432ff25d0120 /lib/Sema/SemaDeclCXX.cpp | |
parent | afdc21ad774eff6ed6c464e3f2dff9e26ed3d0b0 (diff) |
When we parse something that looks like a templated friend tag but
actually just has an extraneous 'template<>' header, strip off the
'template<>' header and treat it as a normal friend tag. Fixes PR10660
/ <rdar://problem/9958322>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142587 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclCXX.cpp')
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 951ea9ccfd..bb867ed33e 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -9746,8 +9746,6 @@ Decl *Sema::ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, if (Invalid) return 0; - assert(SS.isNotEmpty() && "valid templated tag with no SS and no direct?"); - bool isAllExplicitSpecializations = true; for (unsigned I = TempParamLists.size(); I-- > 0; ) { if (TempParamLists.get()[I]->size()) { @@ -9762,6 +9760,18 @@ Decl *Sema::ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, // about the template header and build an appropriate non-templated // friend. TODO: for source fidelity, remember the headers. if (isAllExplicitSpecializations) { + if (SS.isEmpty()) { + bool Owned = false; + bool IsDependent = false; + return ActOnTag(S, TagSpec, TUK_Friend, TagLoc, SS, Name, NameLoc, + Attr, AS_public, + /*ModulePrivateLoc=*/SourceLocation(), + MultiTemplateParamsArg(), Owned, IsDependent, + /*ScopedEnum=*/false, + /*ScopedEnumUsesClassTag=*/false, + /*UnderlyingType=*/TypeResult()); + } + NestedNameSpecifierLoc QualifierLoc = SS.getWithLocInContext(Context); ElaboratedTypeKeyword Keyword = TypeWithKeyword::getKeywordForTagTypeKind(Kind); @@ -9789,6 +9799,10 @@ Decl *Sema::ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, CurContext->addDecl(Friend); return Friend; } + + assert(SS.isNotEmpty() && "valid templated tag with no SS and no direct?"); + + // Handle the case of a templated-scope friend class. e.g. // template <class T> class A<T>::B; |