(root)/
gcc-13.2.0/
gcc/
testsuite/
c-c++-common/
Wimplicit-fallthrough-4.c
       1  /* PR c/7652 */
       2  /* { dg-do compile } */
       3  /* { dg-options "-Wimplicit-fallthrough" } */
       4  
       5  extern void bar (int);
       6  
       7  /* Test if with more elses.  */
       8  
       9  void
      10  f (int i)
      11  {
      12    switch (i)
      13      {
      14      case 1:
      15        if (i > 5) /* { dg-warning "statement may fall through" } */
      16          bar (1);
      17        else if (i > 10)
      18  	bar (2);
      19        else if (i > 15)
      20  	bar (3);
      21      case 2:
      22        __builtin_abort ();
      23      }
      24  
      25    switch (i)
      26      {
      27      case 1:
      28        if (i > 5) /* { dg-warning "statement may fall through" } */
      29  	bar (1);
      30        else if (i > 10)
      31  	bar (2);
      32        else if (i > 15)
      33  	bar (3);
      34        else
      35  	bar (4);
      36      case 2:
      37        __builtin_abort ();
      38      }
      39  
      40    switch (i)
      41      {
      42      case 1:
      43        if (i > 5)
      44          return;
      45        else if (i > 10) /* { dg-warning "statement may fall through" } */
      46  	bar (2);
      47        else if (i > 15)
      48  	bar (3);
      49      case 2:
      50        __builtin_abort ();
      51      }
      52  
      53    switch (i)
      54      {
      55      case 1:
      56        if (i > 5)
      57          return;
      58        else if (i > 10) /* { dg-warning "statement may fall through" } */
      59  	bar (2);
      60        else if (i > 15)
      61  	bar (3);
      62        else
      63  	bar (4);
      64      case 2:
      65        __builtin_abort ();
      66      }
      67  
      68    switch (i)
      69      {
      70      case 1:
      71        if (i > 5) /* { dg-warning "statement may fall through" } */
      72          bar (1);
      73        else if (i > 10)
      74  	return;
      75        else if (i > 15)
      76  	bar (3);
      77      case 2:
      78        __builtin_abort ();
      79      }
      80  
      81    switch (i)
      82      {
      83      case 1:
      84        if (i > 5) /* { dg-warning "statement may fall through" } */
      85          bar (1);
      86        else if (i > 10)
      87  	return;
      88        else if (i > 15)
      89  	bar (3);
      90        else
      91  	bar (4);
      92      case 2:
      93        __builtin_abort ();
      94      }
      95  
      96    switch (i)
      97      {
      98      case 1:
      99        if (i > 5) /* { dg-warning "statement may fall through" } */
     100          bar (1);
     101        else if (i > 10)
     102  	bar (4);
     103        else if (i > 15)
     104  	return;
     105      case 2:
     106        __builtin_abort ();
     107      }
     108  
     109    switch (i)
     110      {
     111      case 1:
     112        if (i > 5) /* { dg-warning "statement may fall through" } */
     113          bar (1);
     114        else if (i > 10)
     115  	bar (4);
     116        else if (i > 15)
     117  	return;
     118        else
     119  	bar (4);
     120      case 2:
     121        __builtin_abort ();
     122      }
     123  
     124    switch (i)
     125      {
     126      case 1:
     127        if (i > 5)
     128          return;
     129        else if (i > 10)
     130  	return;
     131        else if (i > 15) /* { dg-warning "statement may fall through" } */
     132  	bar (3);
     133      case 2:
     134        __builtin_abort ();
     135      }
     136  
     137    switch (i)
     138      {
     139      case 1:
     140        if (i > 5)
     141          return;
     142        else if (i > 10)
     143  	return;
     144        else if (i > 15) /* { dg-warning "statement may fall through" } */
     145  	bar (3);
     146        else
     147  	bar (4);
     148      case 2:
     149        __builtin_abort ();
     150      }
     151  
     152    switch (i)
     153      {
     154      case 1:
     155        if (i > 5)
     156          return;
     157        else if (i > 10) /* { dg-warning "statement may fall through" } */
     158  	bar (2);
     159        else if (i > 15)
     160  	return;
     161      case 2:
     162        __builtin_abort ();
     163      }
     164  
     165    switch (i)
     166      {
     167      case 1:
     168        if (i > 5)
     169          return;
     170        else if (i > 10) /* { dg-warning "statement may fall through" } */
     171  	bar (2);
     172        else if (i > 15)
     173  	return;
     174        else
     175  	bar (4);
     176      case 2:
     177        __builtin_abort ();
     178      }
     179  
     180    switch (i)
     181      {
     182      case 1:
     183        if (i > 5) /* { dg-warning "statement may fall through" } */
     184          bar (1);
     185        else if (i > 10)
     186  	return;
     187        else if (i > 15)
     188  	return;
     189      case 2:
     190        __builtin_abort ();
     191      }
     192  
     193    switch (i)
     194      {
     195      case 1:
     196        if (i > 5) /* { dg-warning "statement may fall through" } */
     197          bar (1);
     198        else if (i > 10)
     199  	return;
     200        else if (i > 15)
     201  	return;
     202        else
     203  	bar (4);
     204      case 2:
     205        __builtin_abort ();
     206      }
     207  
     208    switch (i)
     209      {
     210      case 1:
     211        if (i > 5)
     212         return;
     213        else if (i > 10)
     214  	return;
     215        else if (i > 15) /* { dg-warning "statement may fall through" } */
     216  	return;
     217      case 2:
     218        __builtin_abort ();
     219      }
     220  
     221    switch (i)
     222      {
     223      case 1:
     224        if (i > 5)
     225         return;
     226        else if (i > 10)
     227  	return;
     228        else if (i > 15)
     229  	return;
     230        else
     231  	bar (4); /* { dg-warning "statement may fall through" } */
     232      case 2:
     233        __builtin_abort ();
     234      }
     235  
     236    switch (i)
     237      {
     238      case 1:
     239        if (i > 5)
     240         return;
     241        else if (i > 10)
     242  	return;
     243        else if (i > 15)
     244  	return;
     245        else
     246  	return;
     247      case 2:
     248        __builtin_abort ();
     249      }
     250  }