]> granicus.if.org Git - clang/commitdiff
Add more testing of ?: for Obj-C object types.
authorDaniel Dunbar <daniel@zuster.org>
Thu, 16 Jul 2009 21:55:48 +0000 (21:55 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 16 Jul 2009 21:55:48 +0000 (21:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76108 91177308-0d34-0410-b5e6-96231b3b80d8

test/SemaObjC/conditional-expr.m

index ec3613b2aa9bc541479daf0dbf25aaee2a56a804..e7855163f181d74430d05b8434df4b2094597987 100644 (file)
   return nextOutputStream ? nextOutputStream : self;
 }
 @end
+
+//
+
+@protocol P0
+@property int intProp;
+@end
+@protocol P1
+@end
+@protocol P2
+@end
+
+@interface A <P0>
+@end
+
+@interface B : A
+@end
+
+@interface C
+@end
+
+@interface D
+@end
+
+void f0(id<P0> x) {
+  x.intProp = 1;
+}
+
+void f1(int cond, id<P0> x, id<P0> y) {
+  (cond ? x : y).intProp = 1;
+}
+
+void f2(int cond, id<P0> x, A *y) {
+  (cond ? x : y).intProp = 1;
+}
+
+void f3(int cond, id<P0> x, B *y) {
+  (cond ? x : y).intProp = 1;
+}
+
+void f4(int cond, id x, B *y) {
+  (cond ? x : y).intProp = 1; // expected-error {{property 'intProp' not found on object of type 'id'}}
+}
+
+void f5(int cond, id<P0> x, C *y) {
+  (cond ? x : y).intProp = 1; // expected-error {{property 'intProp' not found on object of type 'C *'}}
+}
+
+void f6(int cond, C *x, D *y) {
+  (cond ? x : y).intProp = 1; // expected-warning {{incompatible operand types}}, expected-error {{property 'intProp' not found on object of type 'id'}}
+}