kit

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

gnu_inline_control_flow.c (991B)


      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 c_cg_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  */
      9 extern inline int suppressed(int n) {
     10   int s = 0;
     11   while (n > 0) {
     12     if (n == 3) {
     13       n--;
     14       continue;
     15     }
     16     switch (n) {
     17       case 1:
     18         s += 1;
     19         break;
     20       case 2:
     21         s += 2;
     22         break;
     23       default:
     24         s += n;
     25         break;
     26     }
     27     n--;
     28   }
     29   for (int i = 0; i < 4; i++) {
     30     if (i == 1) continue;
     31     if (i == 3) break;
     32     s += i;
     33   }
     34   return s;
     35 }
     36 
     37 int test_main(void) { return 7; }