summaryrefslogtreecommitdiff
path: root/clang/test/SemaObjC/labeled-break-continue.m
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/SemaObjC/labeled-break-continue.m')
-rw-r--r--clang/test/SemaObjC/labeled-break-continue.m39
1 files changed, 39 insertions, 0 deletions
diff --git a/clang/test/SemaObjC/labeled-break-continue.m b/clang/test/SemaObjC/labeled-break-continue.m
new file mode 100644
index 000000000000..2791474a579b
--- /dev/null
+++ b/clang/test/SemaObjC/labeled-break-continue.m
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -std=c2y -fsyntax-only -verify -fblocks %s
+
+void f1(id y) {
+ l1: for (id x in y) {
+ break l1;
+ continue l1;
+ }
+
+ l2: for (id x in y) {
+ break l1; // expected-error {{'break' label does not name an enclosing loop or 'switch'}}
+ continue l1; // expected-error {{'continue' label does not name an enclosing loop}}
+ }
+
+ l3: for (id x in y) {
+ l4: for (id x in y) {
+ break l3;
+ break l4;
+ continue l3;
+ continue l4;
+ }
+ }
+}
+
+void f2(id y) {
+ l1: for (id x in ({
+ break l1; // expected-error {{'break' label does not name an enclosing loop or 'switch'}}
+ continue l1; // expected-error {{'continue' label does not name an enclosing loop}}
+ y;
+ })) {}
+}
+
+void f3(id y) {
+ a: b: for (id x in y) {
+ (void) ^{
+ break a; // expected-error {{'break' label does not name an enclosing loop or 'switch'}}
+ continue b; // expected-error {{'continue' label does not name an enclosing loop}}
+ };
+ }
+}