From a50b2d5d043d34124b078f81572ddbf58d737434 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sat, 28 Dec 2019 14:05:55 +0000 Subject: [PATCH] Fix enumerated array literal check --- src/check_expr.cpp | 19 ++++--------------- src/ir.cpp | 9 +++++++-- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 8ba504ed3..268adc70f 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -8126,25 +8126,14 @@ ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast *node, Type } - if (t->kind == Type_Array) { - if (is_to_be_determined_array_count) { - t->Array.count = max; - } else if (cl->elems.count > 0 && cl->elems[0]->kind != Ast_FieldValue) { - if (0 < max && max < t->Array.count) { - error(node, "Expected %lld values for this array literal, got %lld", cast(long long)t->Array.count, cast(long long)max); + if (t->kind == Type_EnumeratedArray) { + if (cl->elems.count > 0 && cl->elems[0]->kind != Ast_FieldValue) { + if (0 < max && max < t->EnumeratedArray.count) { + error(node, "Expected %lld values for this enumerated array literal, got %lld", cast(long long)t->EnumeratedArray.count, cast(long long)max); } } } - - if (t->kind == Type_SimdVector) { - if (!is_constant) { - error(node, "Expected all constant elements for a simd vector"); - } - if (t->SimdVector.is_x86_mmx) { - error(node, "Compound literals are not allowed with intrinsics.x86_mmx"); - } - } break; } diff --git a/src/ir.cpp b/src/ir.cpp index 31d6c0251..3be207e3e 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -9401,8 +9401,13 @@ void ir_build_range_tuple(irProcedure *proc, Ast *expr, Type *val0_type, Type *v void ir_store_type_case_implicit(irProcedure *proc, Ast *clause, irValue *value) { Entity *e = implicit_entity_of_node(clause); GB_ASSERT(e != nullptr); +#if 1 irValue *x = ir_add_local(proc, e, nullptr, false); ir_emit_store(proc, x, value); +#else + irValue *x = ir_address_from_load_or_generate_local(proc, value); + ir_module_add_value(proc->module, e, x); +#endif } void ir_type_case_body(irProcedure *proc, Ast *label, Ast *clause, irBlock *body, irBlock *done) { @@ -10317,9 +10322,9 @@ void ir_build_stmt_internal(irProcedure *proc, Ast *node) { ir_start_block(proc, body); + // bool any_or_not_ptr = is_type_any(type_deref(parent_type)) || !is_parent_ptr; + bool any_or_not_ptr = !is_parent_ptr; if (cc->list.count == 1) { - // bool any_or_not_ptr = is_type_any(type_deref(parent_type)) || !is_parent_ptr; - bool any_or_not_ptr = !is_parent_ptr; Type *ct = case_entity->type; if (any_or_not_ptr) {