History

Revert ""Fix" nocode_wanted in expr_landor"

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.

grischka committed 3 years ago

Commit 5f085611 parent 7abf2c02 files · +14 −6Browse files

Unified · Split

2 files
  1. tccgen.c +11 −5
  2. tests/tests2/128_run_atexit.c +3 −1
tccgen.c+11−5
@@ -56,8 +56,9 @@ ST_DATA int nocode_wanted; /* no code generation wanted */ · 55 unmodified lines
5656 #define unevalmask 0xffff /* unevaluated subexpression */
5757 #define NODATA_WANTED (nocode_wanted > 0) /* no static data output wanted either */
5858 #define DATA_ONLY_WANTED 0x80000000 /* ON outside of functions and for static initializers */
59−#define CODE_OFF() if(!nocode_wanted)(nocode_wanted |= 0x20000000)
60−#define CODE_ON() (nocode_wanted &= ~0x20000000)
59+#define CODE_OFF_BIT 0x20000000
60+#define CODE_OFF() if(!nocode_wanted)(nocode_wanted |= CODE_OFF_BIT)
61+#define CODE_ON() (nocode_wanted &= ~CODE_OFF_BIT)
6162
6263 ST_DATA int global_expr; /* true if compound literals must be allocated globally (used during initializers parsing */
6364 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
765766 again, so that the VT_CMP/VT_JMP value will be in vtop
766767 when code is unsuppressed again. */
767768
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))
769776 gv(RC_INT);
770777 }
771778
@@ -6263,7 +6270,7 @@ static int condition_3way(void) · 5491 unmodified lines
62636270
62646271 static void expr_landor(int op)
62656272 {
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;
62676274 for(;;) {
62686275 c = f ? i : condition_3way();
62696276 if (c < 0)
@@ -6286,7 +6293,6 @@ static void expr_landor(int op) · 16 unmodified lines
62866293 nocode_wanted -= f;
62876294 } else {
62886295 gvtst_set(i, t);
6289− nocode_wanted = prev_ncw;
62906296 }
62916297 }
62926298
tests/tests2/128_run_atexit.c+3−1
@@ -1,4 +1,5 @@
1−int printf(const char *format, ...);
1+#include <stdio.h>
2+
23 int atexit(void (*function)(void));
34 int on_exit(void (*function)(int, void *), void *arg);
45 void exit(int status);
@@ -6,6 +7,7 @@ void exit(int status); · 1 unmodified line
67 void cleanup1(void)
78 {
89 printf ("cleanup1\n");
10+ fflush(stdout);
911 }
1012
1113 void cleanup2(void)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t