From: Daniel Dunbar Date: Thu, 16 Jul 2009 21:55:48 +0000 (+0000) Subject: Add more testing of ?: for Obj-C object types. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1cdad9e844173d3d7aaad05ce567343178d4dc89;p=clang Add more testing of ?: for Obj-C object types. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76108 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/SemaObjC/conditional-expr.m b/test/SemaObjC/conditional-expr.m index ec3613b2aa..e7855163f1 100644 --- a/test/SemaObjC/conditional-expr.m +++ b/test/SemaObjC/conditional-expr.m @@ -42,3 +42,53 @@ return nextOutputStream ? nextOutputStream : self; } @end + +// + +@protocol P0 +@property int intProp; +@end +@protocol P1 +@end +@protocol P2 +@end + +@interface A +@end + +@interface B : A +@end + +@interface C +@end + +@interface D +@end + +void f0(id x) { + x.intProp = 1; +} + +void f1(int cond, id x, id y) { + (cond ? x : y).intProp = 1; +} + +void f2(int cond, id x, A *y) { + (cond ? x : y).intProp = 1; +} + +void f3(int cond, id 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 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'}} +}