Browse Source

Fix enumerated array literal check

gingerBill 5 years ago
parent
commit
a50b2d5d04
2 changed files with 11 additions and 17 deletions
  1. 4 15
      src/check_expr.cpp
  2. 7 2
      src/ir.cpp

+ 4 - 15
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;
 		}
 

+ 7 - 2
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) {