(root)/
gcc-13.2.0/
gcc/
testsuite/
c-c++-common/
Wimplicit-fallthrough-39.c
       1  /* PR middle-end/103597 */
       2  /* { dg-do compile } */
       3  /* { dg-options "-Wimplicit-fallthrough" } */
       4  
       5  #define E(c, e) if (c) e
       6  
       7  int
       8  fn0 (int n)
       9  {
      10    switch (n)
      11      {
      12      case 0:
      13        E (1, return 0);
      14      case 1:
      15        return -1;
      16      }
      17    return 0;
      18  }
      19  
      20  int
      21  fn1 (int n)
      22  {
      23    switch (n)
      24      {
      25      case 0:
      26        E (1, goto out);
      27      case 1:
      28        return -1;
      29      }
      30  out:
      31    return 0;
      32  }
      33  
      34  int
      35  fn2 (int n)
      36  {
      37    switch (n)
      38      {
      39      case 0:
      40        if (1)
      41         	n++;	  /* { dg-warning "statement may fall through" } */
      42      case 1:	  /* { dg-message "here" } */
      43        return -1;
      44      }
      45    return 0;
      46  }
      47  
      48  int
      49  fn3 (int n)
      50  {
      51    switch (n)
      52      {
      53      case 0:
      54        if (0)		/* { dg-warning "statement may fall through" } */
      55         	return 0;
      56      case 1:		/* { dg-message "here" } */
      57        return -1;
      58      }
      59    return 0;
      60  }
      61  
      62  int
      63  fn4 (int n)
      64  {
      65    switch (n)
      66      {
      67      case 0:
      68        E (0, n++);
      69        --n;	  /* { dg-warning "statement may fall through" } */
      70      case 1:	  /* { dg-message "here" } */
      71        return -1;
      72      }
      73    return 0;
      74  }
      75  
      76  int
      77  fn5 (int n)
      78  {
      79    switch (n)
      80      {
      81      case 0:
      82        if (1)
      83  	return 0;
      84        else
      85  	return -1;
      86      case 1:
      87        return -1;
      88      }
      89    return 0;
      90  }
      91  
      92  int
      93  fn6 (int n)
      94  {
      95    switch (n)
      96      {
      97      case 0:
      98        if (1)
      99  	return 0;
     100        else
     101  	{
     102  meow:
     103  	  n--;  /* { dg-warning "statement may fall through" } */
     104  	}
     105      case 1:   /* { dg-message "here" } */
     106        return -1;
     107      case 2:
     108        goto meow;
     109      }
     110    return 0;
     111  }
     112  
     113  int
     114  fn7 (int n)
     115  {
     116    switch (n)
     117      {
     118      case 0:
     119        if (1)
     120         	return 0;
     121  woof:
     122      case 1:
     123        return -1;
     124      }
     125    return 0;
     126  }
     127  
     128  int
     129  fn8 (int n)
     130  {
     131    switch (n)
     132      {
     133      case 0:
     134        if (1) n++; /* { dg-warning "statement may fall through" } */
     135  woof:		  /* { dg-message "here" } */
     136      case 1:
     137        return -1;
     138      }
     139    return 0;
     140  }