summaryrefslogtreecommitdiff
path: root/test/SemaObjC
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@apple.com>2017-04-19 17:54:08 +0000
committerAkira Hatanaka <ahatanaka@apple.com>2017-04-19 17:54:08 +0000
commit17081268e25326cb2afd21f56e5d12ac445a832c (patch)
tree483135aeebcd8d1edba55790ade1e2cec9d55abf /test/SemaObjC
parentbfb79c8fec5e58a34d73d75ec302ea3e8cae1750 (diff)
[Sema][ObjC] Disallow jumping into ObjC fast enumeration loops.
rdar://problem/31635406 Differential Revision: https://reviews.llvm.org/D32187 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300722 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaObjC')
-rw-r--r--test/SemaObjC/foreach.m24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/SemaObjC/foreach.m b/test/SemaObjC/foreach.m
index 91ea2ec4e0..477c4fc383 100644
--- a/test/SemaObjC/foreach.m
+++ b/test/SemaObjC/foreach.m
@@ -55,3 +55,27 @@ void test2(NSObject<NSFastEnumeration> *collection) {
for (obj.prop in collection) { /* expected-error {{selector element is not a valid lvalue}} */
}
}
+
+int cond();
+
+void test3(NSObject<NSFastEnumeration> *a0, NSObject<NSFastEnumeration> *a1) {
+ for (id i in a0) { /* expected-note 2 {{jump enters Objective-C fast enumeration loop}} */
+ for (id j in a1) { /* expected-note 2 {{jump enters Objective-C fast enumeration loop}} */
+ (void)i, (void)j;
+label0:
+ if (cond())
+ goto label1;
+ }
+label1:
+ if (cond())
+ goto label0; /* expected-error {{cannot jump from this goto statement to its label}} */
+ if (cond())
+ goto label2;
+ }
+
+label2:
+ if (cond())
+ goto label0; /* expected-error {{cannot jump from this goto statement to its label}} */
+ if (cond())
+ goto label1; /* expected-error{{cannot jump from this goto statement to its label}} */
+}