aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Sema/scope-check.c32
-rw-r--r--test/SemaCXX/scope-check.cpp4
2 files changed, 33 insertions, 3 deletions
diff --git a/test/Sema/scope-check.c b/test/Sema/scope-check.c
index 4ccb64c9aa..1a2fc2b360 100644
--- a/test/Sema/scope-check.c
+++ b/test/Sema/scope-check.c
@@ -133,7 +133,7 @@ int test8(int x) {
void test9(int n, void *P) {
int Y;
int Z = 4;
- goto *P; // expected-warning {{indirect goto might cross protected scopes}}
+ goto *P; // expected-error {{indirect goto might cross protected scopes}}
L2: ;
int a[n]; // expected-note {{jump bypasses initialization of variable length array}}
@@ -199,3 +199,33 @@ void test13(int n, void *p) {
a0: ;
static void *ps[] = { &&a0 };
}
+
+int test14(int n) {
+ static void *ps[] = { &&a0, &&a1 };
+ if (n < 0)
+ goto *&&a0;
+
+ if (n > 0) {
+ int vla[n];
+ a1:
+ vla[n-1] = 0;
+ }
+ a0:
+ return 0;
+}
+
+
+// PR8473: IR gen can't deal with indirect gotos past VLA
+// initialization, so that really needs to be a hard error.
+void test15(int n, void *pc) {
+ static const void *addrs[] = { &&L1, &&L2 };
+
+ goto *pc; // expected-error {{indirect goto might cross protected scope}}
+
+ L1:
+ {
+ char vla[n]; // expected-note {{jump bypasses initialization}}
+ L2: // expected-note {{possible target}}
+ vla[0] = 'a';
+ }
+}
diff --git a/test/SemaCXX/scope-check.cpp b/test/SemaCXX/scope-check.cpp
index cdc3868a7b..d462af06d7 100644
--- a/test/SemaCXX/scope-check.cpp
+++ b/test/SemaCXX/scope-check.cpp
@@ -66,7 +66,7 @@ namespace test4 {
C c0;
- goto *ip; // expected-warning {{indirect goto might cross protected scopes}}
+ goto *ip; // expected-error {{indirect goto might cross protected scopes}}
C c1; // expected-note {{jump bypasses variable initialization}}
lbl1: // expected-note {{possible target of indirect goto}}
return 0;
@@ -90,7 +90,7 @@ namespace test5 {
if (ip[1]) {
D d; // expected-note {{jump exits scope of variable with non-trivial destructor}}
ip += 2;
- goto *ip; // expected-warning {{indirect goto might cross protected scopes}}
+ goto *ip; // expected-error {{indirect goto might cross protected scopes}}
}
return 1;
}