diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-08-27 22:31:34 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-08-27 22:31:34 +0000 |
| commit | 5971e8c2dbdd27329be5cf61bc59fa9e67e1f7cb (patch) | |
| tree | 61fd3423fea1cfc56d98f2dc5aa192797745e464 /clang/lib | |
| parent | abf6ec45cd6454c1c3c9e29aa3367c219ddc3b7d (diff) | |
| download | bcm5719-llvm-5971e8c2dbdd27329be5cf61bc59fa9e67e1f7cb.tar.gz bcm5719-llvm-5971e8c2dbdd27329be5cf61bc59fa9e67e1f7cb.zip | |
PR20769: Fix confusion when checking whether a prior default argument was in
scope when checking for conflicts.
llvm-svn: 216628
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Sema/IdentifierResolver.cpp | 3 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 16 |
2 files changed, 13 insertions, 6 deletions
diff --git a/clang/lib/Sema/IdentifierResolver.cpp b/clang/lib/Sema/IdentifierResolver.cpp index 2a5bacff0d9..6586fb32787 100644 --- a/clang/lib/Sema/IdentifierResolver.cpp +++ b/clang/lib/Sema/IdentifierResolver.cpp @@ -130,6 +130,9 @@ bool IdentifierResolver::isDeclInScope(Decl *D, DeclContext *Ctx, Scope *S, return false; } + // FIXME: If D is a local extern declaration, this check doesn't make sense; + // we should be checking its lexical context instead in that case, because + // that is its scope. DeclContext *DCtx = D->getDeclContext()->getRedeclContext(); return AllowInlineNamespace ? Ctx->InEnclosingNamespaceSetOf(DCtx) : Ctx->Equals(DCtx); diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 081d91e0506..f0925e478b1 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -446,20 +446,24 @@ bool Sema::MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old, bool OldParamHasDfl = OldParam->hasDefaultArg(); bool NewParamHasDfl = NewParam->hasDefaultArg(); - NamedDecl *ND = Old; - // The declaration context corresponding to the scope is the semantic // parent, unless this is a local function declaration, in which case // it is that surrounding function. - DeclContext *ScopeDC = New->getLexicalDeclContext(); - if (!ScopeDC->isFunctionOrMethod()) - ScopeDC = New->getDeclContext(); - if (S && !isDeclInScope(ND, ScopeDC, S) && + DeclContext *ScopeDC = New->isLocalExternDecl() + ? New->getLexicalDeclContext() + : New->getDeclContext(); + if (S && !isDeclInScope(Old, ScopeDC, S) && !New->getDeclContext()->isRecord()) // Ignore default parameters of old decl if they are not in // the same scope and this is not an out-of-line definition of // a member function. OldParamHasDfl = false; + if (New->isLocalExternDecl() != Old->isLocalExternDecl()) + // If only one of these is a local function declaration, then they are + // declared in different scopes, even though isDeclInScope may think + // they're in the same scope. (If both are local, the scope check is + // sufficent, and if neither is local, then they are in the same scope.) + OldParamHasDfl = false; if (OldParamHasDfl && NewParamHasDfl) { |

