[cfe-commits] r69476 - in /cfe/trunk: lib/Sema/SemaDecl.cpp test/Sema/scope-check.c
Chris Lattner
sabre at nondot.org
Sat Apr 18 14:00:42 PDT 2009
Author: lattner
Date: Sat Apr 18 16:00:42 2009
New Revision: 69476
URL: http://llvm.org/viewvc/llvm-project?rev=69476&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/scope-check.c
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=69476&r1=69475&r2=69476&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Apr 18 16:00:42 2009
@@ -3157,7 +3157,6 @@
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 @@
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;
}
Modified: cfe/trunk/test/Sema/scope-check.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/scope-check.c?rev=69476&r1=69475&r2=69476&view=diff
==============================================================================
--- cfe/trunk/test/Sema/scope-check.c (original)
+++ cfe/trunk/test/Sema/scope-check.c Sat Apr 18 16:00:42 2009
@@ -47,7 +47,6 @@
}
void test7(int x) {
-foo: // FIXME: remove
switch (x) {
case 1: ;
int a[x]; // expected-note {{jump bypasses initialization of variable length array}}
More information about the cfe-commits
mailing list