mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-01-11 04:29:53 +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>
|
<JetCodeStyleSettings>
|
||||||
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
||||||
<value>
|
<value>
|
||||||
<package name="java.util" alias="false" withSubpackages="false" />
|
<package name="java.util" withSubpackages="false" static="false" />
|
||||||
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
|
<package name="kotlinx.android.synthetic" withSubpackages="true" static="false" />
|
||||||
<package name="io.ktor" alias="false" withSubpackages="true" />
|
<package name="io.ktor" withSubpackages="true" static="false" />
|
||||||
</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" />
|
|
||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
</JetCodeStyleSettings>
|
</JetCodeStyleSettings>
|
||||||
|
@ -981,6 +981,8 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor<Objec
|
|||||||
if(ctx.expr() != null) {
|
if(ctx.expr() != null) {
|
||||||
varDeclPush();
|
varDeclPush();
|
||||||
RValue sizeVal = (RValue) visit(ctx.expr());
|
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();
|
varDeclPop();
|
||||||
arraySpec = new ArraySpec((ConstantValue) sizeVal);
|
arraySpec = new ArraySpec((ConstantValue) sizeVal);
|
||||||
} else {
|
} else {
|
||||||
|
@ -44,6 +44,11 @@ public class TestPrograms {
|
|||||||
public TestPrograms() {
|
public TestPrograms() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testProblemArraySizeDecl() throws IOException, URISyntaxException {
|
||||||
|
assertError("problem-arraysize-decl.c", "BAR is not constant or is not defined");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testComplexNew30YearsLowResolution() throws IOException, URISyntaxException {
|
public void testComplexNew30YearsLowResolution() throws IOException, URISyntaxException {
|
||||||
compileAndCompare("complex/new_30_years_low_resolution/new_30_years_low_resolution.c");
|
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…
x
Reference in New Issue
Block a user