From bc3731dc5d853bfac12628ef3132a19427c58b7b Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Wed, 4 Nov 2020 09:09:38 +0100 Subject: [PATCH] Added test for #564 --- .../dk/camelot64/kickc/test/TestPrograms.java | 6 ++++++ src/test/kc/unknown-var-problem.c | 21 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 src/test/kc/unknown-var-problem.c diff --git a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java index e05ddfbf1..d37ea86fc 100644 --- a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java +++ b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java @@ -44,6 +44,12 @@ public class TestPrograms { public TestPrograms() { } + // https://gitlab.com/camelot/kickc/-/issues/564 + //@Test + //public void testUnknownVarProblem() throws IOException, URISyntaxException { + // compileAndCompare("unknown-var-problem.c", log().verboseParse()); + //} + @Test public void testFunctionPointerProblem1() throws IOException, URISyntaxException { compileAndCompare("function-pointer-problem-1.c"); diff --git a/src/test/kc/unknown-var-problem.c b/src/test/kc/unknown-var-problem.c new file mode 100644 index 000000000..f83afbbe7 --- /dev/null +++ b/src/test/kc/unknown-var-problem.c @@ -0,0 +1,21 @@ +// Demonstrates problem with assigning a pointer to pointer inside inline function +// https://gitlab.com/camelot/kickc/-/issues/564 + +typedef char uint8_t; + +uint8_t sieveFlags[128]; + +void main() { + clearSieveData(); +} + +inline void clearSieveData() { + uint8_t *p = sieveFlags; + uint8_t **pp = &p + 1; + for (register uint8_t i: 0..0x1f) { + for (register uint8_t j: 0..0xff) { + *(p + j) = 1; + } + (*pp)++; + } +}