reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.10 -fsyntax-only -verify -fobjc-exceptions -Wno-objc-root-class %s

@class A, B, C;

void test1() {
  goto L; // expected-error{{cannot jump}}
  goto L2; // expected-error{{cannot jump}}
  goto L3; // expected-error{{cannot jump}}
  @try {   // expected-note {{jump bypasses initialization of @try block}}
L: ;
  } @catch (A *x) { // expected-note {{jump bypasses initialization of @catch block}}
L2: ;
  } @catch (B *x) {
  } @catch (C *c) {
  } @finally {// expected-note {{jump bypasses initialization of @finally block}}
L3: ;
  }
  
  @try {
    goto L4; // expected-error{{cannot jump}}
    goto L5; // expected-error{{cannot jump}}
  } @catch (C *c) { // expected-note {{jump bypasses initialization of @catch block}}
  L5: ;
    goto L6; // expected-error{{cannot jump}}
  } @catch (B *c) { // expected-note {{jump bypasses initialization of @catch block}}
  L6: ;
  } @finally { // expected-note {{jump bypasses initialization of @finally block}}
  L4: ;
  }
 
  
  @try { // expected-note 2 {{jump bypasses initialization of @try block}}
  L7: ;
  } @catch (C *c) {
    goto L7; // expected-error{{cannot jump}}
  } @finally {
    goto L7; // expected-error{{cannot jump}}
  }
  
  goto L8;  // expected-error{{cannot jump}}
  @try { 
  } @catch (A *c) {
  } @catch (B *c) {
  } @catch (C *c) { // expected-note {{jump bypasses initialization of @catch block}}
  L8: ;
  }
  
  // rdar://6810106
  id X;
  goto L9;    // expected-error{{cannot jump}}
  goto L10;   // ok
  @synchronized    // expected-note {{jump bypasses initialization of @synchronized block}}
  ( ({ L10: ; X; })) {
  L9:
    ;
  }
}

void test2(int a) {
  if (a) goto L0;
  @try {} @finally {}
 L0:
  return;
}

// rdar://6803963
void test3() {
  @try {
    goto blargh;
  blargh: ;
  } @catch (...) {}
}

@interface Greeter
+ (void) hello;
@end

@implementation Greeter
+ (void) hello {

  @try {
    goto blargh;     // expected-error {{cannot jump}}
  } @catch (...) {   // expected-note {{jump bypasses initialization of @catch block}}
  blargh: ;
  }
}

+ (void)meth2 {
    int n; void *P;
    goto L0;     // expected-error {{cannot jump}}
    typedef int A[n];  // expected-note {{jump bypasses initialization of VLA typedef}}
  L0:
    
    goto L1;      // expected-error {{cannot jump}}
    A b, c[10];        // expected-note 2 {{jump bypasses initialization of variable length array}}
  L1:
    goto L2;     // expected-error {{cannot jump}}
    A d[n];      // expected-note {{jump bypasses initialization of variable length array}}
  L2:
    return;
}

@end