1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify %s -fblocks 2*67e74705SXin Li test_gotos()3*67e74705SXin Livoid test_gotos() { 4*67e74705SXin Li goto L1; // expected-error {{use of undeclared label 'L1'}} 5*67e74705SXin Li goto L3; // OK 6*67e74705SXin Li #pragma clang __debug captured 7*67e74705SXin Li { 8*67e74705SXin Li L1: 9*67e74705SXin Li goto L2; // OK 10*67e74705SXin Li L2: 11*67e74705SXin Li goto L3; // expected-error {{use of undeclared label 'L3'}} 12*67e74705SXin Li } 13*67e74705SXin Li L3: ; 14*67e74705SXin Li } 15*67e74705SXin Li test_break_continue()16*67e74705SXin Livoid test_break_continue() { 17*67e74705SXin Li while (1) { 18*67e74705SXin Li #pragma clang __debug captured 19*67e74705SXin Li { 20*67e74705SXin Li break; // expected-error {{'break' statement not in loop or switch statement}} 21*67e74705SXin Li continue; // expected-error {{'continue' statement not in loop statement}} 22*67e74705SXin Li } 23*67e74705SXin Li } 24*67e74705SXin Li } 25*67e74705SXin Li test_return()26*67e74705SXin Livoid test_return() { 27*67e74705SXin Li while (1) { 28*67e74705SXin Li #pragma clang __debug captured 29*67e74705SXin Li { 30*67e74705SXin Li return; // expected-error {{cannot return from default captured statement}} 31*67e74705SXin Li } 32*67e74705SXin Li } 33*67e74705SXin Li } 34*67e74705SXin Li test_nest()35*67e74705SXin Livoid test_nest() { 36*67e74705SXin Li int x; 37*67e74705SXin Li #pragma clang __debug captured 38*67e74705SXin Li { 39*67e74705SXin Li int y; 40*67e74705SXin Li #pragma clang __debug captured 41*67e74705SXin Li { 42*67e74705SXin Li int z; 43*67e74705SXin Li #pragma clang __debug captured 44*67e74705SXin Li { 45*67e74705SXin Li x = z = y; // OK 46*67e74705SXin Li } 47*67e74705SXin Li } 48*67e74705SXin Li } 49*67e74705SXin Li } 50*67e74705SXin Li test_nest_block()51*67e74705SXin Livoid test_nest_block() { 52*67e74705SXin Li __block int x; // expected-note {{'x' declared here}} 53*67e74705SXin Li int y; 54*67e74705SXin Li ^{ 55*67e74705SXin Li int z; 56*67e74705SXin Li #pragma clang __debug captured 57*67e74705SXin Li { 58*67e74705SXin Li x = y; // expected-error{{__block variable 'x' cannot be captured in a captured statement}} 59*67e74705SXin Li y = z; // expected-error{{variable is not assignable (missing __block type specifier)}} 60*67e74705SXin Li z = y; // OK 61*67e74705SXin Li } 62*67e74705SXin Li }(); 63*67e74705SXin Li 64*67e74705SXin Li __block int a; // expected-note 2 {{'a' declared here}} 65*67e74705SXin Li int b; 66*67e74705SXin Li #pragma clang __debug captured 67*67e74705SXin Li { 68*67e74705SXin Li __block int c; 69*67e74705SXin Li int d; 70*67e74705SXin Li ^{ 71*67e74705SXin Li a = b; // expected-error{{__block variable 'a' cannot be captured in a captured statement}} 72*67e74705SXin Li b = d; // OK - Consistent with block inside a lambda 73*67e74705SXin Li c = a; // expected-error{{__block variable 'a' cannot be captured in a captured statement}} 74*67e74705SXin Li c = d; // OK 75*67e74705SXin Li d = b; // expected-error{{variable is not assignable (missing __block type specifier)}} 76*67e74705SXin Li }(); 77*67e74705SXin Li } 78*67e74705SXin Li } 79