aboutsummaryrefslogtreecommitdiff
path: root/test/run_tests.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2015-12-22 13:22:40 -0700
committerAndrew Kelley <superjoe30@gmail.com>2015-12-22 13:22:40 -0700
commit431170d981edf1eba790cefe0f27a6142634ea1d (patch)
tree67f8d09417dd0bb151f0b22ac9fa52e90f2664aa /test/run_tests.cpp
parent437e9b954d8a47a1acb6aa5327c6473ab8d9267c (diff)
downloadzig-431170d981edf1eba790cefe0f27a6142634ea1d.tar.gz
zig-431170d981edf1eba790cefe0f27a6142634ea1d.zip
codegen: fix struct pointer field access
Diffstat (limited to 'test/run_tests.cpp')
-rw-r--r--test/run_tests.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp
index 8fd17c4d1a..2566df9ada 100644
--- a/test/run_tests.cpp
+++ b/test/run_tests.cpp
@@ -573,6 +573,7 @@ export fn main(argc : isize, argv : &&u8, env : &&u8) -> i32 {
if foo.c != 100 {
print_str("BAD\n");
}
+ test_point_to_self();
print_str("OK\n");
return 0;
}
@@ -589,6 +590,28 @@ fn test_foo(foo : Foo) {
fn test_mutation(foo : &Foo) {
foo.c = 100;
}
+struct Node {
+ val: Val,
+ next: &Node,
+}
+
+struct Val {
+ x: i32,
+}
+fn test_point_to_self() {
+ var root : Node;
+ root.val.x = 1;
+
+ var node : Node;
+ node.next = &root;
+ node.val.x = 2;
+
+ root.next = &node;
+
+ if node.next.next.next.val.x != 1 {
+ print_str("BAD\n");
+ }
+}
)SOURCE", "OK\n");
add_simple_case("global variables", R"SOURCE(