diff --git a/tccgen.c b/tccgen.c index ceff794e..0809760f 100644 --- a/tccgen.c +++ b/tccgen.c @@ -56,7 +56,7 @@ ST_DATA int nocode_wanted; /* no code generation wanted */ #define unevalmask 0xffff /* unevaluated subexpression */ #define NODATA_WANTED (nocode_wanted > 0) /* no static data output wanted either */ #define DATA_ONLY_WANTED 0x80000000 /* ON outside of functions and for static initializers */ -#define CODE_OFF() (nocode_wanted |= 0x20000000) +#define CODE_OFF() if(!nocode_wanted)(nocode_wanted |= 0x20000000) #define CODE_ON() (nocode_wanted &= ~0x20000000) ST_DATA int global_expr; /* true if compound literals must be allocated globally (used during initializers parsing */ diff --git a/tests/tests2/88_codeopt.c b/tests/tests2/88_codeopt.c index 2ab4c8a8..3faa5fac 100644 --- a/tests/tests2/88_codeopt.c +++ b/tests/tests2/88_codeopt.c @@ -44,6 +44,16 @@ void bla(void) get_args(!!__ret, sizeof(__ret)); } +int ext; + +void broken_jumpopt (int xxx) +{ + /* This was broken in 8227db3a2 by code suppression during suppressed + code :) */ + ext = (xxx || 1) || ((xxx && 1) || 1); + printf("okay: %d %d\n", xxx, ext); +} + _Bool chk(unsigned long addr, unsigned long limit, unsigned long size) { _Bool ret; @@ -65,5 +75,6 @@ int main() else printf("okay\n"); bla(); + broken_jumpopt(42); return 0; } diff --git a/tests/tests2/88_codeopt.expect b/tests/tests2/88_codeopt.expect index 439edfd8..76b582b3 100644 --- a/tests/tests2/88_codeopt.expect +++ b/tests/tests2/88_codeopt.expect @@ -1,2 +1,3 @@ okay okay +okay: 42 1