From: Jérémie Astor Date: Mon, 15 Jun 2020 12:17:45 +0000 (+0200) Subject: :bug: Fix stmt_auto X-Git-Tag: nightly~1474 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=153ec452032598c77573313dac74cfc973d8c5d6;p=gwion.git :bug: Fix stmt_auto --- diff --git a/src/emit/emit.c b/src/emit/emit.c index 2e5cff70..18c127b6 100644 --- a/src/emit/emit.c +++ b/src/emit/emit.c @@ -1506,7 +1506,6 @@ ANN static Instr emit_stmt_autoptr_init(const Emitter emit, const Type type) { } ANN static m_bool _emit_stmt_auto(const Emitter emit, const Stmt_Auto stmt, m_uint *end_pc) { - emit_push_scope(emit); const Instr s1 = emit_add_instr(emit, MemSetImm); Instr cpy = stmt->is_ptr ? emit_stmt_autoptr_init(emit, stmt->v->type) : NULL; emit_local(emit, emit->gwion->type[et_int]); @@ -1527,8 +1526,6 @@ ANN static m_bool _emit_stmt_auto(const Emitter emit, const Stmt_Auto stmt, m_ui end->m_val = emit_code_size(emit); tgt->m_val = ini_pc; s1->m_val = loop->m_val = offset; - regpop(emit, SZ_INT); - emit_pop_scope(emit); return ret; } @@ -1538,6 +1535,7 @@ ANN static m_bool emit_stmt_auto(const Emitter emit, const Stmt_Auto stmt) { m_uint end_pc = 0; const m_bool ret = _emit_stmt_auto(emit, stmt, &end_pc); emit_pop_stack(emit, end_pc); + regpop(emit, SZ_INT); return ret; } diff --git a/src/parse/check.c b/src/parse/check.c index 6695263a..17459c4d 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -1000,12 +1000,12 @@ ANN static m_bool do_stmt_auto(const Env env, const Stmt_Auto stmt) { " This is not allowed in auto loop"), stmt->exp->info->type->name) if(stmt->is_ptr) { struct Type_List_ tl = {}; + if(depth) + ptr = array_type(env, ptr, depth); Type_Decl *td0 = type2td(env, ptr, stmt->exp->pos), td = { .xid=insert_symbol("Ptr"), .types=&tl, .pos=stmt->exp->pos }; tl.td = td0; ptr = known_type(env, &td); - if(depth) - ptr = array_type(env, ptr, depth); td0->array = NULL; free_type_decl(env->gwion->mp, td0); const Type base = get_type(ptr);