brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.9 KiB · 885f392 Raw
124 lines · plain
1// RUN: %clang_cc1 -fsyntax-only -verify %s2 3#include <stddef.h>4 5typedef struct objc_object *id;6id objc_getClass(const char *s);7 8@interface Object 9- (id) initWithInt: (int) i;10@end11 12@protocol Func13+ (int) class_func0;14- (int) instance_func0;15@end16 17@interface Derived: Object // expected-note {{receiver is instance of class declared here}}18+ (int) class_func1;19+ (int) class_func2;20+ (int) class_func3;21+ (int) class_func4;22+ (int) class_func5;23+ (int) class_func6;24+ (int) class_func7;25- (int) instance_func1;26- (int) instance_func2;27- (int) instance_func3;28- (int) instance_func4;29- (int) instance_func5;30- (int) instance_func6;31- (int) instance_func7;32- (id) initWithInt: (int) i;33@end34 35@implementation Derived36+ (int) class_func137{38   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   return i + (size_t)[super class_func0];   // expected-warning {{class method '+class_func0' not found (return type defaults to 'id')}}40}41+ (int) class_func242{43   int i = [(id <Func>)self class_func0];44   i += [(id <Func>)super class_func0];    // expected-error {{cannot cast 'super' (it isn't an expression)}}45   i += [(Class <Func>)self class_func0];  // 46   return i + [(Class <Func>)super class_func0]; // // expected-error {{cannot cast 'super' (it isn't an expression)}}47}48+ (int) class_func349{50   return [(Object <Func> *)super class_func0];  // expected-error {{cannot cast 'super' (it isn't an expression)}}51}52+ (int) class_func453{54   return [(Derived <Func> *)super class_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}55}   56+ (int) class_func557{58   int i = (size_t)[Derived class_func0];    // expected-warning {{class method '+class_func0' not found (return type defaults to 'id')}}59   return i + (size_t)[Object class_func0];  // expected-warning {{class method '+class_func0' not found (return type defaults to 'id')}}60}61+ (int) class_func662{63   return (size_t)[objc_getClass("Object") class_func1]; // GCC warns about this64}65+ (int) class_func766{67   return [objc_getClass("Derived") class_func1];68}69- (int) instance_func170{71   int i = (size_t)[self instance_func0];     // expected-warning {{instance method '-instance_func0' not found (return type defaults to 'id'); did you mean}}72   return i + (size_t)[super instance_func0]; // expected-warning {{'Object' may not respond to 'instance_func0'}}73}74- (int) instance_func275{76   return [(id <Func>)super instance_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}77}78- (int) instance_func379{80   return [(Object <Func> *)super instance_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}81}82- (int) instance_func483{84   return [(Derived <Func> *)super instance_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}85}   86- (int) instance_func587{88   int i = (size_t)[Derived instance_func1]; // expected-warning {{class method '+instance_func1' not found (return type defaults to 'id')}} 89   return i + (size_t)[Object instance_func1]; // expected-warning {{class method '+instance_func1' not found (return type defaults to 'id')}}90}91- (int) instance_func692{93   return (size_t)[objc_getClass("Object") class_func1];94}95- (int) instance_func796{97   return [objc_getClass("Derived") class_func1];98}99- (id) initWithInt: (int) i100{101   // Don't warn about parentheses here.102   if (self = [super initWithInt: i]) {103     [self instance_func1];104   }105   return self;106}107@end108 109@class C;110@interface A // expected-note {{receiver is instance of class declared here}}111- (instancetype)initWithCoder:(A *)coder;112@end113 114@interface B : A115@end116 117@implementation B118- (instancetype)initWithCoder:(C *)coder {     // expected-note {{'coder' declared here}}119  if (0 != (self = [super initWithCode:code])) // expected-error {{use of undeclared identifier 'code'}} expected-warning {{instance method '-initWithCode:' not found}}120    return (void *)0;121  return (void *)0;122}123@end124