summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2014-07-25 19:45:01 +0000
committerFariborz Jahanian <fjahanian@apple.com>2014-07-25 19:45:01 +0000
commita57d91c2aede9cb8c5e43ab86cfaebe4e43f0161 (patch)
tree8e3c6ec2d1f652c077adfccb29dd52b7f481465c /clang/test
parente5b6e0d2313cdd5b906bfeaf3968ff7fdd6438db (diff)
downloadbcm5719-llvm-a57d91c2aede9cb8c5e43ab86cfaebe4e43f0161.tar.gz
bcm5719-llvm-a57d91c2aede9cb8c5e43ab86cfaebe4e43f0161.zip
Objective-C. Warn if protocol used in an @protocol
expression is a forward declaration as this results in undefined behavior. rdar://17768630 llvm-svn: 213968
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/SemaObjC/protocol-expr-1.m2
-rw-r--r--clang/test/SemaObjC/protocol-expr-neg-1.m19
2 files changed, 18 insertions, 3 deletions
diff --git a/clang/test/SemaObjC/protocol-expr-1.m b/clang/test/SemaObjC/protocol-expr-1.m
index 94a0d9e3e8b..5ff3db474c7 100644
--- a/clang/test/SemaObjC/protocol-expr-1.m
+++ b/clang/test/SemaObjC/protocol-expr-1.m
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// expected-no-diagnostics
-@protocol fproto;
+@protocol fproto @end
@protocol p1
@end
diff --git a/clang/test/SemaObjC/protocol-expr-neg-1.m b/clang/test/SemaObjC/protocol-expr-neg-1.m
index 58ac8c0ca32..aed56c016b0 100644
--- a/clang/test/SemaObjC/protocol-expr-neg-1.m
+++ b/clang/test/SemaObjC/protocol-expr-neg-1.m
@@ -2,7 +2,7 @@
@class Protocol;
-@protocol fproto;
+@protocol fproto; // expected-note {{'fproto' declared here}}
@protocol p1
@end
@@ -12,8 +12,23 @@
int main()
{
Protocol *proto = @protocol(p1);
- Protocol *fproto = @protocol(fproto);
+ Protocol *fproto = @protocol(fproto); // expected-warning {{@protocol is using a forward protocol declaration of fproto}}
Protocol *pp = @protocol(i); // expected-error {{cannot find protocol declaration for 'i'}}
Protocol *p1p = @protocol(cl); // expected-error {{cannot find protocol declaration for 'cl'}}
}
+// rdar://17768630
+@protocol SuperProtocol; // expected-note {{'SuperProtocol' declared here}}
+@protocol TestProtocol; // expected-note {{'TestProtocol' declared here}}
+
+@interface I
+- (int) conformsToProtocol : (Protocol *)protocl;
+@end
+
+int doesConform(id foo) {
+ return [foo conformsToProtocol:@protocol(TestProtocol)]; // expected-warning {{@protocol is using a forward protocol declaration of TestProtocol}}
+}
+
+int doesConformSuper(id foo) {
+ return [foo conformsToProtocol:@protocol(SuperProtocol)]; // expected-warning {{@protocol is using a forward protocol declaration of SuperProtocol}}
+}
OpenPOWER on IntegriCloud