1  /* PR c/7652 */
       2  /* { dg-do compile } */
       3  /* { dg-options "-Wimplicit-fallthrough" } */
       4  
       5  extern void bar (int);
       6  
       7  /* Test if with else.  */
       8  
       9  void
      10  f (int i)
      11  {
      12    switch (i)
      13      {
      14      case 1:
      15        if (i) /* { dg-warning "statement may fall through" } */
      16  	bar (1);
      17        else
      18  	bar (2);
      19      case 2:
      20        __builtin_abort ();
      21      }
      22  
      23    switch (i)
      24      {
      25      case 1:
      26        if (i)
      27  	bar (1);
      28        else
      29  	bar (2);
      30        bar (3); /* { dg-warning "statement may fall through" } */
      31      case 2:
      32        __builtin_abort ();
      33      }
      34  
      35    switch (i)
      36      {
      37      case 1:
      38        if (i)
      39          return;
      40        else
      41  	bar (2); /* { dg-warning "statement may fall through" } */
      42      case 2:
      43        __builtin_abort ();
      44      }
      45  
      46    switch (i)
      47      {
      48      case 1:
      49        if (i)
      50          return;
      51        else
      52  	bar (2);
      53        bar (3); /* { dg-warning "statement may fall through" } */
      54      case 2:
      55        __builtin_abort ();
      56      }
      57  
      58    switch (i)
      59      {
      60      case 1:
      61        if (i) /* { dg-warning "statement may fall through" } */
      62          bar (1);
      63        else
      64  	return;
      65      case 2:
      66        __builtin_abort ();
      67      }
      68  
      69    switch (i)
      70      {
      71      case 1:
      72        if (i)
      73  	bar (1);
      74        else
      75  	return;
      76        bar (3); /* { dg-warning "statement may fall through" } */
      77      case 2:
      78        __builtin_abort ();
      79      }
      80  
      81    switch (i)
      82      {
      83      case 1:
      84        if (i)
      85  	return;
      86        else
      87  	return;
      88      case 2:
      89        __builtin_abort ();
      90      }
      91  
      92    switch (i)
      93      {
      94      case 1:
      95        if (i)
      96  	return;
      97        else
      98  	return;
      99        bar (3); /* { dg-warning "statement may fall through" } */
     100      case 2:
     101        __builtin_abort ();
     102      }
     103  
     104    switch (i)
     105      {
     106      case 1:
     107        if (i) /* { dg-warning "statement may fall through" } */
     108  	{
     109            bar (1);
     110            bar (2);
     111            bar (3);
     112            bar (4);
     113  	}
     114        else
     115  	{
     116            bar (5);
     117            bar (6);
     118            bar (7);
     119            bar (8);
     120  	}
     121      case 2:
     122        __builtin_abort ();
     123      }
     124  
     125    switch (i)
     126      {
     127      case 1:
     128        if (i)
     129  	{
     130            bar (1);
     131            bar (2);
     132            bar (3);
     133            bar (4);
     134  	}
     135        else
     136  	{
     137            bar (5);
     138            bar (6);
     139            bar (7);
     140            bar (8);
     141  	}
     142        bar (9); /* { dg-warning "statement may fall through" } */
     143      case 2:
     144        __builtin_abort ();
     145      }
     146  
     147    switch (i)
     148      {
     149      case 1:
     150        if (i) /* { dg-warning "statement may fall through" } */
     151          {
     152  	}
     153        else
     154  	bar (2);
     155      case 2:
     156        __builtin_abort ();
     157      }
     158  
     159    switch (i)
     160      {
     161      case 1:
     162        if (i) /* { dg-warning "statement may fall through" } */
     163  	bar (1);
     164        else
     165  	{
     166  	}
     167      case 2:
     168        __builtin_abort ();
     169      }
     170  
     171    switch (i)
     172      {
     173      case 1:
     174        if (i) /* { dg-warning "statement may fall through" } */
     175  	{
     176  	}
     177        else
     178  	{
     179  	}
     180      case 2:
     181        __builtin_abort ();
     182      }
     183  
     184    switch (i)
     185      {
     186      case 1:
     187        if (i) /* { dg-warning "statement may fall through" } */
     188  	return;
     189        else
     190  	{
     191  	}
     192      case 2:
     193        __builtin_abort ();
     194      }
     195  
     196    switch (i)
     197      {
     198      case 1:
     199        if (i) /* { dg-warning "statement may fall through" } */
     200  	{
     201  	}
     202        else
     203  	return;
     204      case 2:
     205        __builtin_abort ();
     206      }
     207  
     208    switch (i)
     209      {
     210      case 1:
     211        if (i)
     212          goto L1;
     213        else
     214  	bar (2); /* { dg-warning "statement may fall through" } */
     215      case 2:
     216  L1:
     217        __builtin_abort ();
     218      }
     219  
     220    switch (i)
     221      {
     222      case 1:
     223        if (i)
     224          goto L2;
     225        else
     226  	bar (2); /* { dg-warning "statement may fall through" } */
     227  L2:
     228      case 2:
     229        __builtin_abort ();
     230      }
     231  
     232    switch (i)
     233      {
     234      case 1:
     235        if (i) /* { dg-warning "statement may fall through" } */
     236  	bar (1);
     237        else
     238          goto L3;
     239      case 2:
     240  L3:
     241        __builtin_abort ();
     242      }
     243  
     244    switch (i)
     245      {
     246      case 1:
     247        if (i) /* { dg-warning "statement may fall through" } */
     248  	bar (1);
     249        else
     250          goto L4;
     251  L4:
     252      case 2:
     253        __builtin_abort ();
     254      }
     255  
     256    switch (i)
     257      {
     258      case 1:
     259        if (i)
     260          goto L5;
     261        else
     262          goto L5;
     263  L5:
     264      case 2:
     265        __builtin_abort ();
     266      }
     267  
     268    switch (i)
     269      {
     270      case 1:
     271        if (i)
     272          bar (1);
     273        else
     274  	bar (2);
     275        break;
     276      case 2:
     277        __builtin_abort ();
     278      }
     279  
     280    switch (i)
     281      {
     282      case 1:
     283        if (i)
     284          bar (1);
     285        else
     286  	bar (2);
     287        bar (3);
     288        break;
     289      case 2:
     290        __builtin_abort ();
     291      }
     292  
     293    switch (i)
     294      {
     295      case 1:
     296        if (i)
     297          return;
     298        else
     299  	bar (2);
     300        break;
     301      case 2:
     302        __builtin_abort ();
     303      }
     304  
     305    switch (i)
     306      {
     307      case 1:
     308        if (i)
     309          return;
     310        else
     311  	bar (2);
     312        bar (3);
     313        break;
     314      case 2:
     315        __builtin_abort ();
     316      }
     317  
     318    switch (i)
     319      {
     320      case 1:
     321        if (i)
     322          bar (1);
     323        else
     324  	return;
     325        break;
     326      case 2:
     327        __builtin_abort ();
     328      }
     329  
     330    switch (i)
     331      {
     332      case 1:
     333        if (i)
     334  	bar (1);
     335        else
     336  	return;
     337        bar (3);
     338        break;
     339      case 2:
     340        __builtin_abort ();
     341      }
     342  
     343    switch (i)
     344      {
     345      case 1:
     346        if (i)
     347  	return;
     348        else
     349  	return;
     350        break;
     351      case 2:
     352        __builtin_abort ();
     353      }
     354  
     355    switch (i)
     356      {
     357      case 1:
     358        if (i)
     359  	return;
     360        else
     361  	return;
     362        bar (3);
     363        break;
     364      case 2:
     365        __builtin_abort ();
     366      }
     367  
     368    switch (i)
     369      {
     370      case 1:
     371        if (i)
     372  	{
     373            bar (1);
     374            bar (2);
     375            bar (3);
     376            bar (4);
     377  	}
     378        else
     379  	{
     380            bar (5);
     381            bar (6);
     382            bar (7);
     383            bar (8);
     384  	}
     385        break;
     386      case 2:
     387        __builtin_abort ();
     388      }
     389  
     390    switch (i)
     391      {
     392      case 1:
     393        if (i)
     394  	{
     395            bar (1);
     396            bar (2);
     397            bar (3);
     398            bar (4);
     399  	}
     400        else
     401  	{
     402            bar (5);
     403            bar (6);
     404            bar (7);
     405            bar (8);
     406  	}
     407        bar (9);
     408        break;
     409      case 2:
     410        __builtin_abort ();
     411      }
     412  
     413    switch (i)
     414      {
     415      case 1:
     416        if (i)
     417          {
     418  	}
     419        else
     420  	bar (2);
     421        break;
     422      case 2:
     423        __builtin_abort ();
     424      }
     425  
     426    switch (i)
     427      {
     428      case 1:
     429        if (i)
     430  	bar (1);
     431        else
     432  	{
     433  	}
     434        break;
     435      case 2:
     436        __builtin_abort ();
     437      }
     438  
     439    switch (i)
     440      {
     441      case 1:
     442        if (i)
     443  	{
     444  	}
     445        else
     446  	{
     447  	}
     448        break;
     449      case 2:
     450        __builtin_abort ();
     451      }
     452  
     453    switch (i)
     454      {
     455      case 1:
     456        if (i)
     457  	return;
     458        else
     459  	{
     460  	}
     461        break;
     462      case 2:
     463        __builtin_abort ();
     464      }
     465  
     466    switch (i)
     467      {
     468      case 1:
     469        if (i)
     470  	{
     471  	}
     472        else
     473  	return;
     474        break;
     475      case 2:
     476        __builtin_abort ();
     477      }
     478  
     479    switch (i)
     480      {
     481      case 1:
     482        if (i)
     483          goto L6;
     484        else
     485  	bar (2);
     486        break;
     487      case 2:
     488  L6:
     489        __builtin_abort ();
     490      }
     491  
     492    switch (i)
     493      {
     494      case 1:
     495        if (i)
     496          goto L7;
     497        else
     498  	bar (2);
     499        break;
     500  L7:
     501      case 2:
     502        __builtin_abort ();
     503      }
     504  
     505    switch (i)
     506      {
     507      case 1:
     508        if (i)
     509  	bar (1);
     510        else
     511          goto L8;
     512        break;
     513      case 2:
     514  L8:
     515        __builtin_abort ();
     516      }
     517  
     518    switch (i)
     519      {
     520      case 1:
     521        if (i)
     522  	bar (1);
     523        else
     524          goto L9;
     525        break;
     526  L9:
     527      case 2:
     528        __builtin_abort ();
     529      }
     530  
     531    switch (i)
     532      {
     533      case 1:
     534        if (i)
     535          goto L10;
     536        else
     537          goto L10;
     538        break;
     539  L10:
     540      case 2:
     541        __builtin_abort ();
     542      }
     543  }