1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -verify %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc#include <stddef.h> 4*f4a2713aSLionel Sambuc 5*f4a2713aSLionel Sambuctypedef struct objc_object *id; 6*f4a2713aSLionel Sambucid objc_getClass(const char *s); 7*f4a2713aSLionel Sambuc 8*f4a2713aSLionel Sambuc@interface Object 9*f4a2713aSLionel Sambuc- (id) initWithInt: (int) i; 10*f4a2713aSLionel Sambuc@end 11*f4a2713aSLionel Sambuc 12*f4a2713aSLionel Sambuc@protocol Func 13*f4a2713aSLionel Sambuc+ (int) class_func0; 14*f4a2713aSLionel Sambuc- (int) instance_func0; 15*f4a2713aSLionel Sambuc@end 16*f4a2713aSLionel Sambuc 17*f4a2713aSLionel Sambuc@interface Derived: Object // expected-note {{receiver is instance of class declared here}} 18*f4a2713aSLionel Sambuc+ (int) class_func1; 19*f4a2713aSLionel Sambuc+ (int) class_func2; 20*f4a2713aSLionel Sambuc+ (int) class_func3; 21*f4a2713aSLionel Sambuc+ (int) class_func4; 22*f4a2713aSLionel Sambuc+ (int) class_func5; 23*f4a2713aSLionel Sambuc+ (int) class_func6; 24*f4a2713aSLionel Sambuc+ (int) class_func7; 25*f4a2713aSLionel Sambuc- (int) instance_func1; 26*f4a2713aSLionel Sambuc- (int) instance_func2; 27*f4a2713aSLionel Sambuc- (int) instance_func3; 28*f4a2713aSLionel Sambuc- (int) instance_func4; 29*f4a2713aSLionel Sambuc- (int) instance_func5; 30*f4a2713aSLionel Sambuc- (int) instance_func6; 31*f4a2713aSLionel Sambuc- (int) instance_func7; 32*f4a2713aSLionel Sambuc- (id) initWithInt: (int) i; 33*f4a2713aSLionel Sambuc@end 34*f4a2713aSLionel Sambuc 35*f4a2713aSLionel Sambuc@implementation Derived 36*f4a2713aSLionel Sambuc+ (int) class_func1 37*f4a2713aSLionel Sambuc{ 38*f4a2713aSLionel Sambuc int i = (size_t)[self class_func0]; // expected-warning {{class method '+class_func0' not found (return type defaults to 'id'); did you mean '+class_func}} 39*f4a2713aSLionel Sambuc return i + (size_t)[super class_func0]; // expected-warning {{class method '+class_func0' not found (return type defaults to 'id')}} 40*f4a2713aSLionel Sambuc} 41*f4a2713aSLionel Sambuc+ (int) class_func2 42*f4a2713aSLionel Sambuc{ 43*f4a2713aSLionel Sambuc int i = [(id <Func>)self class_func0]; 44*f4a2713aSLionel Sambuc i += [(id <Func>)super class_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}} 45*f4a2713aSLionel Sambuc i += [(Class <Func>)self class_func0]; // 46*f4a2713aSLionel Sambuc return i + [(Class <Func>)super class_func0]; // // expected-error {{cannot cast 'super' (it isn't an expression)}} 47*f4a2713aSLionel Sambuc} 48*f4a2713aSLionel Sambuc+ (int) class_func3 49*f4a2713aSLionel Sambuc{ 50*f4a2713aSLionel Sambuc return [(Object <Func> *)super class_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}} 51*f4a2713aSLionel Sambuc} 52*f4a2713aSLionel Sambuc+ (int) class_func4 53*f4a2713aSLionel Sambuc{ 54*f4a2713aSLionel Sambuc return [(Derived <Func> *)super class_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}} 55*f4a2713aSLionel Sambuc} 56*f4a2713aSLionel Sambuc+ (int) class_func5 57*f4a2713aSLionel Sambuc{ 58*f4a2713aSLionel Sambuc int i = (size_t)[Derived class_func0]; // expected-warning {{class method '+class_func0' not found (return type defaults to 'id')}} 59*f4a2713aSLionel Sambuc return i + (size_t)[Object class_func0]; // expected-warning {{class method '+class_func0' not found (return type defaults to 'id')}} 60*f4a2713aSLionel Sambuc} 61*f4a2713aSLionel Sambuc+ (int) class_func6 62*f4a2713aSLionel Sambuc{ 63*f4a2713aSLionel Sambuc return (size_t)[objc_getClass("Object") class_func1]; // GCC warns about this 64*f4a2713aSLionel Sambuc} 65*f4a2713aSLionel Sambuc+ (int) class_func7 66*f4a2713aSLionel Sambuc{ 67*f4a2713aSLionel Sambuc return [objc_getClass("Derived") class_func1]; 68*f4a2713aSLionel Sambuc} 69*f4a2713aSLionel Sambuc- (int) instance_func1 70*f4a2713aSLionel Sambuc{ 71*f4a2713aSLionel Sambuc int i = (size_t)[self instance_func0]; // expected-warning {{instance method '-instance_func0' not found (return type defaults to 'id'); did you mean}} 72*f4a2713aSLionel Sambuc return i + (size_t)[super instance_func0]; // expected-warning {{'Object' may not respond to 'instance_func0'}} 73*f4a2713aSLionel Sambuc} 74*f4a2713aSLionel Sambuc- (int) instance_func2 75*f4a2713aSLionel Sambuc{ 76*f4a2713aSLionel Sambuc return [(id <Func>)super instance_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}} 77*f4a2713aSLionel Sambuc} 78*f4a2713aSLionel Sambuc- (int) instance_func3 79*f4a2713aSLionel Sambuc{ 80*f4a2713aSLionel Sambuc return [(Object <Func> *)super instance_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}} 81*f4a2713aSLionel Sambuc} 82*f4a2713aSLionel Sambuc- (int) instance_func4 83*f4a2713aSLionel Sambuc{ 84*f4a2713aSLionel Sambuc return [(Derived <Func> *)super instance_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}} 85*f4a2713aSLionel Sambuc} 86*f4a2713aSLionel Sambuc- (int) instance_func5 87*f4a2713aSLionel Sambuc{ 88*f4a2713aSLionel Sambuc int i = (size_t)[Derived instance_func1]; // expected-warning {{class method '+instance_func1' not found (return type defaults to 'id')}} 89*f4a2713aSLionel Sambuc return i + (size_t)[Object instance_func1]; // expected-warning {{class method '+instance_func1' not found (return type defaults to 'id')}} 90*f4a2713aSLionel Sambuc} 91*f4a2713aSLionel Sambuc- (int) instance_func6 92*f4a2713aSLionel Sambuc{ 93*f4a2713aSLionel Sambuc return (size_t)[objc_getClass("Object") class_func1]; 94*f4a2713aSLionel Sambuc} 95*f4a2713aSLionel Sambuc- (int) instance_func7 96*f4a2713aSLionel Sambuc{ 97*f4a2713aSLionel Sambuc return [objc_getClass("Derived") class_func1]; 98*f4a2713aSLionel Sambuc} 99*f4a2713aSLionel Sambuc- (id) initWithInt: (int) i 100*f4a2713aSLionel Sambuc{ 101*f4a2713aSLionel Sambuc // Don't warn about parentheses here. 102*f4a2713aSLionel Sambuc if (self = [super initWithInt: i]) { 103*f4a2713aSLionel Sambuc [self instance_func1]; 104*f4a2713aSLionel Sambuc } 105*f4a2713aSLionel Sambuc return self; 106*f4a2713aSLionel Sambuc} 107*f4a2713aSLionel Sambuc@end 108*f4a2713aSLionel Sambuc 109