Skip to content

Commit

Permalink
fix: Fixed overflow warnings when code not processed due to IF.
Browse files Browse the repository at this point in the history
Even though CALLs and JPs are avoided, values were being evaluated. This
is avoided by including also the conditional check in values.
  • Loading branch information
Fubukimaru authored and duhow committed Nov 4, 2023
1 parent 8f33dd2 commit 7a8a22b
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/dura.y
Original file line number Diff line number Diff line change
Expand Up @@ -3340,26 +3340,32 @@ value_real: REAL

value_3bits: value
{
if (($1 < 0) || ($1 > 7))
warning_message(3, fname_src, lines, pass, &warnings);
$$ = $1 & 0x07;
if (conditional[conditional_level]) {
if (($1 < 0) || ($1 > 7))
warning_message(3, fname_src, lines, pass, &warnings);
$$ = $1 & 0x07;
}
}
;

value_8bits: value
{
if (($1 > 255) || ($1 < -128)) {
warning_message(2, fname_src, lines, pass, &warnings);
if (conditional[conditional_level]) {
if (($1 > 255) || ($1 < -128)) {
warning_message(2, fname_src, lines, pass, &warnings);
}
$$ = $1 & 0xff;
}
$$ = $1 & 0xff;
}
;

value_16bits: value
{
if (($1 > 65535) || ($1 < -32768))
warning_message(1, fname_src, lines, pass, &warnings);
$$ = $1 & 0xffff;
if (conditional[conditional_level]) {
if (($1 > 65535) || ($1 < -32768))
warning_message(1, fname_src, lines, pass, &warnings);
$$ = $1 & 0xffff;
}
}
;

Expand Down Expand Up @@ -3693,7 +3699,8 @@ void msx_bios_vars()
void write_byte(int b)
{
/* If the condition of this block is fulfilled, create the code */
if ((!conditional_level) || (conditional[conditional_level]))
// if ((!conditional_level) || (conditional[conditional_level]))
if (conditional[conditional_level])
{
if (rom_type != MEGAROM)
{
Expand Down

0 comments on commit 7a8a22b

Please sign in to comment.