Fix nocode_wanted in expr_landor

The generated code by yarpgen failed. I traced the problem to
expr_landor. The problem was that nocode_wanted was removing
too much code.
See also testcase 33.
This commit is contained in:
herman ten brugge 2023-03-11 07:51:00 +01:00
parent cb3589c56e
commit cad8739594
3 changed files with 29 additions and 1 deletions

View File

@ -6263,7 +6263,7 @@ static int condition_3way(void)
static void expr_landor(int op) static void expr_landor(int op)
{ {
int t = 0, cc = 1, f = 0, i = op == TOK_LAND, c; int t = 0, cc = 1, f = 0, i = op == TOK_LAND, c, prev_ncw = nocode_wanted;
for(;;) { for(;;) {
c = f ? i : condition_3way(); c = f ? i : condition_3way();
if (c < 0) if (c < 0)
@ -6286,6 +6286,7 @@ static void expr_landor(int op)
nocode_wanted -= f; nocode_wanted -= f;
} else { } else {
gvtst_set(i, t); gvtst_set(i, t);
nocode_wanted = prev_ncw;
} }
} }

View File

@ -50,6 +50,31 @@ void constantcond(void)
printf("okay\n"); printf("okay\n");
} }
unsigned short tf_4_var_2 = 29886;
const unsigned short tf_4_var_34 = 54077;
const unsigned short tf_4_var_86 = 1129;
long int tf_4_var_98 = -4448775496354969734L;
unsigned short tf_4_array_8 [9] =
{52593, 34626, 28127, 8124, 11473, 14634, 8370, 31153, 31060};
unsigned short tf_4_array_2 [6] =
{7493, 64504, 22566, 54931, 44752, 18026};
unsigned short tf_4_array_3 [9] =
{22671, 46595, 24007, 22460, 12020, 19732, 46148, 3906, 26139};
unsigned short tf_4_array_7 [9] =
{24530, 26236, 61122, 9019, 26099, 31028, 1078, 27042, 36756};
unsigned short tf_4_array_4 [9] =
{32711, 2853, 55531, 52731, 6621, 38797, 23543, 64627, 55640};
long int tf_4_var_132 = -6396431410421938408L;
static void tst_yarpgen(void)
{
/* generated by yarpgen */
tf_4_var_132 = (long int) (((unsigned long long int) (((((((int) (tf_4_var_86)) && ((int) (tf_4_array_8 [0]))) ? (((int) (tf_4_var_2)) || ((int) (8))) : (((int) (tf_4_array_2 [0])) || (-4096)))) || ((((int) (tf_4_array_3 [6])) || ((int) (tf_4_var_34))) && (((int) (tf_4_array_3 [7])) || ((int) (tf_4_var_98))))) % ((+((int) ((unsigned short) (-6)))) && ((((int) (tf_4_array_7 [5])) & ((int) (tf_4_array_7 [1]))) | (((int) (tf_4_array_4 [0])) & ((int) (tf_4_array_4 [0]))))))) <= (((unsigned long long int) ((int) ((unsigned short) (((7192886880476152731ULL) * (7192886880476152731ULL)) * ((unsigned long long int) (((-9223372036854775807L - 1L)) * ((long int) ((int) (0))))))))) * (((unsigned long long int) (((-6) * ((int) (3))) * (-((int) (4))))) * (((8ULL) * (4ULL)) * ((unsigned long long int) (((long int) (-6)) * (-3L)))))));
printf("%ld\n", tf_4_var_132);
}
int main() int main()
{ {
int Count; int Count;
@ -86,6 +111,7 @@ int main()
constantcond(); constantcond();
tst_yarpgen();
return 0; return 0;
} }

View File

@ -11,3 +11,4 @@
27 27
152 152
okay okay
1