summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX/scope-check.cpp
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2012-12-02 13:20:44 +0000
committerdim <dim@FreeBSD.org>2012-12-02 13:20:44 +0000
commit056abd2059c65a3e908193aeae16fad98017437c (patch)
tree2732d02d7d51218d6eed98ac7fcfc5b8794896b5 /test/SemaCXX/scope-check.cpp
parentcc73504950eb7b5dff2dded9bedd67bc36d64641 (diff)
downloadFreeBSD-src-056abd2059c65a3e908193aeae16fad98017437c.zip
FreeBSD-src-056abd2059c65a3e908193aeae16fad98017437c.tar.gz
Vendor import of clang release_32 branch r168974 (effectively, 3.2 RC2):
http://llvm.org/svn/llvm-project/cfe/branches/release_32@168974
Diffstat (limited to 'test/SemaCXX/scope-check.cpp')
-rw-r--r--test/SemaCXX/scope-check.cpp103
1 files changed, 85 insertions, 18 deletions
diff --git a/test/SemaCXX/scope-check.cpp b/test/SemaCXX/scope-check.cpp
index b659de0..8fd23f4 100644
--- a/test/SemaCXX/scope-check.cpp
+++ b/test/SemaCXX/scope-check.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s -Wno-unreachable-code
-// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -std=gnu++11 %s -Wno-unreachable-code
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -fcxx-exceptions %s -Wno-unreachable-code
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -fcxx-exceptions -std=gnu++11 %s -Wno-unreachable-code
namespace test0 {
struct D { ~D(); };
@@ -174,14 +174,14 @@ namespace test9 {
// http://llvm.org/PR10462
namespace PR10462 {
-enum MyEnum {
- something_valid,
- something_invalid
-};
-
-bool recurse() {
- MyEnum K;
- switch (K) { // expected-warning {{enumeration value 'something_invalid' not handled in switch}}
+ enum MyEnum {
+ something_valid,
+ something_invalid
+ };
+
+ bool recurse() {
+ MyEnum K;
+ switch (K) { // expected-warning {{enumeration value 'something_invalid' not handled in switch}}
case something_valid:
case what_am_i_thinking: // expected-error {{use of undeclared identifier}}
int *X = 0;
@@ -189,21 +189,88 @@ bool recurse() {
}
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;
+ 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;
+ }
+}
+
+// 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;
+ }
}
+// PR14225
+namespace test15 {
+ void f1() try {
+ goto x; // expected-error {{goto into protected scope}}
+ } 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}}
+ }
+}
OpenPOWER on IntegriCloud