diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-10-21 03:15:03 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2016-10-21 03:15:03 +0000 |
| commit | fdf0888b6969864d18ce262f4b343d9226b9e22a (patch) | |
| tree | 5cf79945f62712c4cfdac4754e161e05efe6bc2e /clang/lib/Sema | |
| parent | 81440dc93fa423a620094f0d9afd58e1b8e4b3aa (diff) | |
| download | bcm5719-llvm-fdf0888b6969864d18ce262f4b343d9226b9e22a.tar.gz bcm5719-llvm-fdf0888b6969864d18ce262f4b343d9226b9e22a.zip | |
Don't try to use !Previous.empty() as a proxy for "Is this a redeclaration?" --
we don't collapse that down to a single entry if it's not a redeclaration.
Instead, set the Redeclaration bit on the Declarator to indicate whether a
function is a redeclaration (which may not have been linked into the
redeclaration chain if it's a dependent context friend).
Fixes a rejects-valid; see testcase.
llvm-svn: 284802
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 7 |
2 files changed, 4 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index b483690a03c..2711b362685 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -8445,7 +8445,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, ? cast<NamedDecl>(FunctionTemplate) : NewFD); - if (isFriend && D.isRedeclaration()) { + if (isFriend && NewFD->getPreviousDecl()) { AccessSpecifier Access = AS_public; if (!NewFD->isInvalidDecl()) Access = NewFD->getPreviousDecl()->getAccess(); @@ -8901,8 +8901,6 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, NewFD->setPreviousDeclaration(cast<FunctionDecl>(OldDecl)); if (isa<CXXMethodDecl>(NewFD)) NewFD->setAccess(OldDecl->getAccess()); - } else { - Redeclaration = false; } } } diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index c1938d5e8e6..f49525c6e45 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -13785,10 +13785,9 @@ NamedDecl *Sema::ActOnFriendFunctionDecl(Scope *S, Declarator &D, // template in the translation unit. if (functionDeclHasDefaultArgument(FD)) { // We can't look at FD->getPreviousDecl() because it may not have been set - // if we're in a dependent context. If we get this far with a non-empty - // Previous set, we must have a valid previous declaration of this - // function. - if (!Previous.empty()) { + // if we're in a dependent context. If the function is known to be a + // redeclaration, we will have narrowed Previous down to the right decl. + if (D.isRedeclaration()) { Diag(FD->getLocation(), diag::err_friend_decl_with_def_arg_redeclared); Diag(Previous.getRepresentativeDecl()->getLocation(), diag::note_previous_declaration); |

