1*67e74705SXin Li// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s 2*67e74705SXin Li 3*67e74705SXin Litypedef struct objc_object { 4*67e74705SXin Li Class isa; 5*67e74705SXin Li} *id; 6*67e74705SXin Li 7*67e74705SXin Li 8*67e74705SXin Li@interface foo 9*67e74705SXin Li- (void)meth; 10*67e74705SXin Li@end 11*67e74705SXin Li 12*67e74705SXin Li@implementation foo 13*67e74705SXin Li- (void) contents {} // No declaration in @interface! 14*67e74705SXin Li- (void) meth { [self contents]; } 15*67e74705SXin Li@end 16*67e74705SXin Li 17*67e74705SXin Litypedef struct _NSPoint { 18*67e74705SXin Li float x; 19*67e74705SXin Li float y; 20*67e74705SXin Li} NSPoint; 21*67e74705SXin Li 22*67e74705SXin Litypedef struct _NSSize { 23*67e74705SXin Li float width; 24*67e74705SXin Li float height; 25*67e74705SXin Li} NSSize; 26*67e74705SXin Li 27*67e74705SXin Litypedef struct _NSRect { 28*67e74705SXin Li NSPoint origin; 29*67e74705SXin Li NSSize size; 30*67e74705SXin Li} NSRect; 31*67e74705SXin Li 32*67e74705SXin Li@interface AnyClass 33*67e74705SXin Li- (NSRect)rect; 34*67e74705SXin Li@end 35*67e74705SXin Li 36*67e74705SXin Li@class Helicopter; 37*67e74705SXin Li 38*67e74705SXin Listatic void func(Helicopter *obj) { 39*67e74705SXin Li // Note that the proto for "rect" is found in the global pool even when 40*67e74705SXin Li // a statically typed object's class interface isn't in scope! This 41*67e74705SXin Li // behavior isn't very desirable, however wee need it for GCC compatibility. 42*67e74705SXin Li NSRect r = [obj rect]; 43*67e74705SXin Li} 44*67e74705SXin Li 45*67e74705SXin Li@interface NSObject @end 46*67e74705SXin Li 47*67e74705SXin Liextern Class NSClassFromObject(id object); 48*67e74705SXin Li 49*67e74705SXin Li@interface XX : NSObject 50*67e74705SXin Li@end 51*67e74705SXin Li 52*67e74705SXin Li@implementation XX 53*67e74705SXin Li 54*67e74705SXin Li+ _privateMethod { 55*67e74705SXin Li return self; 56*67e74705SXin Li} 57*67e74705SXin Li 58*67e74705SXin Li- (void) xx { 59*67e74705SXin Li [NSClassFromObject(self) _privateMethod]; 60*67e74705SXin Li} 61*67e74705SXin Li@end 62*67e74705SXin Li 63*67e74705SXin Li@implementation XX (Private) 64*67e74705SXin Li- (void) yy { 65*67e74705SXin Li [NSClassFromObject(self) _privateMethod]; 66*67e74705SXin Li} 67*67e74705SXin Li@end 68*67e74705SXin Li 69*67e74705SXin Li@interface I0 70*67e74705SXin Li-(void) nonVararg: (int) x; 71*67e74705SXin Li@end 72*67e74705SXin Li 73*67e74705SXin Liint f0(I0 *ob) { 74*67e74705SXin Li [ ob nonVararg: 0, 1, 2]; // expected-error {{too many arguments to method call}} 75*67e74705SXin Li} 76*67e74705SXin Li 77*67e74705SXin Liint f2() { 78*67e74705SXin Li const id foo; 79*67e74705SXin Li [foo bar]; // expected-warning {{method '-bar' not found (return type defaults to 'id')}} 80*67e74705SXin Li return 0; 81*67e74705SXin Li} 82*67e74705SXin Li 83*67e74705SXin Li 84*67e74705SXin Li// PR3766 85*67e74705SXin Listruct S { int X; } S; 86*67e74705SXin Li 87*67e74705SXin Liint test5(int X) { 88*67e74705SXin Li int a = [X somemsg]; // expected-warning {{receiver type 'int' is not 'id'}} \ 89*67e74705SXin Li expected-warning {{method '-somemsg' not found}} \ 90*67e74705SXin Li expected-warning {{incompatible pointer to integer conversion initializing 'int' with an expression of type 'id'}} 91*67e74705SXin Li int b = [S somemsg]; // expected-error {{bad receiver type 'struct S'}} 92*67e74705SXin Li} 93*67e74705SXin Li 94*67e74705SXin Li// PR4021 95*67e74705SXin Livoid foo4() { 96*67e74705SXin Li struct objc_object X[10]; 97*67e74705SXin Li 98*67e74705SXin Li [X rect]; // expected-warning {{receiver type 'struct objc_object *' is not 'id' or interface pointer, consider casting it to 'id'}} 99*67e74705SXin Li} 100*67e74705SXin Li 101*67e74705SXin Li// rdar://13207886 102*67e74705SXin Livoid foo5(id p) { 103*67e74705SXin Li p 104*67e74705SXin Li [(id)(p) bar]; // expected-error {{missing '['}} \ 105*67e74705SXin Li // expected-error {{expected ']'}} \ 106*67e74705SXin Li // expected-note {{to match this '['}} \ 107*67e74705SXin Li // expected-warning {{instance method '-bar' not found}} 108*67e74705SXin Li} 109*67e74705SXin Li 110*67e74705SXin Li@interface I1 // expected-note {{receiver is instance of class declared here}} 111*67e74705SXin Li-(void)unavail_meth __attribute__((unavailable)); // expected-note {{marked unavailable here}} 112*67e74705SXin Li@end 113*67e74705SXin Li 114*67e74705SXin Li// rdar://13620447 115*67e74705SXin Livoid foo6(I1 *p) { 116*67e74705SXin Li [p 117*67e74705SXin Li bar]; // expected-warning {{instance method '-bar' not found}} 118*67e74705SXin Li [p 119*67e74705SXin Li unavail_meth]; // expected-error {{unavailable}} 120*67e74705SXin Li} 121