blob: fd069af7b02c9606e6fa8475a43e2cc843dd11f2 [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 {
Richard Trieu2fe9b7f2011-12-15 00:38:15 +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) {
John McCall2fbe92c2013-03-01 09:20:14 +000054 [super m]; // expected-warning{{receiver type 'int' is not 'id'}}
Steve Naroff5cb93b82008-11-19 15:54:23 +000055}
Douglas Gregor9a632ea2010-10-20 03:06:34 +000056void f1(id puper) { // expected-note {{'puper' declared here}}
Douglas Gregor3eedbb02010-10-20 01:32:02 +000057 [super m]; // expected-error{{use of undeclared identifier 'super'}}
Steve Naroff5cb93b82008-11-19 15:54:23 +000058}
Fariborz Jahaniane4fb8282010-01-22 23:04:44 +000059
60// radar 7400691
61typedef Foo super;
62
Chris Lattnereb483eb2010-04-11 08:28:14 +000063typedef Foo FooTD;
64
Fariborz Jahaniane4fb8282010-01-22 23:04:44 +000065void test() {
Chris Lattnereb483eb2010-04-11 08:28:14 +000066 [FooTD cMethod];
Fariborz Jahaniane4fb8282010-01-22 23:04:44 +000067 [super cMethod];
68}
Chris Lattner236beab2010-04-12 06:20:33 +000069
70struct SomeStruct {
71 int X;
72};
73
74int test2() {
75 struct SomeStruct super = { 0 };
76 return super.X;
77}
Chris Lattnera823d6a2010-04-12 06:27:57 +000078
79int test3() {
80 id super = 0;
81 [(B*)super instanceMethod];
82 int *s1 = (int*)super;
Chris Lattner1e461362010-04-12 06:36:00 +000083
84 id X[] = { [ super superClassMethod] };
Chris Lattnera823d6a2010-04-12 06:27:57 +000085 return 0;
86}