mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-11-23 08:32:39 +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() {
|
||||
}
|
||||
|
||||
/*
|
||||
@Test
|
||||
public void testProblemStructPointerParam() throws IOException, URISyntaxException {
|
||||
compileAndCompare("problem-struct-pointer-param");
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
@Test
|
||||
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…
Reference in New Issue
Block a user