]> granicus.if.org Git - clang/commitdiff
Check a few more kinds of declarations that make a scope.
authorEli Friedman <eli.friedman@gmail.com>
Sat, 28 Feb 2009 06:22:14 +0000 (06:22 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Sat, 28 Feb 2009 06:22:14 +0000 (06:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65680 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/Sema/scope-check.c

index 8a4ffaf65de6eaafa1bc614decc5a59fa43fb2e1..e99be90963e02d4d8b5cf82a1b6f4a35335e1684 100644 (file)
@@ -2503,6 +2503,9 @@ static bool StatementCreatesScope(Stmt* S) {
          i != DS->decl_end(); ++i) {
       if (VarDecl* D = dyn_cast<VarDecl>(*i)) {
         result |= D->getType()->isVariablyModifiedType();
+        result |= !!D->getAttr<CleanupAttr>();
+      } else if (TypedefDecl* D = dyn_cast<TypedefDecl>(*i)) {
+        result |= D->getUnderlyingType()->isVariablyModifiedType();
       }
     }
   }
index 0eb134cbd3bbf9f1921b386ef7389e4739aaeb5d..71c9d2fd39173137cd50b4999132f799d584736c 100644 (file)
@@ -6,3 +6,19 @@ int test1(int x) {
   L:
   return sizeof a;
 }
+
+int test2(int x) {
+  goto L; // expected-error{{illegal jump}}
+  typedef int a[x];
+  L:
+  return sizeof(a);
+}
+
+void test3clean(int*);
+
+int test3() {
+  goto L; // expected-error{{illegal jump}}
+  int a __attribute((cleanup(test3clean)));
+  L:
+  return a;
+}