Home | History | Annotate | Download | only in SemaObjC
      1 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
      2 
      3 @interface Test {
      4    int x;
      5 }
      6 
      7 -(void) setX: (int) d;
      8 @end
      9 
     10 extern struct foo x;
     11 
     12 @implementation Test
     13 
     14 -(void) setX: (int) n {
     15    x = n;
     16 }
     17 
     18 @end
     19 
     20 @interface Ivar
     21 - (float*)method;
     22 @end
     23 
     24 @interface A {
     25   A *Ivar;
     26 }
     27 - (int*)method;
     28 @end
     29 
     30 @implementation A
     31 - (int*)method {
     32   int *ip = [Ivar method]; // expected-warning{{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 @end
     37 
     38 @interface TwoIvars {
     39   int a;
     40   int b;
     41 }
     42 @end
     43 
     44 @implementation TwoIvars
     45 + (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 @end
     50 
     51 // rdar://10309454
     52 @interface Radar10309454
     53 {
     54   int IVAR; // expected-note 4 {{previous definition is here}}
     55 }
     56 @end
     57 
     58 @interface Radar10309454()
     59 {
     60   int IVAR; // expected-error {{instance variable is already declared}}
     61   int PIVAR; // expected-note {{previous definition is here}}
     62 }
     63 @end
     64 
     65 @interface Radar10309454()
     66 {
     67   int IVAR; // expected-error {{instance variable is already declared}}
     68 }
     69 @end
     70 
     71 @interface Radar10309454()
     72 {
     73   int IVAR; // expected-error {{instance variable is already declared}}
     74   int PIVAR; // expected-error {{instance variable is already declared}}
     75 }
     76 @end
     77 
     78 @implementation Radar10309454
     79 {
     80   int IVAR; // expected-error {{instance variable is already declared}}
     81 }
     82 @end
     83