brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.0 KiB · 8854b1c Raw
154 lines · plain
1// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s2 3@interface Test {4   int x;5}6 7-(void) setX: (int) d;8@end9 10extern struct foo x;11 12@implementation Test13 14-(void) setX: (int) n {15   x = n;16}17 18@end19 20@interface Ivar21- (float*)method;22@end23 24@interface A {25  A *Ivar;26}27- (int*)method;28@end29 30@implementation A31- (int*)method {32  int *ip = [Ivar method]; // expected-error{{incompatible pointer types initializing 'int *' with an expression of type 'float *'}}33                           // Note that there is no warning in Objective-C++34  return 0;35}36@end37 38@interface TwoIvars {39  int a;40  int b;41}42@end43 44@implementation TwoIvars45+ (int)classMethod {46  return a + b; // expected-error{{instance variable 'a' accessed in class method}} \47  // expected-error{{instance variable 'b' accessed in class method}}48}49@end50 51@interface Radar1030945452{53  int IVAR; // expected-note 4 {{previous definition is here}}54}55@end56 57@interface Radar10309454()58{59  int IVAR; // expected-error {{instance variable is already declared}}60  int PIVAR; // expected-note {{previous definition is here}}61}62@end63 64@interface Radar10309454()65{66  int IVAR; // expected-error {{instance variable is already declared}}67}68@end69 70@interface Radar10309454()71{72  int IVAR; // expected-error {{instance variable is already declared}}73  int PIVAR; // expected-error {{instance variable is already declared}}74}75@end76 77@implementation Radar1030945478{79  int IVAR; // expected-error {{instance variable is already declared}}80}81@end82 83// PR598484@interface Radar14037151 {85  int myStatus;86}87- (int) test;88@end89 90@implementation Radar1403715191- (int) test92{93  myStatus = 1;     // works94   __typeof(myStatus) __in;  // works.95  union U {96    __typeof(myStatus) __in;  // fails.97  };98  struct S { // expected-note{{previous definition is here}}99    __typeof(myStatus) __in;  // fails.100    struct S1 { // expected-warning {{declaration does not declare anything}}101      __typeof(myStatus) __in;  // fails.102      struct S { // expected-error {{nested redefinition of 'S'}}103        __typeof(myStatus) __in;  // fails.104      };105    };106  };107 108  return 0;109}110@end111 112@class NSString, NSData, NSNumber;113 114@interface NSObject115{116  Class isa;117}118@end119 120@interface Foo121{122  int a;123  NSString* b;124  NSData* c;125}126@end127 128@interface Bar : Foo129@end130 131@interface Bar () {132	NSString *q_strong;133	NSNumber *r_strong;134	int d; // expected-note {{previous definition is here}}135	NSString *e_strong; // expected-note {{previous definition is here}}136	NSData *f_weak; // expected-note {{previous definition is here}}137	int g; // expected-note 2 {{previous definition is here}}138}139@end140 141@interface Bar () {142	int g; // expected-note {{previous definition is here}} \143               // expected-error {{instance variable is already declared}}144}145@end146 147@implementation Bar {148	int d; // expected-error {{instance variable is already declared}}149	NSString *e_strong; // expected-error {{instance variable is already declared}}150	NSData *f_weak; // expected-error {{instance variable is already declared}}151	NSData *g; // expected-error 2 {{instance variable is already declared}}152}153@end154