Steve Naroff | c43d868 | 2007-11-11 00:10:47 +0000 | [diff] [blame] | 1 | // RUN: clang -fsyntax-only -verify %s |
| 2 | |
| 3 | @interface foo |
| 4 | - (void)meth; |
| 5 | @end |
| 6 | |
| 7 | @implementation foo |
| 8 | - (void) contents {} // No declaration in @interface! |
Steve Naroff | 0416fb9 | 2007-11-11 17:19:15 +0000 | [diff] [blame] | 9 | - (void) meth { [self contents]; } |
Steve Naroff | c43d868 | 2007-11-11 00:10:47 +0000 | [diff] [blame] | 10 | @end |
| 11 | |
Steve Naroff | a924e7c | 2007-12-11 03:34:41 +0000 | [diff] [blame] | 12 | typedef struct _NSPoint { |
| 13 | float x; |
| 14 | float y; |
| 15 | } NSPoint; |
| 16 | |
| 17 | typedef struct _NSSize { |
| 18 | float width; |
| 19 | float height; |
| 20 | } NSSize; |
| 21 | |
| 22 | typedef struct _NSRect { |
| 23 | NSPoint origin; |
| 24 | NSSize size; |
| 25 | } NSRect; |
| 26 | |
| 27 | @interface AnyClass |
| 28 | - (NSRect)rect; |
| 29 | @end |
| 30 | |
| 31 | @class Helicopter; |
| 32 | |
| 33 | static void func(Helicopter *obj) { |
| 34 | // Note that the proto for "rect" is found in the global pool even when |
| 35 | // a statically typed object's class interface isn't in scope! This |
| 36 | // behavior isn't very desirable, however wee need it for GCC compatibility. |
| 37 | NSRect r = [obj rect]; |
| 38 | } |
Steve Naroff | a56f616 | 2007-12-18 01:30:32 +0000 | [diff] [blame] | 39 | |
| 40 | @interface NSObject @end |
| 41 | |
| 42 | extern Class NSClassFromObject(id object); |
| 43 | |
| 44 | @interface XX : NSObject |
| 45 | @end |
| 46 | |
| 47 | @implementation XX |
| 48 | |
| 49 | + _privateMethod { |
| 50 | return self; |
| 51 | } |
| 52 | |
| 53 | - (void) xx { |
| 54 | [NSClassFromObject(self) _privateMethod]; |
| 55 | } |
| 56 | @end |
| 57 | |
| 58 | @implementation XX (Private) |
| 59 | - (void) yy { |
| 60 | [NSClassFromObject(self) _privateMethod]; |
| 61 | } |
| 62 | @end |
| 63 | |
Daniel Dunbar | 91e19b2 | 2008-09-11 00:50:25 +0000 | [diff] [blame] | 64 | @interface I0 |
| 65 | -(void) nonVararg: (int) x; |
| 66 | @end |
| 67 | |
| 68 | int f0(I0 *ob) { |
Chris Lattner | 2c21a07 | 2008-11-21 18:44:24 +0000 | [diff] [blame] | 69 | [ ob nonVararg: 0, 1, 2]; // expected-error {{too many arguments to method call}} |
Daniel Dunbar | 91e19b2 | 2008-09-11 00:50:25 +0000 | [diff] [blame] | 70 | } |
Chris Lattner | e47f7b1 | 2009-02-18 04:41:38 +0000 | [diff] [blame] | 71 | |
| 72 | int f2() { |
| 73 | const id foo; |
| 74 | [foo bar]; // expected-warning {{method '-bar' not found (return type defaults to 'id')}} |
| 75 | return 0; |
| 76 | } |
| 77 | |
Chris Lattner | 0c73f37 | 2009-03-09 21:19:16 +0000 | [diff] [blame] | 78 | |
| 79 | // PR3766 |
| 80 | struct S { int X; } S; |
| 81 | |
| 82 | int test5(int X) { |
Chris Lattner | 4018a28 | 2009-03-11 03:47:47 +0000 | [diff] [blame] | 83 | int a = [X somemsg]; // expected-warning {{receiver type 'int' is not 'id'}} \ |
Chris Lattner | 0c73f37 | 2009-03-09 21:19:16 +0000 | [diff] [blame] | 84 | expected-warning {{method '-somemsg' not found}} \ |
| 85 | expected-warning {{incompatible pointer to integer conversion initializing 'id', expected 'int'}} |
| 86 | int b = [S somemsg]; // expected-error {{bad receiver type 'struct S'}} |
| 87 | } |
| 88 | |
| 89 | |
| 90 | |