Home | History | Annotate | Download | only in SemaObjC
      1 // RUN: %clang_cc1 -fsyntax-only -verify -fobjc-exceptions -Wno-objc-root-class %s
      2 
      3 @class A, B, C;
      4 
      5 void test1() {
      6   goto L; // expected-error{{goto into protected scope}}
      7   goto L2; // expected-error{{goto into protected scope}}
      8   goto L3; // expected-error{{goto into protected scope}}
      9   @try {   // expected-note {{jump bypasses initialization of @try block}}
     10 L: ;
     11   } @catch (A *x) { // expected-note {{jump bypasses initialization of @catch block}}
     12 L2: ;
     13   } @catch (B *x) {
     14   } @catch (C *c) {
     15   } @finally {// expected-note {{jump bypasses initialization of @finally block}}
     16 L3: ;
     17   }
     18   
     19   @try {
     20     goto L4; // expected-error{{goto into protected scope}}
     21     goto L5; // expected-error{{goto into protected scope}}
     22   } @catch (C *c) { // expected-note {{jump bypasses initialization of @catch block}}
     23   L5: ;
     24     goto L6; // expected-error{{goto into protected scope}}
     25   } @catch (B *c) { // expected-note {{jump bypasses initialization of @catch block}}
     26   L6: ;
     27   } @finally { // expected-note {{jump bypasses initialization of @finally block}}
     28   L4: ;
     29   }
     30  
     31   
     32   @try { // expected-note 2 {{jump bypasses initialization of @try block}}
     33   L7: ;
     34   } @catch (C *c) {
     35     goto L7; // expected-error{{goto into protected scope}}
     36   } @finally {
     37     goto L7; // expected-error{{goto into protected scope}}
     38   }
     39   
     40   goto L8;  // expected-error{{goto into protected scope}}
     41   @try { 
     42   } @catch (A *c) {
     43   } @catch (B *c) {
     44   } @catch (C *c) { // expected-note {{jump bypasses initialization of @catch block}}
     45   L8: ;
     46   }
     47   
     48   // rdar://6810106
     49   id X;
     50   goto L9;    // expected-error{{goto into protected scope}}
     51   goto L10;   // ok
     52   @synchronized    // expected-note {{jump bypasses initialization of @synchronized block}}
     53   ( ({ L10: ; X; })) {
     54   L9:
     55     ;
     56   }
     57 }
     58 
     59 void test2(int a) {
     60   if (a) goto L0;
     61   @try {} @finally {}
     62  L0:
     63   return;
     64 }
     65 
     66 // rdar://6803963
     67 void test3() {
     68   @try {
     69     goto blargh;
     70   blargh: ;
     71   } @catch (...) {}
     72 }
     73 
     74 @interface Greeter
     75 + (void) hello;
     76 @end
     77 
     78 @implementation Greeter
     79 + (void) hello {
     80 
     81   @try {
     82     goto blargh;     // expected-error {{goto into protected scope}}
     83   } @catch (...) {   // expected-note {{jump bypasses initialization of @catch block}}
     84   blargh: ;
     85   }
     86 }
     87 
     88 + (void)meth2 {
     89     int n; void *P;
     90     goto L0;     // expected-error {{goto into protected scope}}
     91     typedef int A[n];  // expected-note {{jump bypasses initialization of VLA typedef}}
     92   L0:
     93     
     94     goto L1;      // expected-error {{goto into protected scope}}
     95     A b, c[10];        // expected-note 2 {{jump bypasses initialization of variable length array}}
     96   L1:
     97     goto L2;     // expected-error {{goto into protected scope}}
     98     A d[n];      // expected-note {{jump bypasses initialization of variable length array}}
     99   L2:
    100     return;
    101 }
    102 
    103 @end
    104