1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-14 23:04:57 +00:00

Added test provoking a register clobber error.

This commit is contained in:
jespergravgaard 2018-01-30 22:23:07 +01:00
parent 63f6620246
commit b466f2f5cc
3 changed files with 14 additions and 1 deletions

View File

@ -41,7 +41,7 @@ public class Pass4AssertNoCpuClobber extends Pass2Base {
*/
public void check() {
if(hasClobberProblem(true)) {
throw new RuntimeException("CLOBBER ERROR! See log for more info.");
throw new CompileError("CLOBBER ERROR! See log for more info.");
}
}

View File

@ -507,6 +507,11 @@ public class TestPrograms {
assertError("illegal-alignment", "Cannot align variable");
}
@Test
public void testRegisterClobber() throws IOException, URISyntaxException {
assertError("register-clobber", "CLOBBER ERROR");
}
private void assertError(String kcFile, String expectError) throws IOException, URISyntaxException {
try {
compileAndCompare(kcFile);

View File

@ -0,0 +1,8 @@
void main() {
byte* SCREEN = $0400;
for( register(X) byte x: 0..100 ) {
for( register(X) byte y: 0..100 ) {
SCREEN[x] = y;
}
}
}