blob: 4c1364907f84ddd20e1ebb3352e3abc05810e628 (
plain)
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
|
/* Test C23 attribute syntax. Valid use of fallthrough attribute. */
/* { dg-do compile } */
/* { dg-options "-std=c23 -pedantic-errors -Wextra" } */
int
f (int a, int c)
{
int b = 2;
switch (a)
{
case 1:
b = 1; /* { dg-warning "may fall through" } */
case 2:
b = 2;
[[fallthrough]];
case 3:
b += 7;
break;
case 4:
b = 5;
[[__fallthrough__]];
case 5:
b += 1;
break;
case 6:
if (c == 2)
{
[[fallthrough]];
}
else
{
[[fallthrough]];
}
case 7:
b += 3;
[[fallthrough]];
default:
b += 8;
break;
}
return b;
}
|