Skip to content

Commit

Permalink
Pascal: Fix code generated for minint
Browse files Browse the repository at this point in the history
Pascal has a MAXINT constant, but seems to lack a corresponding
MININT so our generated Pascal code failed to compile.

We now use (-MAXINT - 1) for Snowball `minint`, which is correct
assuming two's complement representation.
  • Loading branch information
ojwb committed Oct 21, 2021
1 parent ed32a1d commit e6d8b6f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/generator_pascal.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ static void generate_AE(struct generator * g, struct node * p) {
case c_maxint:
write_string(g, "MAXINT"); break;
case c_minint:
write_string(g, "MININT"); break;
write_string(g, "(-MAXINT - 1)"); break;
case c_neg:
write_char(g, '-'); generate_AE(g, p->right); break;
case c_multiply:
Expand Down

0 comments on commit e6d8b6f

Please sign in to comment.