(root)/
gcc-13.2.0/
gcc/
testsuite/
c-c++-common/
attr-fallthrough-1.c
       1  /* PR c/7652 */
       2  /* { dg-do compile } */
       3  /* { dg-options "-Wall -Wextra -Wpedantic" } */
       4  
       5  extern void bar (int);
       6  void
       7  fn (int i)
       8  {
       9    __attribute__((fallthrough)) int j = 0; /* { dg-warning "ignored|attribute not followed" } */
      10  
      11    if (j)
      12      __attribute__((fallthrough));  /* { dg-error "invalid use" } */
      13  
      14    __attribute__((fallthrough));  /* { dg-error "invalid use" } */
      15    switch (i)
      16    {
      17      __attribute__((fallthrough)); /* { dg-warning "statement will never" } */
      18    case 1:
      19     i++;
      20     __attribute__((fallthrough));
      21    case 2:
      22      if (i) /* { dg-warning "statement may fall through" } */
      23        bar (2);
      24      else
      25        __attribute__((fallthrough));
      26    case 3:
      27      if (i > 1)
      28        __attribute__((fallthrough));
      29      else
      30        return;
      31    case 4:
      32      if (i)
      33        __attribute__((fallthrough)); /* { dg-warning "not preceding" } */
      34      __attribute__((fallthrough));
      35    case 5:
      36     ;
      37     __attribute__((fallthrough));
      38    case 6:
      39      if (i) /* { dg-warning "statement may fall through" } */
      40        bar (6);
      41      else
      42        {
      43  	__attribute__((fallthrough));
      44        }
      45    case 7:
      46      if (i > 1)
      47        {
      48  	__attribute__((fallthrough));
      49        }
      50      else
      51        bar (7); /* { dg-warning "statement may fall through" } */
      52    default:
      53      --j;
      54    }
      55  
      56    __attribute__((fallthrough)); /* { dg-error "invalid use" } */
      57  }