// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wno-objc-root-class %s @protocol NSObject @end @protocol DTOutputStreams @end @interface DTFilterOutputStream - nextOutputStream; @end @implementation DTFilterOutputStream - (id)initWithNextOutputStream:(id ) outputStream { id nextOutputStream = [self nextOutputStream]; self = nextOutputStream; return nextOutputStream ? nextOutputStream : self; } - nextOutputStream { return self; } @end @interface DTFilterOutputStream2 - nextOutputStream; // expected-note {{method 'nextOutputStream' declared here}} @end @implementation DTFilterOutputStream2 // expected-warning {{method definition for 'nextOutputStream' not found}} - (id)initWithNextOutputStream:(id ) outputStream { id nextOutputStream = [self nextOutputStream]; self = nextOutputStream; // expected-warning {{assigning to 'DTFilterOutputStream2 *' from incompatible type 'id'}} return nextOutputStream ? nextOutputStream : self; // expected-warning {{incompatible operand types ('id' and 'DTFilterOutputStream2 *')}} } @end // No @interface declaration for DTFilterOutputStream3 @implementation DTFilterOutputStream3 // expected-warning {{cannot find interface declaration for 'DTFilterOutputStream3'}} \ // expected-note {{receiver is instance of class declared here}} - (id)initWithNextOutputStream:(id ) outputStream { id nextOutputStream = [self nextOutputStream]; // expected-warning {{method '-nextOutputStream' not found (return type defaults to 'id')}} self = nextOutputStream; // expected-warning {{assigning to 'DTFilterOutputStream3 *' from incompatible type 'id'}} return nextOutputStream ? nextOutputStream : self; // expected-warning {{incompatible operand types ('id' and 'DTFilterOutputStream3 *')}} } @end // @protocol P0 @property int intProp; @end @protocol P1 @end @protocol P2 @end @protocol P3 @end @protocol P4 @end @interface A @end @interface B : A @end @interface C @end @interface D @end @interface E : A @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-warning {{incompatible operand types ('id' and 'C *')}} expected-error {{property 'intProp' not found on object of type 'id'}} } 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'}} } id f7(int a, id x, A* p) { return a ? x : p; } int f8(int a, A *x, A *y) { return [ (a ? x : y ) intProp ]; } void f9(int a, A *x, A *y) { id l0 = (a ? x : y ); // Ok. y is of A object type and A is qualified by P0. A *l1 = (a ? x : y ); // Ok. y is of A object type and A is qualified by P0. A *l2 = (a ? x : y ); // expected-warning {{incompatible pointer types initializing 'A *' with an expression of type 'A *'}} (void)[ (a ? x : y ) intProp ]; // Ok. Common type is A * and P0's property intProp is accessed. } void f10(int a, id x, id y) { [ (a ? x : y ) intProp ]; } void f11(int a, id x, id y) { [ (a ? x : y ) intProp ]; // expected-warning {{incompatible operand types ('id' and 'id')}} } void f12(int a, A *x, A *y) { A* l0 = (a ? x : y ); // expected-warning {{incompatible pointer types initializing 'A *' with an expression of type 'A *'}} } void f13(int a, B *x, E *y) { int *ip = a ? x : y; // expected-warning{{expression of type 'A *'}} }