blob: 88de77c259ad1d743150b8780a3f40086f7eb977 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Steve Naroff87d3ef02008-11-17 22:29:32 +00002
3@interface Foo
4- iMethod;
5+ cMethod;
6@end
7
8@interface A
Chris Lattner1e461362010-04-12 06:36:00 +00009+ superClassMethod;
Steve Naroff87d3ef02008-11-17 22:29:32 +000010@end
11
12@interface B : A
13- (void)instanceMethod;
14+ classMethod;
15@end
16
17@implementation B
18
19- (void)instanceMethod {
Chris Lattnereb483eb2010-04-11 08:28:14 +000020 [super iMethod]; // expected-warning{{'A' may not respond to 'iMethod')}}
Steve Naroff87d3ef02008-11-17 22:29:32 +000021}
22
23+ classMethod {
24 [super cMethod]; // expected-warning{{method '+cMethod' not found (return type defaults to 'id')}}
Chris Lattner1e461362010-04-12 06:36:00 +000025
26 id X[] = { [ super superClassMethod] };
27 id Y[] = { [ super.superClassMethod iMethod] };
Mike Stumpd1969d82009-07-22 00:43:08 +000028 return 0;
Steve Naroff87d3ef02008-11-17 22:29:32 +000029}
30@end
Steve Naroff5cb93b82008-11-19 15:54:23 +000031
32@interface XX
33- m;
34@end
35
36void f(id super) {
37 [super m];
38}
39void f0(int super) {
Chris Lattner4018a282009-03-11 03:47:47 +000040 [super m]; // expected-warning{{receiver type 'int' is not 'id'}} \
Chris Lattner0c73f372009-03-09 21:19:16 +000041 expected-warning {{method '-m' not found (return type defaults to 'id')}}
Steve Naroff5cb93b82008-11-19 15:54:23 +000042}
Chris Lattner15faee12010-04-12 05:38:43 +000043void f1(id puper) { // expected-note {{'puper' declared here}}
44 [super m]; // expected-error{{use of undeclared identifier 'super'; did you mean 'puper'?}}
Steve Naroff5cb93b82008-11-19 15:54:23 +000045}
Fariborz Jahaniane4fb8282010-01-22 23:04:44 +000046
47// radar 7400691
48typedef Foo super;
49
Chris Lattnereb483eb2010-04-11 08:28:14 +000050typedef Foo FooTD;
51
Fariborz Jahaniane4fb8282010-01-22 23:04:44 +000052void test() {
Chris Lattnereb483eb2010-04-11 08:28:14 +000053 [FooTD cMethod];
Fariborz Jahaniane4fb8282010-01-22 23:04:44 +000054 [super cMethod];
55}
Chris Lattner236beab2010-04-12 06:20:33 +000056
57struct SomeStruct {
58 int X;
59};
60
61int test2() {
62 struct SomeStruct super = { 0 };
63 return super.X;
64}
Chris Lattnera823d6a2010-04-12 06:27:57 +000065
66int test3() {
67 id super = 0;
68 [(B*)super instanceMethod];
69 int *s1 = (int*)super;
Chris Lattner1e461362010-04-12 06:36:00 +000070
71 id X[] = { [ super superClassMethod] };
Chris Lattnera823d6a2010-04-12 06:27:57 +000072 return 0;
73}