blob: c614ceba2056b278e5dfdc9cb7fef27f5733960e (
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
|
/* Test C2x fallthrough attribute: mixtures with other attributes. */
/* { dg-do compile } */
/* { dg-options "-std=c2x -pedantic-errors" } */
/* Use of other standard attributes together with "fallthrough" goes
through a different path to diagnosing ignored attributes from that
used in attribute declarations without "fallthrough". Verify that
such ignored attributes result in a pedwarn (for use in a context
not permitted in the constraints for those attributes) in this case
as well. */
int
f (int a)
{
switch (a)
{
case 1:
a++;
[[fallthrough, deprecated]]; /* { dg-error "attribute ignored" } */
case 2:
a++;
[[maybe_unused]] [[fallthrough]]; /* { dg-error "attribute ignored" } */
case 3:
a++;
[[__nodiscard__, fallthrough]]; /* { dg-error "attribute ignored" } */
case 4:
a++;
}
return a;
}
|