From 50e9a13909014aedee0ae80fbd262c3881a965f7 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Thu, 10 Oct 2019 13:31:08 +0200 Subject: [PATCH] :art: Test auto ptr stmt --- src/emit/emit.c | 1 + tests/tree/auto_array.gw | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 tests/tree/auto_array.gw diff --git a/src/emit/emit.c b/src/emit/emit.c index 334d670d..8f2e33e3 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -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 index 00000000..e5bb5284 --- /dev/null +++ b/tests/tree/auto_array.gw @@ -0,0 +1,4 @@ +int i[2][2]; +for(auto @a : i) + <<< a >>>; +<<< i >>>; -- 2.43.0