| 1 |
// P2324R2 - Labels at the end of compound statements |
| 2 |
// PR c++/103539 |
| 3 |
// { dg-do compile { target c++23 } } |
| 4 |
// Test bad cases. |
| 5 |
|
| 6 |
void |
| 7 |
fn1 () |
| 8 |
{ |
| 9 |
/* A selection-statement wants a statement, but a mere label isn't a statement. */ |
| 10 |
if (1) |
| 11 |
lab: |
| 12 |
} // { dg-error "expected" } |
| 13 |
|
| 14 |
void |
| 15 |
fn2 () |
| 16 |
{ |
| 17 |
if (0) |
| 18 |
{ |
| 19 |
} |
| 20 |
else |
| 21 |
lab: |
| 22 |
} // { dg-error "expected" } |
| 23 |
|
| 24 |
void |
| 25 |
fn3 () |
| 26 |
{ |
| 27 |
do |
| 28 |
lab: |
| 29 |
while (0); // { dg-error "expected" } |
| 30 |
} // { dg-error "expected" } |
| 31 |
|
| 32 |
void |
| 33 |
fn4 () |
| 34 |
{ |
| 35 |
for (;;) |
| 36 |
lab: |
| 37 |
} // { dg-error "expected" } |
| 38 |
|
| 39 |
void |
| 40 |
fn5 () |
| 41 |
{ |
| 42 |
switch (1) |
| 43 |
lab: |
| 44 |
} // { dg-error "expected" } |
| 45 |
|
| 46 |
void |
| 47 |
fn6 () |
| 48 |
{ |
| 49 |
if (1) |
| 50 |
lab1: |
| 51 |
lab2: |
| 52 |
} // { dg-error "expected" } |