Home | History | Annotate | Download | only in SemaObjC
      1 // RUN: %clang_cc1 -fobjc-runtime=macosx-10.8 -fsyntax-only -verify %s
      2 
      3 __attribute__((objc_root_class))
      4 @interface Root @end
      5 
      6 // These should not get diagnosed immediately.
      7 @interface A : Root {
      8   __weak id x;
      9 }
     10 @property __weak id y;
     11 @end
     12 
     13 // Diagnostic goes on the ivar if it's explicit.
     14 @interface B : Root {
     15   __weak id x;  // expected-error {{cannot create __weak reference in file using manual reference counting}}
     16 }
     17 @property __weak id x;
     18 @end
     19 @implementation B
     20 @synthesize x;
     21 @end
     22 
     23 // Otherwise, it goes with the @synthesize.
     24 @interface C : Root
     25 @property __weak id x; // expected-note {{property declared here}}
     26 @end
     27 @implementation C
     28 @synthesize x; // expected-error {{cannot synthesize weak property in file using manual reference counting}}
     29 @end
     30 
     31 @interface D : Root
     32 @property __weak id x; // expected-note {{property declared here}}
     33 @end
     34 @implementation D // expected-error {{cannot synthesize weak property in file using manual reference counting}}
     35 @end
     36 
     37 @interface E : Root {
     38 @public
     39   __weak id x; // expected-note 2 {{declaration uses __weak, but ARC is disabled}}
     40 }
     41 @end
     42 
     43 void testE(E *e) {
     44   id x = e->x; // expected-error {{'x' is unavailable}}
     45   e->x = x; // expected-error {{'x' is unavailable}}
     46 }
     47 
     48 @interface F : Root
     49 @property (weak) id x;
     50 @end
     51 
     52 void testF(F *f) {
     53   id x = f.x;
     54 }
     55