From: Eli Friedman Date: Sat, 28 Feb 2009 06:22:14 +0000 (+0000) Subject: Check a few more kinds of declarations that make a scope. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=709fa15defbc0208b33707b3da3a628df5a9b7b9;p=clang Check a few more kinds of declarations that make a scope. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65680 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 8a4ffaf65d..e99be90963 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -2503,6 +2503,9 @@ static bool StatementCreatesScope(Stmt* S) { i != DS->decl_end(); ++i) { if (VarDecl* D = dyn_cast(*i)) { result |= D->getType()->isVariablyModifiedType(); + result |= !!D->getAttr(); + } else if (TypedefDecl* D = dyn_cast(*i)) { + result |= D->getUnderlyingType()->isVariablyModifiedType(); } } } diff --git a/test/Sema/scope-check.c b/test/Sema/scope-check.c index 0eb134cbd3..71c9d2fd39 100644 --- a/test/Sema/scope-check.c +++ b/test/Sema/scope-check.c @@ -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; +}