kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

gnu_inline_control_flow.c (989B)


      1 /* A C99 `extern inline` definition is parsed and semantically validated but
      2  * emits no out-of-line code (codegen suppressed). Control-flow statements in
      3  * such a body must do their break/continue/case bookkeeping without opening a
      4  * CG function — regression for pcg_label_new and the while/switch suppressed
      5  * paths, which mint dummy labels under suppression instead of calling the CG
      6  * label ops. The suppressed body is intentionally not referenced (an extern
      7  * inline has no external definition to link against); test_main stands alone. */
      8 extern inline int suppressed(int n) {
      9   int s = 0;
     10   while (n > 0) {
     11     if (n == 3) {
     12       n--;
     13       continue;
     14     }
     15     switch (n) {
     16       case 1:
     17         s += 1;
     18         break;
     19       case 2:
     20         s += 2;
     21         break;
     22       default:
     23         s += n;
     24         break;
     25     }
     26     n--;
     27   }
     28   for (int i = 0; i < 4; i++) {
     29     if (i == 1) continue;
     30     if (i == 3) break;
     31     s += i;
     32   }
     33   return s;
     34 }
     35 
     36 int test_main(void) { return 7; }