boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

124-tentative-static.c (846B)


      1 /* C 6.9.2 — file-scope tentative definitions can repeat and may be
      2  * later replaced by an initialized definition. tcc.c relies on this
      3  * pattern (`static int gnu_ext;` early, `static int gnu_ext = 1;`
      4  * later). */
      5 
      6 static int s_dup;          /* tentative */
      7 static int s_dup;          /* tentative again — must merge, not redefine */
      8 
      9 static int s_init;         /* tentative ... */
     10 static int s_init = 7;     /* ... promoted to a real def with initializer */
     11 
     12 int g_dup;                 /* tentative, no storage class */
     13 int g_dup;                 /* tentative again */
     14 
     15 int g_init;                /* tentative ... */
     16 int g_init = 11;           /* ... real def */
     17 
     18 int main(int argc, char **argv) {
     19     if (s_dup != 0) return 1;
     20     if (s_init != 7) return 2;
     21     if (g_dup != 0) return 3;
     22     if (g_init != 11) return 4;
     23     return 0;
     24 }