diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-06-29 21:22:02 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-06-29 21:22:02 +0000 |
commit | 825faf7a4faec8083b87ae2c98a1296991d161b5 (patch) | |
tree | fc8cb879ca85cd5ba2b8cf1a72c2c3e4d79d451a /clang/lib/Sema/SemaDecl.cpp | |
parent | 6999f86617f371784be2b6f8d2ae38c8030dfd31 (diff) | |
download | bcm5719-llvm-825faf7a4faec8083b87ae2c98a1296991d161b5.tar.gz bcm5719-llvm-825faf7a4faec8083b87ae2c98a1296991d161b5.zip |
When redeclaring a local extern in the same scope, make sure that we
replace the existing declaration appropriately. Patch by Jordy Rose,
fixes PR10013 / <rdar://problem/9584157>.
llvm-svn: 134097
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 2779faeb15c..8069eb43859 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -3299,8 +3299,18 @@ Sema::RegisterLocallyScopedExternCDecl(NamedDecl *ND, if (S && IdResolver.ReplaceDecl(PrevDecl, ND)) { // The previous declaration was found on the identifer resolver // chain, so remove it from its scope. - while (S && !S->isDeclScope(PrevDecl)) - S = S->getParent(); + + if (S->isDeclScope(PrevDecl)) { + // Special case for redeclarations in the SAME scope. + // Because this declaration is going to be added to the identifier chain + // later, we should temporarily take it OFF the chain. + IdResolver.RemoveDecl(ND); + + } else { + // Find the scope for the original declaration. + while (S && !S->isDeclScope(PrevDecl)) + S = S->getParent(); + } if (S) S->RemoveDecl(PrevDecl); |