brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · c769005 Raw
119 lines · plain
1// RUN: %clang_cc1 -fsyntax-only -Wno-default-const-init-unsafe -verify -Wno-objc-root-class %s2 3typedef struct objc_object {4  Class isa;5} *id;6 7 8@interface foo9- (void)meth;10@end11 12@implementation foo13- (void) contents {}			// No declaration in @interface!14- (void) meth { [self contents]; } 15@end16 17typedef struct _NSPoint {18    float x;19    float y;20} NSPoint;21 22typedef struct _NSSize {23    float width; 24    float height;25} NSSize;26 27typedef struct _NSRect {28    NSPoint origin;29    NSSize size;30} NSRect;31 32@interface AnyClass33- (NSRect)rect;34@end35 36@class Helicopter;37 38static void func(Helicopter *obj) {39  // Note that the proto for "rect" is found in the global pool even when40  // a statically typed object's class interface isn't in scope! This 41  // behavior isn't very desirable, however wee need it for GCC compatibility.42  NSRect r = [obj rect];43}44 45@interface NSObject @end46 47extern Class NSClassFromObject(id object);48 49@interface XX : NSObject 50@end51 52@implementation XX53 54+ _privateMethod {55  return self;56}57 58- (void) xx {59  [NSClassFromObject(self) _privateMethod];60}61@end62 63@implementation XX (Private)64- (void) yy {65  [NSClassFromObject(self) _privateMethod];66}67@end68 69@interface I070-(void) nonVararg: (int) x;71@end72 73int f0(I0 *ob) {74  [ ob nonVararg: 0, 1, 2]; // expected-error {{too many arguments to method call}}75}76 77int f2(void) {78    const id foo;79    [foo bar];  // expected-warning {{method '-bar' not found (return type defaults to 'id')}}80    return 0;81}82 83 84// PR376685struct S { int X; } S;86 87int test5(int X) {88  int a = [X somemsg];  // expected-warning {{receiver type 'int' is not 'id'}} \89                           expected-warning {{method '-somemsg' not found}} \90                           expected-error {{incompatible pointer to integer conversion initializing 'int' with an expression of type 'id'}}91  int b = [S somemsg];  // expected-error {{bad receiver type 'struct S'}}92}93 94// PR402195void foo4(void) {96  struct objc_object X[10];97  98  [X rect]; // expected-warning {{receiver type 'struct objc_object *' is not 'id' or interface pointer, consider casting it to 'id'}}99}100 101void foo5(id p) {102  p103  [(id)(p) bar]; // expected-error {{missing '['}} \104                 // expected-error {{expected ']'}} \105                 // expected-note {{to match this '['}} \106                 // expected-warning {{instance method '-bar' not found}}107}108 109@interface I1 // expected-note {{receiver is instance of class declared here}}110-(void)unavail_meth  __attribute__((unavailable)); // expected-note {{marked unavailable here}}111@end112 113void foo6(I1 *p) {114  [p115    bar]; // expected-warning {{instance method '-bar' not found}}116  [p117    unavail_meth]; // expected-error {{unavailable}}118}119