diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass0GenerateStatementSequence.java b/src/main/java/dk/camelot64/kickc/passes/Pass0GenerateStatementSequence.java index 478f479de..a81137115 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass0GenerateStatementSequence.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass0GenerateStatementSequence.java @@ -2766,7 +2766,7 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor modifiers, StatementSource source) { for(PrePostModifier mod : modifiers) { - if(mod.child instanceof ConstantRef) { + if(mod.child instanceof ConstantValue) { throw new CompileError("Constants can not be modified " + mod.child.toString(), source); } Statement stmt = new StatementAssignment((LValue) mod.child, mod.operator, copyLValue((LValue) mod.child), false, source, Comment.NO_COMMENTS); diff --git a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java index 2d1a44b72..fd874d6ab 100644 --- a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java +++ b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java @@ -666,6 +666,11 @@ public class TestPrograms { compileAndCompare("examples/conio/nacht-screen.c"); } + @Test + public void testPostIncrementProblem5() throws IOException, URISyntaxException { + assertError("post-increment-problem-5.c", "Constants can not be modified"); + } + @Test public void testPostIncrementProblem4() throws IOException, URISyntaxException { compileAndCompare("post-increment-problem-4.c"); @@ -1447,7 +1452,7 @@ public class TestPrograms { @Test public void testDyppa2() throws IOException, URISyntaxException { - compileAndCompare("complex/dyppa2/dyppa2.c", log()); + compileAndCompare("complex/dyppa2/dyppa2.c"); } @Test diff --git a/src/test/kc/complex/dyppa2/dyppa2.c b/src/test/kc/complex/dyppa2/dyppa2.c new file mode 100644 index 000000000..3b2bbbdf6 --- /dev/null +++ b/src/test/kc/complex/dyppa2/dyppa2.c @@ -0,0 +1,33 @@ +// Chunky DYPP with arbitrary sinus +// First implemented as dyppa.asm in 2011 + +#pragma emulator("C64Debugger") + +#include +#include + +// The DYPPA charset containing the sloped offset characters +char __address(0x2000) DYPPA_CHARSET[0x0800] = kickasm(resource "dyppacharset.bin") {{ + .var dyppaFile = LoadBinary("dyppacharset.bin", "Charset=$000,Tables=$800") + .fill dyppaFile.getCharsetSize(), dyppaFile.getCharset(i) +}}; + +// The DYPPA tables mapping the slopes, offsets and pixels to the right character in the charset +// for(offset:0..7) for(slope:0..f) for(pixels: 0..f) glyph_id(offset,slope,pixels) +char align(0x100) DYPPA_TABLE[0x0800] = kickasm(resource "dyppacharset.bin") {{ + .var dyppaFile2 = LoadBinary("dyppacharset.bin", "Charset=$000,Tables=$800") + .fill dyppaFile2.getTablesSize(), dyppaFile2.getTables(i) +}}; + +void main() { + VICII->MEMORY = toD018(DEFAULT_SCREEN, DYPPA_CHARSET); + memset(DEFAULT_SCREEN, DYPPA_TABLE[0], 1000); + + for(;;) { + (*(DEFAULT_SCREEN+999))++; + } + +} + + + diff --git a/src/test/kc/complex/dyppa2/dyppacharset.bin b/src/test/kc/complex/dyppa2/dyppacharset.bin new file mode 100644 index 000000000..98721d73f Binary files /dev/null and b/src/test/kc/complex/dyppa2/dyppacharset.bin differ diff --git a/src/test/kc/post-increment-problem-5.c b/src/test/kc/post-increment-problem-5.c new file mode 100644 index 000000000..4a5b9fed2 --- /dev/null +++ b/src/test/kc/post-increment-problem-5.c @@ -0,0 +1,8 @@ +// Post-increment expression causes java.lang.ClassCastException: class dk.camelot64.kickc.model.values.ConstantBinary cannot be cast to class dk.camelot64.kickc.model.values.LValue +// Should result in a proper error + +char* const SCREEN = 0x0400; + +void main() { + *(SCREEN+999)++; +}