[cfe-commits] r139971 - in /cfe/trunk: lib/Sema/JumpDiagnostics.cpp test/SemaCXX/MicrosoftExtensions.cpp test/SemaCXX/scope-check.cpp
Francois Pichet
pichet2000 at gmail.com
Fri Sep 16 16:15:32 PDT 2011
Author: fpichet
Date: Fri Sep 16 18:15:32 2011
New Revision: 139971
URL: http://llvm.org/viewvc/llvm-project?rev=139971&view=rev
Log:
In Microsoft mode, warn if an indirect goto jump over a variable initialization.
Also add a test case for the non Microsoft case because such test didn't exist.
Modified:
cfe/trunk/lib/Sema/JumpDiagnostics.cpp
cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
cfe/trunk/test/SemaCXX/scope-check.cpp
Modified: cfe/trunk/lib/Sema/JumpDiagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/JumpDiagnostics.cpp?rev=139971&r1=139970&r2=139971&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/JumpDiagnostics.cpp (original)
+++ cfe/trunk/lib/Sema/JumpDiagnostics.cpp Fri Sep 16 18:15:32 2011
@@ -485,7 +485,8 @@
if (IndirectGotoStmt *IGS = dyn_cast<IndirectGotoStmt>(Jump)) {
LabelDecl *Target = IGS->getConstantTarget();
CheckJump(IGS, Target->getStmt(), IGS->getGotoLoc(),
- diag::err_goto_into_protected_scope, 0);
+ diag::err_goto_into_protected_scope,
+ diag::warn_goto_into_protected_scope);
continue;
}
@@ -693,7 +694,7 @@
SmallVector<unsigned, 10> ToScopesError;
SmallVector<unsigned, 10> ToScopesWarning;
for (unsigned I = ToScope; I != CommonScope; I = Scopes[I].ParentScope) {
- if (S.getLangOptions().Microsoft &&
+ if (S.getLangOptions().Microsoft && JumpDiagWarning != 0 &&
IsMicrosoftJumpWarning(JumpDiagError, Scopes[I].InDiag))
ToScopesWarning.push_back(I);
else if (Scopes[I].InDiag)
Modified: cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp?rev=139971&r1=139970&r2=139971&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp (original)
+++ cfe/trunk/test/SemaCXX/MicrosoftExtensions.cpp Fri Sep 16 18:15:32 2011
@@ -258,14 +258,6 @@
}
-
-
-
-
-
-
-
-
namespace ms_protected_scope {
struct C { C(); };
@@ -305,6 +297,14 @@
} catch(int) {
}
}
+
+int jump_over_indirect_goto() {
+ static void *ps[] = { &&a0 };
+ goto *&&a0; // expected-warning {{goto into protected scope}}
+ int a = 3; // expected-note {{jump bypasses variable initialization}}
+ a0:
+ return 0;
+}
}
Modified: cfe/trunk/test/SemaCXX/scope-check.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/scope-check.cpp?rev=139971&r1=139970&r2=139971&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/scope-check.cpp (original)
+++ cfe/trunk/test/SemaCXX/scope-check.cpp Fri Sep 16 18:15:32 2011
@@ -191,4 +191,19 @@
break;
}
}
+
+
+namespace test10 {
+
+int test() {
+ static void *ps[] = { &&a0 };
+ goto *&&a0; // expected-error {{goto into protected scope}}
+ int a = 3; // expected-note {{jump bypasses variable initialization}}
+ a0:
+ return 0;
}
+
+}
+
+}
+
More information about the cfe-commits
mailing list