blob: 9498a8ce7ea9ada140986518c9b27d300d927546 [file] [log] [blame]
Chris Lattner454006d2010-04-12 17:03:29 +00001// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s
2
3void takevoidptr(void*);
4
Steve Naroff87d3ef02008-11-17 22:29:32 +00005
6@interface Foo
7- iMethod;
8+ cMethod;
9@end
10
11@interface A
Chris Lattner1e461362010-04-12 06:36:00 +000012+ superClassMethod;
Chris Lattner454006d2010-04-12 17:03:29 +000013- (void)instanceMethod;
Steve Naroff87d3ef02008-11-17 22:29:32 +000014@end
15
16@interface B : A
17- (void)instanceMethod;
18+ classMethod;
19@end
20
21@implementation B
22
23- (void)instanceMethod {
Chris Lattnereb483eb2010-04-11 08:28:14 +000024 [super iMethod]; // expected-warning{{'A' may not respond to 'iMethod')}}
Chris Lattner454006d2010-04-12 17:03:29 +000025
26 // Use of super in a block is ok and does codegen to the right thing.
27 // rdar://7852959
28 takevoidptr(^{
29 [super instanceMethod];
30 });
Steve Naroff87d3ef02008-11-17 22:29:32 +000031}
32
33+ classMethod {
34 [super cMethod]; // expected-warning{{method '+cMethod' not found (return type defaults to 'id')}}
Chris Lattner1e461362010-04-12 06:36:00 +000035
36 id X[] = { [ super superClassMethod] };
Chris Lattner8b9f1872010-04-12 17:09:27 +000037 id Y[] = {
38 [ super.superClassMethod iMethod],
39 super.superClassMethod,
40 (id)super.superClassMethod // not a cast of super: rdar://7853261
41 };
Mike Stumpd1969d82009-07-22 00:43:08 +000042 return 0;
Steve Naroff87d3ef02008-11-17 22:29:32 +000043}
44@end
Steve Naroff5cb93b82008-11-19 15:54:23 +000045
46@interface XX
47- m;
48@end
49
50void f(id super) {
51 [super m];
52}
53void f0(int super) {
Chris Lattner4018a282009-03-11 03:47:47 +000054 [super m]; // expected-warning{{receiver type 'int' is not 'id'}} \
Chris Lattner0c73f372009-03-09 21:19:16 +000055 expected-warning {{method '-m' not found (return type defaults to 'id')}}
Steve Naroff5cb93b82008-11-19 15:54:23 +000056}
Chris Lattner15faee12010-04-12 05:38:43 +000057void f1(id puper) { // expected-note {{'puper' declared here}}
58 [super m]; // expected-error{{use of undeclared identifier 'super'; did you mean 'puper'?}}
Steve Naroff5cb93b82008-11-19 15:54:23 +000059}
Fariborz Jahaniane4fb8282010-01-22 23:04:44 +000060
61// radar 7400691
62typedef Foo super;
63
Chris Lattnereb483eb2010-04-11 08:28:14 +000064typedef Foo FooTD;
65
Fariborz Jahaniane4fb8282010-01-22 23:04:44 +000066void test() {
Chris Lattnereb483eb2010-04-11 08:28:14 +000067 [FooTD cMethod];
Fariborz Jahaniane4fb8282010-01-22 23:04:44 +000068 [super cMethod];
69}
Chris Lattner236beab2010-04-12 06:20:33 +000070
71struct SomeStruct {
72 int X;
73};
74
75int test2() {
76 struct SomeStruct super = { 0 };
77 return super.X;
78}
Chris Lattnera823d6a2010-04-12 06:27:57 +000079
80int test3() {
81 id super = 0;
82 [(B*)super instanceMethod];
83 int *s1 = (int*)super;
Chris Lattner1e461362010-04-12 06:36:00 +000084
85 id X[] = { [ super superClassMethod] };
Chris Lattnera823d6a2010-04-12 06:27:57 +000086 return 0;
87}
Chris Lattner454006d2010-04-12 17:03:29 +000088
89