-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request cc65#2362 from colinleroy/fix-2357-bis
Add test case for bug cc65#2357
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* bug #2357 - Compiler produces invalid code after d8a3938 | ||
*/ | ||
|
||
unsigned long test; | ||
|
||
unsigned long longarray[7]; | ||
|
||
void jsr_threebytes(void) { | ||
|
||
} | ||
|
||
/* having replaced two sty $zp with two sta $abs, but forgetting | ||
* to update the instruction size, coptlong.c could cause a build | ||
* error "Error: Range error (131 not in [-128..127])" if the | ||
* computed codesize was under 126, but the real codesize was above | ||
* 127. | ||
* This tests verifies that the bug is fixed. | ||
*/ | ||
unsigned char __fastcall__ foo (unsigned char res) | ||
{ | ||
if (res == 0) { | ||
longarray[1]=test; /* 24 bytes - but the compiler thought 22 */ | ||
longarray[2]=test; /* 48 bytes - but 44 */ | ||
longarray[3]=test; /* 72 bytes - 66 */ | ||
longarray[4]=test; /* 96 bytes - 88 */ | ||
longarray[6]=test; /* 120 bytes - 110 */ | ||
jsr_threebytes(); /* 123 - 113 */ | ||
jsr_threebytes(); /* 126 - 116 */ | ||
jsr_threebytes(); /* 129 - 119 */ | ||
} | ||
return 0; | ||
} | ||
|
||
int main (void) | ||
{ | ||
foo(42); | ||
return 0; | ||
} |