diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/SemaCXX/scope-check.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/test/SemaCXX/scope-check.cpp b/test/SemaCXX/scope-check.cpp index 86d1bd8960..78228c0dc5 100644 --- a/test/SemaCXX/scope-check.cpp +++ b/test/SemaCXX/scope-check.cpp @@ -202,3 +202,61 @@ namespace test10 { return 0; } } + +// pr13812 +namespace test11 { + struct C { + C(int x); + ~C(); + }; + void f(void **ip) { + 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}} + } +} + +namespace test12 { + struct C { + C(int x); + ~C(); + }; + void f(void **ip) { + static void *ips[] = { &&l0 }; + const C c0 = 17; + l0: // expected-note {{possible target of indirect goto}} + const C &c1 = 42; // expected-note {{jump exits scope of variable with non-trivial destructor}} + const C &c2 = c0; + goto *ip; // expected-error {{indirect goto might cross protected scopes}} + } +} + +namespace test13 { + struct C { + C(int x); + ~C(); + int i; + }; + void f(void **ip) { + static void *ips[] = { &&l0 }; + l0: // expected-note {{possible target of indirect goto}} + const int &c1 = C(1).i; // expected-note {{jump exits scope of variable with non-trivial destructor}} + goto *ip; // expected-error {{indirect goto might cross protected scopes}} + } +} + +namespace test14 { + struct C { + C(int x); + ~C(); + operator int&() const; + }; + void f(void **ip) { + static void *ips[] = { &&l0 }; + l0: + // no warning since the C temporary is destructed before the goto. + const int &c1 = C(1); + goto *ip; + } +} |