2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
2009-03-04 23:11:40 +08:00
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2009-04-09 07:52:26 +08:00
|
|
|
typedef struct objc_object *id;
|
2009-03-04 23:11:40 +08:00
|
|
|
id objc_getClass(const char *s);
|
|
|
|
|
|
|
|
@interface Object
|
2009-11-11 10:41:58 +08:00
|
|
|
- (id) initWithInt: (int) i;
|
2009-03-04 23:11:40 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
@protocol Func
|
|
|
|
+ (int) class_func0;
|
|
|
|
- (int) instance_func0;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface Derived: Object
|
|
|
|
+ (int) class_func1;
|
|
|
|
+ (int) class_func2;
|
|
|
|
+ (int) class_func3;
|
|
|
|
+ (int) class_func4;
|
|
|
|
+ (int) class_func5;
|
|
|
|
+ (int) class_func6;
|
|
|
|
+ (int) class_func7;
|
|
|
|
- (int) instance_func1;
|
|
|
|
- (int) instance_func2;
|
|
|
|
- (int) instance_func3;
|
|
|
|
- (int) instance_func4;
|
|
|
|
- (int) instance_func5;
|
|
|
|
- (int) instance_func6;
|
|
|
|
- (int) instance_func7;
|
2009-11-11 10:41:58 +08:00
|
|
|
- (id) initWithInt: (int) i;
|
2009-03-04 23:11:40 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation Derived
|
|
|
|
+ (int) class_func1
|
|
|
|
{
|
2011-03-27 01:07:06 +08:00
|
|
|
int i = (size_t)[self class_func0]; // expected-warning {{class method '+class_func0' not found (return type defaults to 'id')}}
|
|
|
|
return i + (size_t)[super class_func0]; // expected-warning {{class method '+class_func0' not found (return type defaults to 'id')}}
|
2009-03-04 23:11:40 +08:00
|
|
|
}
|
|
|
|
+ (int) class_func2
|
|
|
|
{
|
2009-04-07 23:07:57 +08:00
|
|
|
int i = [(id <Func>)self class_func0];
|
2009-04-09 07:52:26 +08:00
|
|
|
i += [(id <Func>)super class_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}
|
2009-07-23 00:07:01 +08:00
|
|
|
i += [(Class <Func>)self class_func0]; //
|
|
|
|
return i + [(Class <Func>)super class_func0]; // // expected-error {{cannot cast 'super' (it isn't an expression)}}
|
2009-03-04 23:11:40 +08:00
|
|
|
}
|
|
|
|
+ (int) class_func3
|
|
|
|
{
|
2009-04-09 07:52:26 +08:00
|
|
|
return [(Object <Func> *)super class_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}
|
2009-03-04 23:11:40 +08:00
|
|
|
}
|
|
|
|
+ (int) class_func4
|
|
|
|
{
|
2009-04-09 07:52:26 +08:00
|
|
|
return [(Derived <Func> *)super class_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}
|
2009-03-04 23:11:40 +08:00
|
|
|
}
|
|
|
|
+ (int) class_func5
|
|
|
|
{
|
2011-03-27 01:07:06 +08:00
|
|
|
int i = (size_t)[Derived class_func0]; // expected-warning {{class method '+class_func0' not found (return type defaults to 'id')}}
|
|
|
|
return i + (size_t)[Object class_func0]; // expected-warning {{class method '+class_func0' not found (return type defaults to 'id')}}
|
2009-03-04 23:11:40 +08:00
|
|
|
}
|
|
|
|
+ (int) class_func6
|
|
|
|
{
|
|
|
|
return (size_t)[objc_getClass("Object") class_func1]; // GCC warns about this
|
|
|
|
}
|
|
|
|
+ (int) class_func7
|
|
|
|
{
|
|
|
|
return [objc_getClass("Derived") class_func1];
|
|
|
|
}
|
|
|
|
- (int) instance_func1
|
|
|
|
{
|
2011-03-27 01:07:06 +08:00
|
|
|
int i = (size_t)[self instance_func0]; // expected-warning {{instance method '-instance_func0' not found (return type defaults to 'id'))}}
|
2010-04-11 16:28:14 +08:00
|
|
|
return i + (size_t)[super instance_func0]; // expected-warning {{'Object' may not respond to 'instance_func0')}}
|
2009-03-04 23:11:40 +08:00
|
|
|
}
|
|
|
|
- (int) instance_func2
|
|
|
|
{
|
2009-04-09 07:52:26 +08:00
|
|
|
return [(id <Func>)super instance_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}
|
2009-03-04 23:11:40 +08:00
|
|
|
}
|
|
|
|
- (int) instance_func3
|
|
|
|
{
|
2009-04-09 07:52:26 +08:00
|
|
|
return [(Object <Func> *)super instance_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}
|
2009-03-04 23:11:40 +08:00
|
|
|
}
|
|
|
|
- (int) instance_func4
|
|
|
|
{
|
2009-04-09 07:52:26 +08:00
|
|
|
return [(Derived <Func> *)super instance_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}
|
2009-03-04 23:11:40 +08:00
|
|
|
}
|
|
|
|
- (int) instance_func5
|
|
|
|
{
|
2011-03-27 01:07:06 +08:00
|
|
|
int i = (size_t)[Derived instance_func1]; // expected-warning {{class method '+instance_func1' not found (return type defaults to 'id')}}
|
|
|
|
return i + (size_t)[Object instance_func1]; // expected-warning {{class method '+instance_func1' not found (return type defaults to 'id')}}
|
2009-03-04 23:11:40 +08:00
|
|
|
}
|
|
|
|
- (int) instance_func6
|
|
|
|
{
|
|
|
|
return (size_t)[objc_getClass("Object") class_func1];
|
|
|
|
}
|
|
|
|
- (int) instance_func7
|
|
|
|
{
|
|
|
|
return [objc_getClass("Derived") class_func1];
|
|
|
|
}
|
2009-11-11 10:41:58 +08:00
|
|
|
- (id) initWithInt: (int) i
|
|
|
|
{
|
|
|
|
// Don't warn about parentheses here.
|
|
|
|
if (self = [super initWithInt: i]) {
|
|
|
|
[self instance_func1];
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
2009-03-04 23:11:40 +08:00
|
|
|
@end
|
|
|
|
|