From 93d19035ca0b15cc3afdddd62a489c77844b268e Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Sat, 14 Aug 2021 23:24:13 +0200 Subject: [PATCH] Added test demonstrating problem with NULL parameter. #706 --- .../camelot64/kickc/test/TestProgramsFast.java | 5 +++++ src/test/kc/null-constant-1.c | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 src/test/kc/null-constant-1.c diff --git a/src/test/java/dk/camelot64/kickc/test/TestProgramsFast.java b/src/test/java/dk/camelot64/kickc/test/TestProgramsFast.java index 443e2ad15..c09471149 100644 --- a/src/test/java/dk/camelot64/kickc/test/TestProgramsFast.java +++ b/src/test/java/dk/camelot64/kickc/test/TestProgramsFast.java @@ -99,6 +99,11 @@ public class TestProgramsFast extends TestPrograms { compileAndCompare("null-constant.c"); } + //@Test + //public void testNullConstant1() throws IOException { + // compileAndCompare("null-constant-1.c"); + //} + @Test public void testBlockError2() throws IOException { compileAndCompare("block-error-2.c"); diff --git a/src/test/kc/null-constant-1.c b/src/test/kc/null-constant-1.c new file mode 100644 index 000000000..ba2a3fc88 --- /dev/null +++ b/src/test/kc/null-constant-1.c @@ -0,0 +1,17 @@ +// Test the NULL pointer + +#include + +void main() { + char* SCREEN = (char*)0x0400; + + SCREEN[1] = get(SCREEN); + SCREEN[0] = get(NULL); + +} + +char get(char* ptr) { + if(NULL==ptr) + return 0; + return *ptr; +} \ No newline at end of file