instead in vcheck_cmp(), pass the CODE_OFF_BIT to generators unless other nocode purposes are set. This reverts commit cad873959410ddacfcd1a61d59755adf870dd592. Also in 128_run_atexit.c: avoid line output disorder which may happen on windows when tcc itself and runned code are using two different printf implementations and tcc would print the "[Returns 1]" above any output from the runned test.
Unified · Split
| @@ -56,8 +56,9 @@ ST_DATA int nocode_wanted; /* no code generation wanted */ · 55 unmodified lines | |||
| 56 | #define unevalmask 0xffff /* unevaluated subexpression */ | 56 | #define unevalmask 0xffff /* unevaluated subexpression */ |
| 57 | #define NODATA_WANTED (nocode_wanted > 0) /* no static data output wanted either */ | 57 | #define NODATA_WANTED (nocode_wanted > 0) /* no static data output wanted either */ |
| 58 | #define DATA_ONLY_WANTED 0x80000000 /* ON outside of functions and for static initializers */ | 58 | #define DATA_ONLY_WANTED 0x80000000 /* ON outside of functions and for static initializers */ |
| 59 | #define CODE_OFF() if(!nocode_wanted)(nocode_wanted |= 0x20000000) | 59 | #define CODE_OFF_BIT 0x20000000 |
| 60 | #define CODE_ON() (nocode_wanted &= ~0x20000000) | 60 | #define CODE_OFF() if(!nocode_wanted)(nocode_wanted |= CODE_OFF_BIT) |
| 61 | #define CODE_ON() (nocode_wanted &= ~CODE_OFF_BIT) | ||
| 61 | 62 | ||
| 62 | ST_DATA int global_expr; /* true if compound literals must be allocated globally (used during initializers parsing */ | 63 | ST_DATA int global_expr; /* true if compound literals must be allocated globally (used during initializers parsing */ |
| 63 | ST_DATA CType func_vt; /* current function return type (used by return instruction) */ | 64 | ST_DATA CType func_vt; /* current function return type (used by return instruction) */ |
| @@ -765,7 +766,13 @@ static void vcheck_cmp(void) · 701 unmodified lines | |||
| 765 | again, so that the VT_CMP/VT_JMP value will be in vtop | 766 | again, so that the VT_CMP/VT_JMP value will be in vtop |
| 766 | when code is unsuppressed again. */ | 767 | when code is unsuppressed again. */ |
| 767 | 768 | ||
| 768 | if (vtop->r == VT_CMP && !nocode_wanted) | 769 | /* However if it's just automatic suppression via CODE_OFF/ON() |
| 770 | then it seems that we better let things work undisturbed. | ||
| 771 | How can it work at all under nocode_wanted? Well, gv() will | ||
| 772 | actually clear it at the gsym() in load()/VT_JMP in the | ||
| 773 | generator backends */ | ||
| 774 | |||
| 775 | if (vtop->r == VT_CMP && 0 == (nocode_wanted & ~CODE_OFF_BIT)) | ||
| 769 | gv(RC_INT); | 776 | gv(RC_INT); |
| 770 | } | 777 | } |
| 771 | 778 | ||
| @@ -6263,7 +6270,7 @@ static int condition_3way(void) · 5491 unmodified lines | |||
| 6263 | 6270 | ||
| 6264 | static void expr_landor(int op) | 6271 | static void expr_landor(int op) |
| 6265 | { | 6272 | { |
| 6266 | int t = 0, cc = 1, f = 0, i = op == TOK_LAND, c, prev_ncw = nocode_wanted; | 6273 | int t = 0, cc = 1, f = 0, i = op == TOK_LAND, c; |
| 6267 | for(;;) { | 6274 | for(;;) { |
| 6268 | c = f ? i : condition_3way(); | 6275 | c = f ? i : condition_3way(); |
| 6269 | if (c < 0) | 6276 | if (c < 0) |
| @@ -6286,7 +6293,6 @@ static void expr_landor(int op) · 16 unmodified lines | |||
| 6286 | nocode_wanted -= f; | 6293 | nocode_wanted -= f; |
| 6287 | } else { | 6294 | } else { |
| 6288 | gvtst_set(i, t); | 6295 | gvtst_set(i, t); |
| 6289 | nocode_wanted = prev_ncw; | ||
| 6290 | } | 6296 | } |
| 6291 | } | 6297 | } |
| 6292 | 6298 | ||
| @@ -1,4 +1,5 @@ | |||
| 1 | int printf(const char *format, ...); | 1 | #include <stdio.h> |
| 2 | |||
| 2 | int atexit(void (*function)(void)); | 3 | int atexit(void (*function)(void)); |
| 3 | int on_exit(void (*function)(int, void *), void *arg); | 4 | int on_exit(void (*function)(int, void *), void *arg); |
| 4 | void exit(int status); | 5 | void exit(int status); |
| @@ -6,6 +7,7 @@ void exit(int status); · 1 unmodified line | |||
| 6 | void cleanup1(void) | 7 | void cleanup1(void) |
| 7 | { | 8 | { |
| 8 | printf ("cleanup1\n"); | 9 | printf ("cleanup1\n"); |
| 10 | fflush(stdout); | ||
| 9 | } | 11 | } |
| 10 | 12 | ||
| 11 | void cleanup2(void) | 13 | void cleanup2(void) |