mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-12-22 21:29:50 +00:00
Merged @SijmenSchoon fix for ClassCastException when declaring array with a constant that does not exist addresses. Closes #607
This commit is contained in:
parent
dedd1cc217
commit
056e145d2e
15
.idea/codeStyles/Project.xml
generated
15
.idea/codeStyles/Project.xml
generated
@ -7,18 +7,9 @@
|
||||
<JetCodeStyleSettings>
|
||||
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
||||
<value>
|
||||
<package name="java.util" alias="false" withSubpackages="false" />
|
||||
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
|
||||
<package name="io.ktor" alias="false" withSubpackages="true" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="PACKAGES_IMPORT_LAYOUT">
|
||||
<value>
|
||||
<package name="" alias="false" withSubpackages="true" />
|
||||
<package name="java" alias="false" withSubpackages="true" />
|
||||
<package name="javax" alias="false" withSubpackages="true" />
|
||||
<package name="kotlin" alias="false" withSubpackages="true" />
|
||||
<package name="" alias="true" withSubpackages="true" />
|
||||
<package name="java.util" withSubpackages="false" static="false" />
|
||||
<package name="kotlinx.android.synthetic" withSubpackages="true" static="false" />
|
||||
<package name="io.ktor" withSubpackages="true" static="false" />
|
||||
</value>
|
||||
</option>
|
||||
</JetCodeStyleSettings>
|
||||
|
@ -981,6 +981,8 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
|
||||
if(ctx.expr() != null) {
|
||||
varDeclPush();
|
||||
RValue sizeVal = (RValue) visit(ctx.expr());
|
||||
if (!(sizeVal instanceof ConstantValue))
|
||||
throw new CompileError(sizeVal.toString() + " is not constant or is not defined", new StatementSource(ctx));
|
||||
varDeclPop();
|
||||
arraySpec = new ArraySpec((ConstantValue) sizeVal);
|
||||
} else {
|
||||
|
@ -44,6 +44,11 @@ public class TestPrograms {
|
||||
public TestPrograms() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProblemArraySizeDecl() throws IOException, URISyntaxException {
|
||||
assertError("problem-arraysize-decl.c", "BAR is not constant or is not defined");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComplexNew30YearsLowResolution() throws IOException, URISyntaxException {
|
||||
compileAndCompare("complex/new_30_years_low_resolution/new_30_years_low_resolution.c");
|
||||
|
6
src/test/kc/problem-arraysize-decl.c
Normal file
6
src/test/kc/problem-arraysize-decl.c
Normal file
@ -0,0 +1,6 @@
|
||||
// Demonstrates problem when declaring an array with a size constant that does not exist
|
||||
|
||||
char foo[BAR];
|
||||
|
||||
void main() {
|
||||
}
|
Loading…
Reference in New Issue
Block a user