]> Nishi Git Mirror - gwion.git/commitdiff
:art: Test auto ptr stmt
authorfennecdjay <astor.jeremie@wanadoo.fr>
Thu, 10 Oct 2019 11:31:08 +0000 (13:31 +0200)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Thu, 10 Oct 2019 11:31:08 +0000 (13:31 +0200)
src/emit/emit.c
tests/tree/auto_array.gw [new file with mode: 0644]

index 334d670dd2b501a6cc7fd95ef08b61f299314435..8f2e33e3e53a93869886a5983573f24df45f208f 100644 (file)
@@ -1288,6 +1288,7 @@ ANN static m_bool emit_stmt_for(const Emitter emit, const Stmt_For stmt) {
 ANN static Instr emit_stmt_autoptr_init(const Emitter emit, const Type type) {
   const Instr new_obj = emit_add_instr(emit, ObjectInstantiate);
   new_obj->m_val2 = (m_uint)type;
+  emit_add_instr(emit, RegAddRef);
   regpop(emit, SZ_INT);
   return emit_add_instr(emit, Reg2Mem);
 }
diff --git a/tests/tree/auto_array.gw b/tests/tree/auto_array.gw
new file mode 100644 (file)
index 0000000..e5bb528
--- /dev/null
@@ -0,0 +1,4 @@
+int i[2][2];
+for(auto @a : i)
+   <<< a >>>;
+<<< i >>>;