| 1 |
// RUN: %clang_cc1 -std=c++20 -verify -fsyntax-only -fnamed-loops %s |
| 2 |
|
| 3 |
int a[10]{}; |
| 4 |
struct S { |
| 5 |
int a[10]{}; |
| 6 |
}; |
| 7 |
|
| 8 |
void f1() { |
| 9 |
l1: for (int x : a) { |
| 10 |
break l1; |
| 11 |
continue l1; |
| 12 |
} |
| 13 |
|
| 14 |
l2: for (int x : a) { |
| 15 |
break l1; // expected-error {{'break' label does not name an enclosing loop or 'switch'}} |
| 16 |
continue l1; // expected-error {{'continue' label does not name an enclosing loop}} |
| 17 |
} |
| 18 |
|
| 19 |
l3: for (int x : a) { |
| 20 |
l4: for (int x : a) { |
| 21 |
break l3; |
| 22 |
break l4; |
| 23 |
continue l3; |
| 24 |
continue l4; |
| 25 |
} |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
void f2() { |
| 30 |
l1: for ( |
| 31 |
int x = ({ |
| 32 |
break l1; // expected-error {{'break' label does not name an enclosing loop or 'switch'}} |
| 33 |
continue l1; // expected-error {{'continue' label does not name an enclosing loop}} |
| 34 |
1; |
| 35 |
}); |
| 36 |
int y : ({ |
| 37 |
break l1; // expected-error {{'break' label does not name an enclosing loop or 'switch'}} |
| 38 |
continue l1; // expected-error {{'continue' label does not name an enclosing loop}} |
| 39 |
S(); |
| 40 |
}).a |
| 41 |
) {} |
| 42 |
} |
| 43 |
|
| 44 |
void f3() { |
| 45 |
a: while (true) { |
| 46 |
(void) []{ |
| 47 |
break a; // expected-error {{'break' label does not name an enclosing loop or 'switch'}} |
| 48 |
continue a; // expected-error {{'continue' label does not name an enclosing loop}} |
| 49 |
}; |
| 50 |
} |
| 51 |
} |