diff options
| author | John McCall <rjmccall@apple.com> | 2010-08-20 01:40:01 +0000 |
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2010-08-20 01:40:01 +0000 |
| commit | a189f2eb0ab9e7ccbf1136a7f3f9f9c541c57be5 (patch) | |
| tree | 23a4e68e469c14551cb7f1085c453f117297d980 /clang/lib/Sema | |
| parent | 5466e751f0c911815fe62684164667bd659f60d2 (diff) | |
| download | bcm5719-llvm-a189f2eb0ab9e7ccbf1136a7f3f9f9c541c57be5.tar.gz bcm5719-llvm-a189f2eb0ab9e7ccbf1136a7f3f9f9c541c57be5.zip | |
Detect efforts to declare a template member friend and explicitly ignore them.
Avoids a crash.
llvm-svn: 111609
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaAccess.cpp | 3 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 2 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaTemplate.cpp | 11 |
3 files changed, 15 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaAccess.cpp b/clang/lib/Sema/SemaAccess.cpp index 90d31772221..e2b7a7e061d 100644 --- a/clang/lib/Sema/SemaAccess.cpp +++ b/clang/lib/Sema/SemaAccess.cpp @@ -514,6 +514,9 @@ static AccessResult MatchesFriend(Sema &S, static AccessResult MatchesFriend(Sema &S, const EffectiveContext &EC, FriendDecl *FriendD) { + if (FriendD->isInvalidDecl()) + return AR_accessible; + if (TypeSourceInfo *T = FriendD->getFriendType()) return MatchesFriend(S, EC, T->getType()->getCanonicalTypeUnqualified()); diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 19580957832..1d633a90480 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -6538,6 +6538,8 @@ Sema::ActOnFriendFunctionDecl(Scope *S, FrD->setAccess(AS_public); CurContext->addDecl(FrD); + if (ND->isInvalidDecl()) FrD->setInvalidDecl(); + return DeclPtrTy::make(ND); } diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 5cfacf78b57..af852aa3406 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -1365,8 +1365,12 @@ Sema::MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc, // If there were at least as many template-ids as there were template // parameter lists, then there are no template parameter lists remaining for // the declaration itself. - if (Idx >= NumParamLists) + if (Idx >= NumParamLists) { + // Silently drop template member friend declarations. + // TODO: implement these + if (IsFriend && NumParamLists) Invalid = true; return 0; + } // If there were too many template parameter lists, complain about that now. if (Idx != NumParamLists - 1) { @@ -1395,6 +1399,11 @@ Sema::MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc, } } + // Silently drop template member template friend declarations. + // TODO: implement these + if (IsFriend && NumParamLists > 1) + Invalid = true; + // Return the last template parameter list, which corresponds to the // entity being declared. return ParamLists[NumParamLists - 1]; |

