]> granicus.if.org Git - clang/commitdiff
Handle redeclarations of catch variables in catch blocks.
authorDavid Blaikie <dblaikie@gmail.com>
Sat, 10 Nov 2012 01:38:24 +0000 (01:38 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Sat, 10 Nov 2012 01:38:24 +0000 (01:38 +0000)
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

lib/Sema/IdentifierResolver.cpp
test/CXX/basic/basic.scope/basic.scope.local/p2.cpp

index 50413c3d95897582a12e9c123a449a52a30a41d3..00939151c67394b523ee12407ed8de379e050c1b 100644 (file)
@@ -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);
       }
     }
index 624118cc36f85b1d7aca3b587733bb904a2410e2..91e96b6b2622fec395e05f69b787ea0e02759137 100644 (file)
@@ -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'}}
+  }
+}