| 1 |
/* PR c/79153 */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
/* { dg-options "-Wimplicit-fallthrough" } */ |
| 4 |
|
| 5 |
int |
| 6 |
test (int v1, int v2) |
| 7 |
{ |
| 8 |
switch (v1) |
| 9 |
{ |
| 10 |
case 3: |
| 11 |
switch (v2) /* { dg-warning "this statement may fall through" } */ |
| 12 |
{ |
| 13 |
case 1: |
| 14 |
return 28; |
| 15 |
case 2: |
| 16 |
return 38; |
| 17 |
case 3: |
| 18 |
return 88; |
| 19 |
default: |
| 20 |
break; |
| 21 |
} |
| 22 |
case 4: /* { dg-message "here" } */ |
| 23 |
return 168; |
| 24 |
case 5: |
| 25 |
switch (v2) /* { dg-warning "this statement may fall through" } */ |
| 26 |
{ |
| 27 |
case 4: |
| 28 |
break; |
| 29 |
case 5: |
| 30 |
return 38; |
| 31 |
case 6: |
| 32 |
return 88; |
| 33 |
} |
| 34 |
case 6: /* { dg-message "here" } */ |
| 35 |
return 169; |
| 36 |
case 7: |
| 37 |
switch (v2) /* { dg-warning "this statement may fall through" } */ |
| 38 |
{ |
| 39 |
case 7: |
| 40 |
return 38; |
| 41 |
case 8: |
| 42 |
return 88; |
| 43 |
} |
| 44 |
case 8: /* { dg-message "here" } */ |
| 45 |
return 170; |
| 46 |
case 9: |
| 47 |
switch (v2) /* { dg-bogus "this statement may fall through" } */ |
| 48 |
{ |
| 49 |
case 9: |
| 50 |
return 38; |
| 51 |
case 10: |
| 52 |
return 88; |
| 53 |
default: |
| 54 |
return 89; |
| 55 |
} |
| 56 |
case 10: |
| 57 |
return 171; |
| 58 |
case 11: |
| 59 |
switch (v2) /* { dg-bogus "this statement may fall through" } */ |
| 60 |
{ |
| 61 |
case -__INT_MAX__ - 1 ... 31: |
| 62 |
return 38; |
| 63 |
case 32: |
| 64 |
return 88; |
| 65 |
case 33 ... __INT_MAX__: |
| 66 |
return 89; |
| 67 |
} |
| 68 |
case 12: |
| 69 |
return 172; |
| 70 |
} |
| 71 |
return -1; |
| 72 |
} |