def warn_unused_label : Warning<"unused label %0">,
InGroup<UnusedLabel>, DefaultIgnore;
-def err_goto_into_protected_scope : Error<"goto into protected scope">;
-def ext_goto_into_protected_scope : ExtWarn<"goto into protected scope">,
+def err_goto_into_protected_scope : Error<
+ "cannot jump from this goto statement to its label">;
+def ext_goto_into_protected_scope : ExtWarn<
+ "jump from this goto statement to its label is a Microsoft extension">,
InGroup<Microsoft>;
def warn_cxx98_compat_goto_into_protected_scope : Warning<
- "goto would jump into protected scope in C++98">,
+ "jump from this goto statement to its label is incompatible with C++98">,
InGroup<CXX98Compat>, DefaultIgnore;
def err_switch_into_protected_scope : Error<
- "switch case is in protected scope">;
+ "cannot jump from switch statement to this case label">;
def warn_cxx98_compat_switch_into_protected_scope : Warning<
- "switch case would be in a protected scope in C++98">,
+ "jump from switch statement to this case label is incompatible with C++98">,
InGroup<CXX98Compat>, DefaultIgnore;
def err_indirect_goto_without_addrlabel : Error<
"indirect goto in function with no address-of-label expressions">;
def err_indirect_goto_in_protected_scope : Error<
- "indirect goto might cross protected scopes">;
+ "cannot jump from this indirect goto statement to one of its possible targets">;
def warn_cxx98_compat_indirect_goto_in_protected_scope : Warning<
- "indirect goto might cross protected scopes in C++98">,
- InGroup<CXX98Compat>, DefaultIgnore;
-def note_indirect_goto_target : Note<"possible target of indirect goto">;
+ "jump from this indirect goto statement to one of its possible targets "
+ "is incompatible with C++98">, InGroup<CXX98Compat>, DefaultIgnore;
+def note_indirect_goto_target : Note<
+ "possible target of indirect goto statement">;
def note_protected_by_variable_init : Note<
"jump bypasses variable initialization">;
def note_protected_by_variable_nontriv_destructor : Note<
;
id x; // expected-note {{jump bypasses initialization of retaining variable}}
- case 1: // expected-error {{switch case is in protected scope}}
+ case 1: // expected-error {{cannot jump}}
x = 0;
break;
}
void f() {
int n = 42;
- goto foo; // expected-error {{goto into protected scope}}
+ goto foo; // expected-error {{cannot jump}}
using T = int[n]; // expected-note {{bypasses initialization of VLA type alias}}
foo: ;
}
void test(int n) {
switch (n) {
try { // expected-note 2{{bypasses}}
- case 0: // expected-error {{protected}}
+ case 0: // expected-error {{cannot jump}}
x:
throw n;
} catch (...) { // expected-note 2{{bypasses}}
- case 1: // expected-error {{protected}}
+ case 1: // expected-error {{cannot jump}}
y:
throw n;
}
case 2:
- goto x; // expected-error {{protected}}
+ goto x; // expected-error {{cannot jump}}
case 3:
- goto y; // expected-error {{protected}}
+ goto y; // expected-error {{cannot jump}}
}
}
}
throw 0;
X: ;
} catch (int) {
- goto X; // expected-error {{protected scope}}
+ goto X; // expected-error {{cannot jump}}
}
};
}
return k;
}
int g() {
- goto later; // expected-error {{protected scope}}
+ goto later; // expected-error {{cannot jump}}
int k = stuff(); // expected-note {{bypasses variable initialization}}
later:
return k;
void jump() {
goto x;
#if __cplusplus < 201103L
- // expected-error@-2 {{protected scope}}
+ // expected-error@-2 {{cannot jump}}
// expected-note@+2 {{non-POD}}
#endif
trivial t;
void f();
void test_Y() {
- goto end; // expected-error{{goto into protected scope}}
+ goto end; // expected-error{{cannot jump from this goto statement to its label}}
Y y; // expected-note{{jump bypasses variable with a non-trivial destructor}}
end:
f();
- goto inner; // expected-error{{goto into protected scope}}
+ goto inner; // expected-error{{cannot jump from this goto statement to its label}}
{
Y y2; // expected-note{{jump bypasses variable with a non-trivial destructor}}
inner:
};
void test_Y() {
- goto end; // expected-error{{goto into protected scope}}
+ goto end; // expected-error{{cannot jump from this goto statement to its label}}
Y y; // expected-note{{jump bypasses variable with a non-trivial destructor}}
end:
return;
};
void test_Z() {
- goto end; // expected-error{{goto into protected scope}}
+ goto end; // expected-error{{cannot jump from this goto statement to its label}}
Z z; // expected-note{{jump bypasses initialization of non-POD variable}}
end:
return;
// rdar://7072507
int test19() {
- goto L0; // expected-error {{goto into protected scope}}
+ goto L0; // expected-error {{cannot jump}}
__block int x; // expected-note {{jump bypasses setup of __block variable}}
L0:
// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -std=gnu99 %s -Wno-unreachable-code
int test1(int x) {
- goto L; // expected-error{{goto into protected scope}}
+ goto L; // expected-error{{cannot jump from this goto statement to its label}}
int a[x]; // expected-note {{jump bypasses initialization of variable length array}}
int b[x]; // expected-note {{jump bypasses initialization of variable length array}}
L:
}
int test2(int x) {
- goto L; // expected-error{{goto into protected scope}}
+ goto L; // expected-error{{cannot jump from this goto statement to its label}}
typedef int a[x]; // expected-note {{jump bypasses initialization of VLA typedef}}
L:
return sizeof(a);
void test3clean(int*);
int test3() {
- goto L; // expected-error{{goto into protected scope}}
+ goto L; // expected-error{{cannot jump from this goto statement to its label}}
int a __attribute((cleanup(test3clean))); // expected-note {{jump bypasses initialization of variable with __attribute__((cleanup))}}
L:
return a;
}
int test4(int x) {
- goto L; // expected-error{{goto into protected scope}}
+ goto L; // expected-error{{cannot jump from this goto statement to its label}}
int a[x]; // expected-note {{jump bypasses initialization of variable length array}}
test4(x);
L:
switch (x) {
case 1: ;
int a[x]; // expected-note {{jump bypasses initialization of variable length array}}
- case 2: // expected-error {{switch case is in protected scope}}
+ case 2: // expected-error {{cannot jump from switch statement to this case label}}
a[1] = 2;
break;
}
int test8(int x) {
// For statement.
- goto L2; // expected-error {{goto into protected scope}}
+ goto L2; // expected-error {{cannot jump from this goto statement to its label}}
for (int arr[x]; // expected-note {{jump bypasses initialization of variable length array}}
; ++x)
L2:;
// Statement expressions.
- goto L3; // expected-error {{goto into protected scope}}
+ goto L3; // expected-error {{cannot jump from this goto statement to its label}}
int Y = ({ int a[x]; // expected-note {{jump bypasses initialization of variable length array}}
L3: 4; });
- goto L4; // expected-error {{goto into protected scope}}
+ goto L4; // expected-error {{cannot jump from this goto statement to its label}}
{
int A[x], // expected-note {{jump bypasses initialization of variable length array}}
B[x]; // expected-note {{jump bypasses initialization of variable length array}}
int A[x], B = ({ if (x)
goto L7;
else
- goto L8; // expected-error {{goto into protected scope}}
+ goto L8; // expected-error {{cannot jump from this goto statement to its label}}
4; }),
C[x]; // expected-note {{jump bypasses initialization of variable length array}}
L8:; // bad
goto L9;
else
// FIXME:
- goto L10; // fixme-error {{goto into protected scope}}
+ goto L10; // fixme-error {{cannot jump from this goto statement to its label}}
4; })];
L10:; // bad
}
}
// Statement expressions 2.
- goto L1; // expected-error {{goto into protected scope}}
+ goto L1; // expected-error {{cannot jump from this goto statement to its label}}
return x == ({
int a[x]; // expected-note {{jump bypasses initialization of variable length array}}
L1:
void test9(int n, void *P) {
int Y;
int Z = 4;
- goto *P; // expected-error {{indirect goto might cross protected scopes}}
+ goto *P; // expected-error {{cannot jump from this indirect goto statement to one of its possible targets}}
L2: ;
int a[n]; // expected-note {{jump bypasses initialization of variable length array}}
}
void test10(int n, void *P) {
- goto L0; // expected-error {{goto into protected scope}}
+ goto L0; // expected-error {{cannot jump from this goto statement to its label}}
typedef int A[n]; // expected-note {{jump bypasses initialization of VLA typedef}}
L0:
- goto L1; // expected-error {{goto into protected scope}}
+ goto L1; // expected-error {{cannot jump from this goto statement to its label}}
A b, c[10]; // expected-note 2 {{jump bypasses initialization of variable length array}}
L1:
- goto L2; // expected-error {{goto into protected scope}}
+ goto L2; // expected-error {{cannot jump from this goto statement to its label}}
A d[n]; // expected-note {{jump bypasses initialization of variable length array}}
L2:
return;
case 2:
case 3:;
int Arr[n]; // expected-note {{jump bypasses initialization of variable length array}}
- case 4: // expected-error {{switch case is in protected scope}}
+ case 4: // expected-error {{cannot jump from switch statement to this case label}}
return;
}
};
L1:
goto L2;
L2:
- goto L3; // expected-error {{goto into protected scope}}
+ goto L3; // expected-error {{cannot jump from this goto statement to its label}}
int Arr[n]; // expected-note {{jump bypasses initialization of variable length array}}
L3:
goto L4;
void test15(int n, void *pc) {
static const void *addrs[] = { &&L1, &&L2 };
- goto *pc; // expected-error {{indirect goto might cross protected scope}}
+ goto *pc; // expected-error {{cannot jump from this indirect goto statement to one of its possible targets}}
L1:
{
int jump_over_variable_init(bool b) {
if (b)
- goto foo; // expected-warning {{goto into protected scope}}
+ goto foo; // expected-warning {{jump from this goto statement to its label is a Microsoft extension}}
C c; // expected-note {{jump bypasses variable initialization}}
foo:
return 1;
};
void jump_over_var_with_dtor() {
- goto end; // expected-warning{{goto into protected scope}}
+ goto end; // expected-warning{{jump from this goto statement to its label is a Microsoft extension}}
Y y; // expected-note {{jump bypasses variable with a non-trivial destructor}}
end:
;
switch (c) {
case 0:
int x = 56; // expected-note {{jump bypasses variable initialization}}
- case 1: // expected-error {{switch case is in protected scope}}
+ case 1: // expected-error {{cannot jump}}
x = 10;
}
}
void exception_jump() {
- goto l2; // expected-error {{goto into protected scope}}
+ goto l2; // expected-error {{cannot jump}}
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}}
+ goto *&&a0; // expected-warning {{jump from this goto statement to its label is a Microsoft extension}}
int a = 3; // expected-note {{jump bypasses variable initialization}}
a0:
return 0;
template void EnumNNSFn<Enum>(); // expected-note {{in instantiation}}
void JumpDiagnostics(int n) {
- goto DirectJump; // expected-warning {{goto would jump into protected scope in C++98}}
+ goto DirectJump; // expected-warning {{jump from this goto statement to its label is incompatible with C++98}}
TrivialButNonPOD tnp1; // expected-note {{jump bypasses initialization of non-POD variable}}
DirectJump:
void *Table[] = {&&DirectJump, &&Later};
- goto *Table[n]; // expected-warning {{indirect goto might cross protected scopes in C++98}}
+ goto *Table[n]; // expected-warning {{jump from this indirect goto statement to one of its possible targets is incompatible with C++98}}
TrivialButNonPOD tnp2; // expected-note {{jump bypasses initialization of non-POD variable}}
-Later: // expected-note {{possible target of indirect goto}}
+Later: // expected-note {{possible target of indirect goto statement}}
switch (n) {
TrivialButNonPOD tnp3; // expected-note {{jump bypasses initialization of non-POD variable}}
- default: // expected-warning {{switch case would be in a protected scope in C++98}}
+ default: // expected-warning {{jump from switch statement to this case label is incompatible with C++98}}
return;
}
}
void jumps() {
l1:
goto l5;
- goto l4; // expected-error {{goto into protected scope}}
- goto l3; // expected-error {{goto into protected scope}}
- goto l2; // expected-error {{goto into protected scope}}
+ goto l4; // expected-error {{cannot jump}}
+ goto l3; // expected-error {{cannot jump}}
+ goto l2; // expected-error {{cannot jump}}
goto l1;
try { // expected-note 4 {{jump bypasses initialization of try block}}
l2:
goto l5;
- goto l4; // expected-error {{goto into protected scope}}
- goto l3; // expected-error {{goto into protected scope}}
+ goto l4; // expected-error {{cannot jump}}
+ goto l3; // expected-error {{cannot jump}}
goto l2;
goto l1;
} catch(int) { // expected-note 4 {{jump bypasses initialization of catch block}}
l3:
goto l5;
- goto l4; // expected-error {{goto into protected scope}}
+ goto l4; // expected-error {{cannot jump}}
goto l3;
- goto l2; // expected-error {{goto into protected scope}}
+ goto l2; // expected-error {{cannot jump}}
goto l1;
} catch(...) { // expected-note 4 {{jump bypasses initialization of catch block}}
l4:
goto l5;
goto l4;
- goto l3; // expected-error {{goto into protected scope}}
- goto l2; // expected-error {{goto into protected scope}}
+ goto l3; // expected-error {{cannot jump}}
+ goto l2; // expected-error {{cannot jump}}
goto l1;
}
l5:
goto l5;
- goto l4; // expected-error {{goto into protected scope}}
- goto l3; // expected-error {{goto into protected scope}}
- goto l2; // expected-error {{goto into protected scope}}
+ goto l4; // expected-error {{cannot jump}}
+ goto l3; // expected-error {{cannot jump}}
+ goto l2; // expected-error {{cannot jump}}
goto l1;
}
~S() {}
};
void g(const S& s) {
- goto done; // expected-error {{goto into protected scope}}
+ goto done; // expected-error {{cannot jump}}
const S s2(s); // expected-note {{jump bypasses variable initialization}}
done:
;
namespace test12 {
struct A { A(); A(const A&); ~A(); };
void test(A a) { // expected-note {{jump enters lifetime of block}} FIXME: weird location
- goto lbl; // expected-error {{goto into protected scope}}
+ goto lbl; // expected-error {{cannot jump}}
(void) ^{ (void) a; };
lbl:
return;
int f(bool b) {
if (b)
- goto foo; // expected-error {{goto into protected scope}}
+ goto foo; // expected-error {{cannot jump}}
C c; // expected-note {{jump bypasses variable initialization}}
foo:
return 1;
C c0;
- goto *ip; // expected-error {{indirect goto might cross protected scopes}}
+ goto *ip; // expected-error {{cannot jump}}
C c1; // expected-note {{jump bypasses variable initialization}}
lbl1: // expected-note {{possible target of indirect goto}}
return 0;
if (ip[1]) {
D d; // expected-note {{jump exits scope of variable with non-trivial destructor}}
ip += 2;
- goto *ip; // expected-error {{indirect goto might cross protected scopes}}
+ goto *ip; // expected-error {{cannot jump}}
}
return 1;
}
switch (c) {
case 0:
int x = 56; // expected-note {{jump bypasses variable initialization}}
- case 1: // expected-error {{switch case is in protected scope}}
+ case 1: // expected-error {{cannot jump}}
x = 10;
}
}
void test2() {
- goto l2; // expected-error {{goto into protected scope}}
+ goto l2; // expected-error {{cannot jump}}
l1: int x = 5; // expected-note {{jump bypasses variable initialization}}
l2: x++;
}
namespace test10 {
int test() {
static void *ps[] = { &&a0 };
- goto *&&a0; // expected-error {{goto into protected scope}}
+ goto *&&a0; // expected-error {{cannot jump}}
int a = 3; // expected-note {{jump bypasses variable initialization}}
a0:
return 0;
static void *ips[] = { &&l0 };
l0: // expected-note {{possible target of indirect goto}}
C c0 = 42; // expected-note {{jump exits scope of variable with non-trivial destructor}}
- goto *ip; // expected-error {{indirect goto might cross protected scopes}}
+ goto *ip; // expected-error {{cannot jump}}
}
}
l0: // expected-note {{possible target of indirect goto}}
const C &c1 = 42; // expected-note {{jump exits scope of lifetime-extended temporary with non-trivial destructor}}
const C &c2 = c0;
- goto *ip; // expected-error {{indirect goto might cross protected scopes}}
+ goto *ip; // expected-error {{cannot jump}}
}
}
static void *ips[] = { &&l0 };
l0: // expected-note {{possible target of indirect goto}}
const int &c1 = C(1).i; // expected-note {{jump exits scope of lifetime-extended temporary with non-trivial destructor}}
- goto *ip; // expected-error {{indirect goto might cross protected scopes}}
+ goto *ip; // expected-error {{cannot jump}}
}
}
// PR14225
namespace test15 {
void f1() try {
- goto x; // expected-error {{goto into protected scope}}
+ goto x; // expected-error {{cannot jump}}
} catch(...) { // expected-note {{jump bypasses initialization of catch block}}
x: ;
}
void f2() try { // expected-note {{jump bypasses initialization of try block}}
x: ;
} catch(...) {
- goto x; // expected-error {{goto into protected scope}}
+ goto x; // expected-error {{cannot jump}}
}
}
namespace test16 {
struct S { int n; };
int f() {
- goto x; // expected-error {{goto into protected scope}}
+ goto x; // expected-error {{cannot jump}}
const S &s = S(); // expected-note {{jump bypasses variable initialization}}
x: return s.n;
}
namespace test17 {
struct S { int get(); private: int n; };
int f() {
- goto x; // expected-error {{goto into protected scope}}
+ goto x; // expected-error {{cannot jump}}
S s = {}; // expected-note {{jump bypasses variable initialization}}
x: return s.get();
}
void *p = &&x;
x: // expected-note {{possible target of indirect goto}}
B b = { 0, A() }; // expected-note {{jump exits scope of lifetime-extended temporary with non-trivial destructor}}
- goto *p; // expected-error {{indirect goto might cross protected scopes}}
+ goto *p; // expected-error {{cannot jump}}
}
}
A a;
x: // expected-note {{possible target of indirect goto}}
std::initializer_list<A> il = { a }; // expected-note {{jump exits scope of lifetime-extended temporary with non-trivial destructor}}
- goto *p; // expected-error {{indirect goto might cross protected scopes}}
+ goto *p; // expected-error {{cannot jump}}
}
}
a,
{ A() } // expected-note {{jump exits scope of lifetime-extended temporary with non-trivial destructor}}
};
- goto *p; // expected-error {{indirect goto might cross protected scopes}}
+ goto *p; // expected-error {{cannot jump}}
}
}
#endif
namespace test21 {
template<typename T> void f() {
- goto x; // expected-error {{protected scope}}
+ goto x; // expected-error {{cannot jump}}
T t; // expected-note {{bypasses}}
x: return;
}
void test(nexist, int c) { // expected-error {{}}
nexist_fn(); // expected-error {{}}
goto nexist_label; // expected-error {{use of undeclared label}}
- goto a0; // expected-error {{goto into protected scope}}
+ goto a0; // expected-error {{cannot jump}}
int a = 0; // expected-note {{jump bypasses variable initialization}}
a0:;
case $: // expected-error {{}}
case 0:
int x = 56; // expected-note {{jump bypasses variable initialization}}
- case 1: // expected-error {{switch case is in protected scope}}
+ case 1: // expected-error {{cannot jump}}
x = 10;
}
}
};
void test2() {
- goto later; // expected-error {{goto into protected scope}}
+ goto later; // expected-error {{cannot jump}}
X x; // expected-note {{jump bypasses variable initialization}}
later:
;
case 0:
dispatch_async((&_dispatch_main_q), ^{ [self pageLeft]; }); // expected-note 3 {{jump enters lifetime of block which strongly captures a variable}}
break;
- case 2: // expected-error {{switch case is in protected scope}}
+ case 2: // expected-error {{cannot jump}}
dispatch_async((&_dispatch_main_q), ^{ [self pageRight]; }); // expected-note 2 {{jump enters lifetime of block which strongly captures a variable}}
break;
- case 3: // expected-error {{switch case is in protected scope}}
+ case 3: // expected-error {{cannot jump}}
{
dispatch_async((&_dispatch_main_q), ^{ [self pageRight]; });
break;
}
- case 4: // expected-error {{switch case is in protected scope}}
+ case 4: // expected-error {{cannot jump}}
break;
}
(void) ^{ (void) obj; };
return 0;
- default: // expected-error {{switch case is in protected scope}}
+ default: // expected-error {{cannot jump}}
return 1;
}
}
;
id x; // expected-note {{jump bypasses initialization of retaining variable}}
- case 1: // expected-error {{switch case is in protected scope}}
+ case 1: // expected-error {{cannot jump}}
break;
}
}
@implementation AUTORP
- (void) unregisterTask:(id) task {
- goto L; // expected-error {{goto into protected scope}}
+ goto L; // expected-error {{cannot jump}}
@autoreleasepool { // expected-note {{jump bypasses auto release push of @autoreleasepool block}}
void *tmp = objc_autoreleasepool_push();
@class A, B, C;
void test1() {
- goto L; // expected-error{{goto into protected scope}}
- goto L2; // expected-error{{goto into protected scope}}
- goto L3; // expected-error{{goto into protected scope}}
+ goto L; // expected-error{{cannot jump}}
+ goto L2; // expected-error{{cannot jump}}
+ goto L3; // expected-error{{cannot jump}}
@try { // expected-note {{jump bypasses initialization of @try block}}
L: ;
} @catch (A *x) { // expected-note {{jump bypasses initialization of @catch block}}
}
@try {
- goto L4; // expected-error{{goto into protected scope}}
- goto L5; // expected-error{{goto into protected scope}}
+ goto L4; // expected-error{{cannot jump}}
+ goto L5; // expected-error{{cannot jump}}
} @catch (C *c) { // expected-note {{jump bypasses initialization of @catch block}}
L5: ;
- goto L6; // expected-error{{goto into protected scope}}
+ goto L6; // expected-error{{cannot jump}}
} @catch (B *c) { // expected-note {{jump bypasses initialization of @catch block}}
L6: ;
} @finally { // expected-note {{jump bypasses initialization of @finally block}}
@try { // expected-note 2 {{jump bypasses initialization of @try block}}
L7: ;
} @catch (C *c) {
- goto L7; // expected-error{{goto into protected scope}}
+ goto L7; // expected-error{{cannot jump}}
} @finally {
- goto L7; // expected-error{{goto into protected scope}}
+ goto L7; // expected-error{{cannot jump}}
}
- goto L8; // expected-error{{goto into protected scope}}
+ goto L8; // expected-error{{cannot jump}}
@try {
} @catch (A *c) {
} @catch (B *c) {
// rdar://6810106
id X;
- goto L9; // expected-error{{goto into protected scope}}
+ goto L9; // expected-error{{cannot jump}}
goto L10; // ok
@synchronized // expected-note {{jump bypasses initialization of @synchronized block}}
( ({ L10: ; X; })) {
+ (void) hello {
@try {
- goto blargh; // expected-error {{goto into protected scope}}
+ goto blargh; // expected-error {{cannot jump}}
} @catch (...) { // expected-note {{jump bypasses initialization of @catch block}}
blargh: ;
}
+ (void)meth2 {
int n; void *P;
- goto L0; // expected-error {{goto into protected scope}}
+ goto L0; // expected-error {{cannot jump}}
typedef int A[n]; // expected-note {{jump bypasses initialization of VLA typedef}}
L0:
- goto L1; // expected-error {{goto into protected scope}}
+ goto L1; // expected-error {{cannot jump}}
A b, c[10]; // expected-note 2 {{jump bypasses initialization of variable length array}}
L1:
- goto L2; // expected-error {{goto into protected scope}}
+ goto L2; // expected-error {{cannot jump}}
A d[n]; // expected-note {{jump bypasses initialization of variable length array}}
L2:
return;