]> granicus.if.org Git - clang/commitdiff
Move the "jump bypasses variable initialization" error -> warning downgrade from...
authorFrancois Pichet <pichet2000@gmail.com>
Sun, 18 Sep 2011 21:48:27 +0000 (21:48 +0000)
committerFrancois Pichet <pichet2000@gmail.com>
Sun, 18 Sep 2011 21:48:27 +0000 (21:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140008 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/JumpDiagnostics.cpp
test/SemaCXX/MicrosoftCompatibility.cpp
test/SemaCXX/MicrosoftExtensions.cpp

index 40e8bcb247db56d69ac4e949c8aa7a0070158aad..3e74dfccbdb128ddaadfd765a441c2e9001f030d 100644 (file)
@@ -694,7 +694,7 @@ void JumpScopeChecker::CheckJump(Stmt *From, Stmt *To, SourceLocation DiagLoc,
   SmallVector<unsigned, 10> ToScopesError;
   SmallVector<unsigned, 10> ToScopesWarning;
   for (unsigned I = ToScope; I != CommonScope; I = Scopes[I].ParentScope) {
-    if (S.getLangOptions().MicrosoftExt && JumpDiagWarning != 0 &&
+    if (S.getLangOptions().MicrosoftMode && JumpDiagWarning != 0 &&
         IsMicrosoftJumpWarning(JumpDiagError, Scopes[I].InDiag))
       ToScopesWarning.push_back(I);
     else if (Scopes[I].InDiag)
index fa4ed3ebefff34277ec618c74f3eafde33e27ec3..98a7532f0c5579d217b3a376d7000b1a4e8f8897 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -verify -fms-compatibility
+// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions
 
 
 
@@ -16,3 +16,57 @@ void test()
 
 }
 
+
+
+namespace ms_protected_scope {
+  struct C { C(); };
+
+  int jump_over_variable_init(bool b) {
+    if (b)
+      goto foo; // expected-warning {{illegal goto into protected scope}}
+    C c; // expected-note {{jump bypasses variable initialization}}
+  foo:
+    return 1;
+  }
+
+struct Y {
+  ~Y();
+};
+
+void jump_over_var_with_dtor() {
+  goto end; // expected-warning{{goto into protected scope}}
+  Y y; // expected-note {{jump bypasses variable initialization}}
+ end:
+    ;
+}
+
+  void jump_over_variable_case(int c) {
+    switch (c) {
+    case 0:
+      int x = 56; // expected-note {{jump bypasses variable initialization}}
+    case 1:       // expected-error {{switch case is in protected scope}}
+      x = 10;
+    }
+  }
+
+void exception_jump() {
+  goto l2; // expected-error {{illegal goto into protected scope}}
+  try { // expected-note {{jump bypasses initialization of try block}}
+     l2: ;
+  } 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;
+}
+  
+}
+
+
+
index 396ee13f66a9e6cd1b4e9837094f6a47720e40ef..e5e5752dba85750ffe68f41c030a395caa6e61e6 100644 (file)
@@ -257,56 +257,3 @@ void f()
 
 }
 
-
-namespace ms_protected_scope {
-  struct C { C(); };
-
-  int jump_over_variable_init(bool b) {
-    if (b)
-      goto foo; // expected-warning {{illegal goto into protected scope}}
-    C c; // expected-note {{jump bypasses variable initialization}}
-  foo:
-    return 1;
-  }
-
-struct Y {
-  ~Y();
-};
-
-void jump_over_var_with_dtor() {
-  goto end; // expected-warning{{goto into protected scope}}
-  Y y; // expected-note {{jump bypasses variable initialization}}
- end:
-    ;
-}
-
-  void jump_over_variable_case(int c) {
-    switch (c) {
-    case 0:
-      int x = 56; // expected-note {{jump bypasses variable initialization}}
-    case 1:       // expected-error {{switch case is in protected scope}}
-      x = 10;
-    }
-  }
-
-void exception_jump() {
-  goto l2; // expected-error {{illegal goto into protected scope}}
-  try { // expected-note {{jump bypasses initialization of try block}}
-     l2: ;
-  } 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;
-}
-  
-}
-
-
-