[Heikki Kultala] This patch contains the ABI changes for the TCE target.
[clang.git] / test / SemaObjC / message.m
blobfed3961ce111d808a4a84467600d95fc75117252
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 typedef struct objc_object {
4   Class isa;
5 } *id;
8 @interface foo
9 - (void)meth;
10 @end
12 @implementation foo
13 - (void) contents {}                    // No declaration in @interface!
14 - (void) meth { [self contents]; } 
15 @end
17 typedef struct _NSPoint {
18     float x;
19     float y;
20 } NSPoint;
22 typedef struct _NSSize {
23     float width; 
24     float height;
25 } NSSize;
27 typedef struct _NSRect {
28     NSPoint origin;
29     NSSize size;
30 } NSRect;
32 @interface AnyClass
33 - (NSRect)rect;
34 @end
36 @class Helicopter;
38 static void func(Helicopter *obj) {
39   // Note that the proto for "rect" is found in the global pool even when
40   // a statically typed object's class interface isn't in scope! This 
41   // behavior isn't very desirable, however wee need it for GCC compatibility.
42   NSRect r = [obj rect];
45 @interface NSObject @end
47 extern Class NSClassFromObject(id object);
49 @interface XX : NSObject 
50 @end
52 @implementation XX
54 + _privateMethod {
55   return self;
58 - (void) xx {
59   [NSClassFromObject(self) _privateMethod];
61 @end
63 @implementation XX (Private)
64 - (void) yy {
65   [NSClassFromObject(self) _privateMethod];
67 @end
69 @interface I0
70 -(void) nonVararg: (int) x;
71 @end
73 int f0(I0 *ob) {
74   [ ob nonVararg: 0, 1, 2]; // expected-error {{too many arguments to method call}}
77 int f2() {
78     const id foo;
79     [foo bar];  // expected-warning {{method '-bar' not found (return type defaults to 'id')}}
80     return 0;
84 // PR3766
85 struct S { int X; } S;
87 int test5(int X) {
88   int a = [X somemsg];  // expected-warning {{receiver type 'int' is not 'id'}} \
89                            expected-warning {{method '-somemsg' not found}} \
90                            expected-warning {{incompatible pointer to integer conversion initializing 'int' with an expression of type 'id'}}
91   int b = [S somemsg];  // expected-error {{bad receiver type 'struct S'}}
94 // PR4021
95 void foo4() {
96   struct objc_object X[10];
97   
98   [X rect]; // expected-warning {{receiver type 'struct objc_object *' is not 'id' or interface pointer, consider casting it to 'id'}} expected-warning {{method '-rect' not found (return type defaults to 'id')}}