summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2011-04-08 18:25:29 +0000
committerFariborz Jahanian <fjahanian@apple.com>2011-04-08 18:25:29 +0000
commitb7bc34a83aff8af09f2a78aa6d1dcafe18ad8619 (patch)
tree8de806a3d2fc84723c0f79e7f669b5ddb3004c2a /test
parentf44a1a04a36453527de2285c402fbe9453184121 (diff)
downloadclang-b7bc34a83aff8af09f2a78aa6d1dcafe18ad8619.tar.gz
clang-b7bc34a83aff8af09f2a78aa6d1dcafe18ad8619.tar.bz2
clang-b7bc34a83aff8af09f2a78aa6d1dcafe18ad8619.tar.xz
Warn for any kind of initialization if initializer does not
implement lhs's protocols. // rdar://9091389. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129142 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/CodeGenObjCXX/references.mm2
-rw-r--r--test/SemaObjC/comptypes-4.m2
-rw-r--r--test/SemaObjC/unqualified-to-qualified-class-warn.m31
-rw-r--r--test/SemaObjCXX/references.mm2
4 files changed, 34 insertions, 3 deletions
diff --git a/test/CodeGenObjCXX/references.mm b/test/CodeGenObjCXX/references.mm
index 8875fd6240..6265c7be76 100644
--- a/test/CodeGenObjCXX/references.mm
+++ b/test/CodeGenObjCXX/references.mm
@@ -30,7 +30,7 @@ void f(B* b) {
@protocol P2 @end
@protocol P3 @end
@interface foo<P1> {} @end
-@interface bar : foo <P1, P2> {} @end
+@interface bar : foo <P1, P2, P3> {} @end
typedef bar baz;
void f5(foo&);
void f5b(foo<P1>&);
diff --git a/test/SemaObjC/comptypes-4.m b/test/SemaObjC/comptypes-4.m
index 56b23b2245..adc324c91e 100644
--- a/test/SemaObjC/comptypes-4.m
+++ b/test/SemaObjC/comptypes-4.m
@@ -12,7 +12,7 @@ int main()
MyClass *obj_cp;
obj_cp = obj_p;
- obj_p = obj_cp;
+ obj_p = obj_cp; // expected-warning {{incompatible pointer types assigning to 'MyClass<MyProtocol> *' from 'MyClass *'}}
if (obj_cp == obj_p)
foo();
diff --git a/test/SemaObjC/unqualified-to-qualified-class-warn.m b/test/SemaObjC/unqualified-to-qualified-class-warn.m
new file mode 100644
index 0000000000..5bbbfd9fcc
--- /dev/null
+++ b/test/SemaObjC/unqualified-to-qualified-class-warn.m
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// rdar://9091389
+
+@protocol Fooable
+- (void)foo;
+@end
+
+@protocol SubFooable <Fooable>
+@end
+
+@interface AClass
+@end
+
+@interface BClass : AClass <SubFooable>
+@end
+
+@implementation BClass
+- (void)foo {
+}
+@end
+
+void functionTakingAClassConformingToAProtocol(AClass <Fooable> *instance) { // expected-note {{passing argument to parameter 'instance' here}}
+}
+
+int main () {
+ AClass *aobject = 0;
+ BClass *bobject = 0;
+ functionTakingAClassConformingToAProtocol(aobject); // expected-warning {{incompatible pointer types passing 'AClass *' to parameter of type 'AClass<Fooable> *'}}
+ functionTakingAClassConformingToAProtocol(bobject); // Shouldn't warn - does implement Fooable
+ return 0;
+}
diff --git a/test/SemaObjCXX/references.mm b/test/SemaObjCXX/references.mm
index 585c75f3cd..3a522005ab 100644
--- a/test/SemaObjCXX/references.mm
+++ b/test/SemaObjCXX/references.mm
@@ -37,7 +37,7 @@ void f4(NSString &tmpstr) {
@protocol P2 @end
@protocol P3 @end
@interface foo<P1> {} @end
-@interface bar : foo <P1, P2> {} @end
+@interface bar : foo <P1, P2, P3> {} @end
typedef bar baz;
struct ToBar {