]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/c2x-attr-fallthrough-5.c
c614ceba2056b278e5dfdc9cb7fef27f5733960e
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / c2x-attr-fallthrough-5.c
1 /* Test C2x fallthrough attribute: mixtures with other attributes. */
2 /* { dg-do compile } */
3 /* { dg-options "-std=c2x -pedantic-errors" } */
4
5 /* Use of other standard attributes together with "fallthrough" goes
6 through a different path to diagnosing ignored attributes from that
7 used in attribute declarations without "fallthrough". Verify that
8 such ignored attributes result in a pedwarn (for use in a context
9 not permitted in the constraints for those attributes) in this case
10 as well. */
11
12 int
13 f (int a)
14 {
15 switch (a)
16 {
17 case 1:
18 a++;
19 [[fallthrough, deprecated]]; /* { dg-error "attribute ignored" } */
20 case 2:
21 a++;
22 [[maybe_unused]] [[fallthrough]]; /* { dg-error "attribute ignored" } */
23 case 3:
24 a++;
25 [[__nodiscard__, fallthrough]]; /* { dg-error "attribute ignored" } */
26 case 4:
27 a++;
28 }
29 return a;
30 }