mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-02-17 10:30:43 +00:00
Added test demonstrating problem with passing derefed struct pointer to call. #225
This commit is contained in:
parent
cb5dc6550e
commit
889cc1219f
@ -35,6 +35,13 @@ public class TestPrograms {
|
|||||||
public TestPrograms() {
|
public TestPrograms() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
@Test
|
||||||
|
public void testProblemStructPointerParam() throws IOException, URISyntaxException {
|
||||||
|
compileAndCompare("problem-struct-pointer-param");
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@Test
|
@Test
|
||||||
public void testProblemArrayStructParam() throws IOException, URISyntaxException {
|
public void testProblemArrayStructParam() throws IOException, URISyntaxException {
|
||||||
|
20
src/test/kc/problem-struct-pointer-param.kc
Normal file
20
src/test/kc/problem-struct-pointer-param.kc
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// Demonstrates problem with passing struct pointer deref as parameter to call
|
||||||
|
|
||||||
|
const char* SCREEN = 0x0400;
|
||||||
|
char idx = 0;
|
||||||
|
|
||||||
|
struct Point {
|
||||||
|
char x;
|
||||||
|
char y;
|
||||||
|
};
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
struct Point point = { 1, 2 };
|
||||||
|
struct Point* ptr = &point;
|
||||||
|
print(*ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print(struct Point p) {
|
||||||
|
SCREEN[idx++] = p.x;
|
||||||
|
SCREEN[idx++] = p.y;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user