blob: d751d1771945732ba75a1b813c0abf3da7254828 [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] };
37 id Y[] = { [ super.superClassMethod iMethod] };
Mike Stumpd1969d82009-07-22 00:43:08 +000038 return 0;
Steve Naroff87d3ef02008-11-17 22:29:32 +000039}
40@end
Steve Naroff5cb93b82008-11-19 15:54:23 +000041
42@interface XX
43- m;
44@end
45
46void f(id super) {
47 [super m];
48}
49void f0(int super) {
Chris Lattner4018a282009-03-11 03:47:47 +000050 [super m]; // expected-warning{{receiver type 'int' is not 'id'}} \
Chris Lattner0c73f372009-03-09 21:19:16 +000051 expected-warning {{method '-m' not found (return type defaults to 'id')}}
Steve Naroff5cb93b82008-11-19 15:54:23 +000052}
Chris Lattner15faee12010-04-12 05:38:43 +000053void f1(id puper) { // expected-note {{'puper' declared here}}
54 [super m]; // expected-error{{use of undeclared identifier 'super'; did you mean 'puper'?}}
Steve Naroff5cb93b82008-11-19 15:54:23 +000055}
Fariborz Jahaniane4fb8282010-01-22 23:04:44 +000056
57// radar 7400691
58typedef Foo super;
59
Chris Lattnereb483eb2010-04-11 08:28:14 +000060typedef Foo FooTD;
61
Fariborz Jahaniane4fb8282010-01-22 23:04:44 +000062void test() {
Chris Lattnereb483eb2010-04-11 08:28:14 +000063 [FooTD cMethod];
Fariborz Jahaniane4fb8282010-01-22 23:04:44 +000064 [super cMethod];
65}
Chris Lattner236beab2010-04-12 06:20:33 +000066
67struct SomeStruct {
68 int X;
69};
70
71int test2() {
72 struct SomeStruct super = { 0 };
73 return super.X;
74}
Chris Lattnera823d6a2010-04-12 06:27:57 +000075
76int test3() {
77 id super = 0;
78 [(B*)super instanceMethod];
79 int *s1 = (int*)super;
Chris Lattner1e461362010-04-12 06:36:00 +000080
81 id X[] = { [ super superClassMethod] };
Chris Lattnera823d6a2010-04-12 06:27:57 +000082 return 0;
83}
Chris Lattner454006d2010-04-12 17:03:29 +000084
85