summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2012-11-10 01:38:24 +0000
committerDavid Blaikie <dblaikie@gmail.com>2012-11-10 01:38:24 +0000
commit3d512d8a75d4cb4609398ce3c2a3ba4c01a23513 (patch)
tree3c1a0eda0b7cee73a8181b78074b6e4c43d89d44
parentd777e2845110469182809e4efc577899395805f7 (diff)
downloadclang-3d512d8a75d4cb4609398ce3c2a3ba4c01a23513.tar.gz
clang-3d512d8a75d4cb4609398ce3c2a3ba4c01a23513.tar.bz2
clang-3d512d8a75d4cb4609398ce3c2a3ba4c01a23513.tar.xz
Handle redeclarations of catch variables in catch blocks.
Fix to regression caused by r167650, caught by Richard Smith in code review. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167653 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Sema/IdentifierResolver.cpp5
-rw-r--r--test/CXX/basic/basic.scope/basic.scope.local/p2.cpp12
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/Sema/IdentifierResolver.cpp b/lib/Sema/IdentifierResolver.cpp
index 50413c3d95..00939151c6 100644
--- a/lib/Sema/IdentifierResolver.cpp
+++ b/lib/Sema/IdentifierResolver.cpp
@@ -138,8 +138,11 @@ bool IdentifierResolver::isDeclInScope(Decl *D, DeclContext *Ctx,
if (S->getFlags() & Scope::FnTryScope)
return S->getParent()->isDeclScope(D);
if (S->getParent()->getFlags() & Scope::ControlScope) {
- if (S->getParent()->getFlags() & Scope::FnCatchScope)
+ if (S->getParent()->getFlags() & Scope::FnCatchScope) {
S = S->getParent();
+ if (S->isDeclScope(D))
+ return true;
+ }
return S->getParent()->isDeclScope(D);
}
}
diff --git a/test/CXX/basic/basic.scope/basic.scope.local/p2.cpp b/test/CXX/basic/basic.scope/basic.scope.local/p2.cpp
index 624118cc36..91e96b6b26 100644
--- a/test/CXX/basic/basic.scope/basic.scope.local/p2.cpp
+++ b/test/CXX/basic/basic.scope/basic.scope.local/p2.cpp
@@ -23,3 +23,15 @@ void func5() try {
} catch (...) {
int j = i; // expected-error{{use of undeclared identifier 'i'}}
}
+
+void func6() try {
+} catch (int i) { // expected-note{{previous definition is here}}
+ int i; // expected-error{{redefinition of 'i'}}
+}
+
+void func7() {
+ try {
+ } catch (int i) { // expected-note{{previous definition is here}}
+ int i; // expected-error{{redefinition of 'i'}}
+ }
+}