diff options
author | Chris Lattner <sabre@nondot.org> | 2009-04-18 21:00:42 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-04-18 21:00:42 +0000 |
commit | b56593725243becfe2685f39eec47406299801ae (patch) | |
tree | f3325a84c54d45c9beee44760b7466b28ca04eea | |
parent | 131038e2125d98f1be0d9cb62561a7cede41bb44 (diff) |
unconditionally check for goto correctness. This is because switch
statements don't end up in the LabelMap so we don't have a quick way
to filter them. We could add state to Sema (a "has vla" and "has
jump" bit) to try to filter this out, but that would be sort of gross
and I'm not convinced it is the best way. Thoughts welcome.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69476 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 6 | ||||
-rw-r--r-- | test/Sema/scope-check.c | 1 |
2 files changed, 2 insertions, 5 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index b580b01bc4..9424fc685c 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -3157,7 +3157,6 @@ Sema::DeclPtrTy Sema::ActOnFinishFunctionBody(DeclPtrTy D, StmtArg BodyArg) { assert(&getLabelMap() == &FunctionLabelMap && "Didn't pop block right?"); - bool HaveLabels = !FunctionLabelMap.empty(); // Check goto/label use. for (llvm::DenseMap<IdentifierInfo*, LabelStmt*>::iterator I = FunctionLabelMap.begin(), E = FunctionLabelMap.end(); I != E; ++I) { @@ -3197,9 +3196,8 @@ Sema::DeclPtrTy Sema::ActOnFinishFunctionBody(DeclPtrTy D, StmtArg BodyArg) { if (!Body) return D; - // If we have labels, verify that goto doesn't jump into scopes illegally. - if (HaveLabels) - JumpScopeChecker(Body, *this); + // Verify that that gotos and switch cases don't jump into scopes illegally. + JumpScopeChecker(Body, *this); return D; } diff --git a/test/Sema/scope-check.c b/test/Sema/scope-check.c index 93120cdf94..b7e3a21d55 100644 --- a/test/Sema/scope-check.c +++ b/test/Sema/scope-check.c @@ -47,7 +47,6 @@ int test6() { } void test7(int x) { -foo: // FIXME: remove switch (x) { case 1: ; int a[x]; // expected-note {{jump bypasses initialization of variable length array}} |