[cfe-commits] r167653 - in /cfe/trunk: lib/Sema/IdentifierResolver.cpp test/CXX/basic/basic.scope/basic.scope.local/p2.cpp

David Blaikie dblaikie at gmail.com
Fri Nov 9 17:38:24 PST 2012


Author: dblaikie
Date: Fri Nov  9 19:38:24 2012
New Revision: 167653

URL: http://llvm.org/viewvc/llvm-project?rev=167653&view=rev
Log:
Handle redeclarations of catch variables in catch blocks.

Fix to regression caused by r167650, caught by Richard Smith in code review.

Modified:
    cfe/trunk/lib/Sema/IdentifierResolver.cpp
    cfe/trunk/test/CXX/basic/basic.scope/basic.scope.local/p2.cpp

Modified: cfe/trunk/lib/Sema/IdentifierResolver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/IdentifierResolver.cpp?rev=167653&r1=167652&r2=167653&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/IdentifierResolver.cpp (original)
+++ cfe/trunk/lib/Sema/IdentifierResolver.cpp Fri Nov  9 19:38:24 2012
@@ -138,8 +138,11 @@
       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);
       }
     }

Modified: cfe/trunk/test/CXX/basic/basic.scope/basic.scope.local/p2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/basic/basic.scope/basic.scope.local/p2.cpp?rev=167653&r1=167652&r2=167653&view=diff
==============================================================================
--- cfe/trunk/test/CXX/basic/basic.scope/basic.scope.local/p2.cpp (original)
+++ cfe/trunk/test/CXX/basic/basic.scope/basic.scope.local/p2.cpp Fri Nov  9 19:38:24 2012
@@ -23,3 +23,15 @@
 } 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'}}
+  }
+}





More information about the cfe-commits mailing list