aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/c2x-attr-fallthrough-6.c
blob: 0984d6769b48665220c98c5e41719ac8b87c8fca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/* Test C23 attribute syntax.  Invalid use of fallthrough attribute in
   bad context inside switch.  */
/* { dg-do compile } */
/* { dg-options "-std=c23 -pedantic-errors -Wextra" } */

int
f (int a)
{
  switch (a)
    {
    case 1:
      a++;
      [[fallthrough]]; /* { dg-error "attribute 'fallthrough' not preceding a case label or default label" } */
      a++;
      [[fallthrough]]; /* { dg-error "attribute 'fallthrough' not preceding a case label or default label" } */
    }
  return a;
}