1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-04-04 15:29:46 +00:00

Fixed infinite loop. Closes #626

This commit is contained in:
jespergravgaard 2021-01-23 12:49:49 +01:00
parent 44ad31a27e
commit 9250e346be
3 changed files with 41 additions and 0 deletions

View File

@ -134,6 +134,7 @@ public class Pass2ConstantStringConsolidation extends Pass2SsaOptimization {
if(getScope().getLocalSymbol(candidateName) == null) {
return candidateName;
}
i++;
} while(true);
}

View File

@ -467,6 +467,11 @@ public class TestPrograms {
compileAndCompare("examples/nes/nes-demo.c");
}
@Test
public void testCx16Vera() throws IOException, URISyntaxException {
compileAndCompare("examples/cx16/cx16-vera.c");
}
@Test
public void testCx16VeraLayers() throws IOException, URISyntaxException {
compileAndCompare("examples/cx16/cx16-veralayers.c");
@ -3546,6 +3551,11 @@ public class TestPrograms {
compileAndCompare("string-const-consolidation.c");
}
@Test
public void testStringConstConsolidationRoot() throws IOException, URISyntaxException {
compileAndCompare("string-const-consolidation-root.c", log());
}
@Test
public void testCommentsGlobalInit() throws IOException, URISyntaxException {
compileAndCompare("test-comments-global.c");

View File

@ -0,0 +1,30 @@
// Tests that multiple different identical strings are consolidated to a root variable
void main() {
print1();
print2();
}
char* s = "string3";
char* s1 = "string4";
void print1() {
print("string1");
print("string2");
print(s);
}
void print2() {
print("string1");
print("string2");
print(s1);
}
char* screen = 0x400;
void print(char* s) {
while(*s) {
*screen++ = *s++;
}
}