blob: f171007be072edf69f5690993807d379f1f329ad [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc -fsyntax-only -verify %s
Steve Naroff6b9dfd42009-03-04 15:11:40 +00002
3#include <stddef.h>
4
Steve Narofffc479d72009-04-06 22:07:54 +00005typedef struct objc_class *Class;
6typedef struct objc_object {
7 Class isa;
8} *id;
Steve Naroff6b9dfd42009-03-04 15:11:40 +00009id objc_getClass(const char *s);
10
11@interface Object
12@end
13
14@protocol Func
15+ (int) class_func0;
16- (int) instance_func0;
17@end
18
19@interface Derived: Object
20+ (int) class_func1;
21+ (int) class_func2;
22+ (int) class_func3;
23+ (int) class_func4;
24+ (int) class_func5;
25+ (int) class_func6;
26+ (int) class_func7;
27- (int) instance_func1;
28- (int) instance_func2;
29- (int) instance_func3;
30- (int) instance_func4;
31- (int) instance_func5;
32- (int) instance_func6;
33- (int) instance_func7;
34@end
35
36@implementation Derived
37+ (int) class_func1
38{
39 int i = (size_t)[self class_func0]; // expected-warning {{method '-class_func0' not found (return type defaults to 'id')}}
40 return i + (size_t)[super class_func0]; // expected-warning {{method '+class_func0' not found (return type defaults to 'id')}}
41}
42+ (int) class_func2
43{
Steve Naroffebaa7682009-04-07 15:07:57 +000044 int i = [(id <Func>)self class_func0];
45 i += [(id <Func>)super class_func0]; // expected-warning {{casting 'super' is deprecated (it isn't an expression)}}
Steve Naroff6b9dfd42009-03-04 15:11:40 +000046 i += [(Class <Func>)self class_func0]; // expected-error {{protocol qualified 'Class' is unsupported}}
Steve Narofffc479d72009-04-06 22:07:54 +000047 return i + [(Class <Func>)super class_func0]; // expected-error {{protocol qualified 'Class' is unsupported}} // expected-warning {{casting 'super' is deprecated (it isn't an expression)}}
Steve Naroff6b9dfd42009-03-04 15:11:40 +000048}
49+ (int) class_func3
50{
Steve Narofffc479d72009-04-06 22:07:54 +000051 return [(Object <Func> *)super class_func0]; // expected-warning {{casting 'super' is deprecated (it isn't an expression)}} // expected-warning {{method '-class_func0' not found (return type defaults to 'id')}} // expected-warning {{incompatible pointer to integer conversion returning 'id', expected 'int'}}
Steve Naroff6b9dfd42009-03-04 15:11:40 +000052}
53+ (int) class_func4
54{
Steve Narofffc479d72009-04-06 22:07:54 +000055 return [(Derived <Func> *)super class_func0]; // expected-warning {{casting 'super' is deprecated (it isn't an expression)}} // expected-warning {{method '-class_func0' not found (return type defaults to 'id')}} // expected-warning {{incompatible pointer to integer conversion returning 'id', expected 'int'}}
Steve Naroff6b9dfd42009-03-04 15:11:40 +000056}
57+ (int) class_func5
58{
59 int i = (size_t)[Derived class_func0]; // expected-warning {{method '+class_func0' not found (return type defaults to 'id')}}
60 return i + (size_t)[Object class_func0]; // expected-warning {{method '+class_func0' not found (return type defaults to 'id')}}
61}
62+ (int) class_func6
63{
64 return (size_t)[objc_getClass("Object") class_func1]; // GCC warns about this
65}
66+ (int) class_func7
67{
68 return [objc_getClass("Derived") class_func1];
69}
70- (int) instance_func1
71{
72 int i = (size_t)[self instance_func0]; // expected-warning {{method '-instance_func0' not found (return type defaults to 'id'))}}
73 return i + (size_t)[super instance_func0]; // expected-warning {{method '-instance_func0' not found (return type defaults to 'id')}}
74}
75- (int) instance_func2
76{
Steve Narofffc479d72009-04-06 22:07:54 +000077 return [(id <Func>)super instance_func0]; // expected-warning {{casting 'super' is deprecated (it isn't an expression)}}
Steve Naroff6b9dfd42009-03-04 15:11:40 +000078}
79- (int) instance_func3
80{
Steve Narofffc479d72009-04-06 22:07:54 +000081 return [(Object <Func> *)super instance_func0]; // expected-warning {{casting 'super' is deprecated (it isn't an expression)}}
Steve Naroff6b9dfd42009-03-04 15:11:40 +000082}
83- (int) instance_func4
84{
Steve Narofffc479d72009-04-06 22:07:54 +000085 return [(Derived <Func> *)super instance_func0]; // expected-warning {{casting 'super' is deprecated (it isn't an expression)}}
Steve Naroff6b9dfd42009-03-04 15:11:40 +000086}
87- (int) instance_func5
88{
Fariborz Jahanianb1006c72009-03-04 17:50:39 +000089 int i = (size_t)[Derived instance_func1]; // expected-warning {{method '+instance_func1' not found (return type defaults to 'id')}}
Steve Naroff6b9dfd42009-03-04 15:11:40 +000090 return i + (size_t)[Object instance_func1]; // expected-warning {{method '+instance_func1' not found (return type defaults to 'id')}}
91}
92- (int) instance_func6
93{
94 return (size_t)[objc_getClass("Object") class_func1];
95}
96- (int) instance_func7
97{
98 return [objc_getClass("Derived") class_func1];
99}
100@end
101