blob: 7dc4fc67b3f90af09f74a6797c88cdb67f5ac62a [file] [log] [blame]
Steve Naroffc43d8682007-11-11 00:10:47 +00001// 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 Naroff0416fb92007-11-11 17:19:15 +00009- (void) meth { [self contents]; }
Steve Naroffc43d8682007-11-11 00:10:47 +000010@end
11
Steve Naroffa924e7c2007-12-11 03:34:41 +000012typedef struct _NSPoint {
13 float x;
14 float y;
15} NSPoint;
16
17typedef struct _NSSize {
18 float width;
19 float height;
20} NSSize;
21
22typedef struct _NSRect {
23 NSPoint origin;
24 NSSize size;
25} NSRect;
26
27@interface AnyClass
28- (NSRect)rect;
29@end
30
31@class Helicopter;
32
33static 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 Naroffa56f6162007-12-18 01:30:32 +000039
40@interface NSObject @end
41
42extern 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 Dunbar91e19b22008-09-11 00:50:25 +000064@interface I0
65-(void) nonVararg: (int) x;
66@end
67
68int f0(I0 *ob) {
Chris Lattner2c21a072008-11-21 18:44:24 +000069 [ ob nonVararg: 0, 1, 2]; // expected-error {{too many arguments to method call}}
Daniel Dunbar91e19b22008-09-11 00:50:25 +000070}
Chris Lattnere47f7b12009-02-18 04:41:38 +000071
72int 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 Lattner0c73f372009-03-09 21:19:16 +000078
79// PR3766
80struct S { int X; } S;
81
82int test5(int X) {
Chris Lattner4018a282009-03-11 03:47:47 +000083 int a = [X somemsg]; // expected-warning {{receiver type 'int' is not 'id'}} \
Chris Lattner0c73f372009-03-09 21:19:16 +000084 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