summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-03-16 16:39:03 +0000
committerDouglas Gregor <dgregor@apple.com>2011-03-16 16:39:03 +0000
commit46c04e74fba75b9b670834e61dec85db87068fb9 (patch)
tree6e0aa079b1f212f9e3ae0528c1b2cb6f9680a77f /clang/lib/Sema/SemaDecl.cpp
parent803adc1bcf05e08877e64cb13d16ed00203a436d (diff)
downloadbcm5719-llvm-46c04e74fba75b9b670834e61dec85db87068fb9.tar.gz
bcm5719-llvm-46c04e74fba75b9b670834e61dec85db87068fb9.zip
When we're inserting a synthesized label declaration for a
forward-looking "goto" statement, make sure to insert it *after* the last declaration in the identifier resolver's declaration chain that is either outside of the function/block/method's scope or that is declared in that function/block/method's specific scope. Previously, we could end up inserting the label ahead of declarations in inner scopes, confusing C++ name lookup. Fixes PR9491/<rdar://problem/9140426> and <rdar://problem/9135994>. Note that the crash-on-invalid PR9495 is *not* fixed. That's a separate issue. llvm-svn: 127737
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 19d96f2ec06..65a372850f2 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -500,11 +500,15 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext) {
// isn't strictly lexical, which breaks name lookup. Be careful to insert
// the label at the appropriate place in the identifier chain.
for (I = IdResolver.begin(D->getDeclName()); I != IEnd; ++I) {
- if ((*I)->getLexicalDeclContext()->Encloses(CurContext))
+ DeclContext *IDC = (*I)->getLexicalDeclContext();
+ if (IDC == CurContext) {
+ if (!S->isDeclScope(*I))
+ continue;
+ } else if (IDC->Encloses(CurContext))
break;
}
- IdResolver.InsertDecl(I, D);
+ IdResolver.InsertDeclAfter(I, D);
} else {
IdResolver.AddDecl(D);
}
OpenPOWER on IntegriCloud