aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWes Hardee <weshardee@gmail.com>2022-07-09 18:09:21 -0500
committerGitHub <noreply@github.com>2022-07-09 18:09:21 -0500
commit00739bf06dc73a88a320baec01a3844fbf9f59a9 (patch)
tree157cca02510cd90f6c092ae99c50056342bc7532 /src
parent23842a8950be99afca4f4180aca95a7c2da771dc (diff)
parente8148055ad78489832c55aab9b81edd694440d63 (diff)
Merge branch 'odin-lang:master' into master
Diffstat (limited to 'src')
-rw-r--r--src/build_settings.cpp2
-rw-r--r--src/check_expr.cpp10
-rw-r--r--src/check_stmt.cpp21
-rw-r--r--src/check_type.cpp4
-rw-r--r--src/llvm_backend_debug.cpp13
-rw-r--r--src/llvm_backend_general.cpp20
-rw-r--r--src/types.cpp11
7 files changed, 70 insertions, 11 deletions
diff --git a/src/build_settings.cpp b/src/build_settings.cpp
index a82cc80c9..65da09df0 100644
--- a/src/build_settings.cpp
+++ b/src/build_settings.cpp
@@ -1322,6 +1322,7 @@ bool init_build_paths(String init_filename) {
}
#if defined(GB_SYSTEM_WINDOWS)
+ if (bc->metrics.os == TargetOs_windows) {
if (bc->resource_filepath.len > 0) {
bc->build_paths[BuildPath_RC] = path_from_string(ha, bc->resource_filepath);
bc->build_paths[BuildPath_RES] = path_from_string(ha, bc->resource_filepath);
@@ -1377,6 +1378,7 @@ bool init_build_paths(String init_filename) {
}
}
}
+ }
#endif
// All the build targets and OSes.
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 58972d2cf..b42301cd6 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -3249,8 +3249,14 @@ void check_binary_expr(CheckerContext *c, Operand *x, Ast *node, Type *type_hint
return;
}
-
- if (!are_types_identical(x->type, y->type)) {
+ if ((op.kind == Token_CmpAnd || op.kind == Token_CmpOr) &&
+ is_type_boolean(x->type) && is_type_boolean(y->type)) {
+ // NOTE(bill, 2022-06-26)
+ // Allow any boolean types within `&&` and `||`
+ // This is an exception to all other binary expressions since the result
+ // of a comparison will always be an untyped boolean, and allowing
+ // any boolean between these two simplifies a lot of expressions
+ } else if (!are_types_identical(x->type, y->type)) {
if (x->type != t_invalid &&
y->type != t_invalid) {
gbString xt = type_to_string(x->type);
diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp
index f061b4961..a6f6f1a7d 100644
--- a/src/check_stmt.cpp
+++ b/src/check_stmt.cpp
@@ -2142,7 +2142,26 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) {
}
if (new_name_count == 0) {
- error(node, "No new declarations on the lhs");
+ begin_error_block();
+ error(node, "No new declarations on the left hand side");
+ bool all_underscore = true;
+ for_array(i, vd->names) {
+ Ast *name = vd->names[i];
+ if (name->kind == Ast_Ident) {
+ if (!is_blank_ident(name)) {
+ all_underscore = false;
+ break;
+ }
+ } else {
+ all_underscore = false;
+ break;
+ }
+ }
+ if (all_underscore) {
+ error_line("\tSuggestion: Try changing the declaration (:=) to an assignment (=)\n");
+ }
+
+ end_error_block();
}
Type *init_type = nullptr;
diff --git a/src/check_type.cpp b/src/check_type.cpp
index fc5b7aed7..bc89a9be9 100644
--- a/src/check_type.cpp
+++ b/src/check_type.cpp
@@ -1240,7 +1240,7 @@ Type *determine_type_from_polymorphic(CheckerContext *ctx, Type *poly_type, Oper
if (!is_operand_value(operand)) {
if (show_error) {
gbString pts = type_to_string(poly_type);
- gbString ots = type_to_string(operand.type);
+ gbString ots = type_to_string(operand.type, true);
defer (gb_string_free(pts));
defer (gb_string_free(ots));
error(operand.expr, "Cannot determine polymorphic type from parameter: '%s' to '%s'", ots, pts);
@@ -1253,7 +1253,7 @@ Type *determine_type_from_polymorphic(CheckerContext *ctx, Type *poly_type, Oper
}
if (show_error) {
gbString pts = type_to_string(poly_type);
- gbString ots = type_to_string(operand.type);
+ gbString ots = type_to_string(operand.type, true);
defer (gb_string_free(pts));
defer (gb_string_free(ots));
error(operand.expr, "Cannot determine polymorphic type from parameter: '%s' to '%s'", ots, pts);
diff --git a/src/llvm_backend_debug.cpp b/src/llvm_backend_debug.cpp
index b91f32bfc..45a868581 100644
--- a/src/llvm_backend_debug.cpp
+++ b/src/llvm_backend_debug.cpp
@@ -419,7 +419,18 @@ LLVMMetadataRef lb_debug_type_internal(lbModule *m, Type *type) {
break;
case Type_SimdVector:
- return LLVMDIBuilderCreateVectorType(m->debug_builder, cast(unsigned)type->SimdVector.count, 8*cast(unsigned)type_align_of(type), lb_debug_type(m, type->SimdVector.elem), nullptr, 0);
+ {
+ LLVMMetadataRef elem = lb_debug_type(m, type->SimdVector.elem);
+ LLVMMetadataRef subscripts[1] = {};
+ subscripts[0] = LLVMDIBuilderGetOrCreateSubrange(m->debug_builder,
+ 0ll,
+ type->SimdVector.count
+ );
+ return LLVMDIBuilderCreateVectorType(
+ m->debug_builder,
+ 8*cast(unsigned)type_size_of(type), 8*cast(unsigned)type_align_of(type),
+ elem, subscripts, gb_count_of(subscripts));
+ }
case Type_RelativePointer: {
LLVMMetadataRef base_integer = lb_debug_type(m, type->RelativePointer.base_integer);
diff --git a/src/llvm_backend_general.cpp b/src/llvm_backend_general.cpp
index e3d30ccff..5b43a11ab 100644
--- a/src/llvm_backend_general.cpp
+++ b/src/llvm_backend_general.cpp
@@ -852,6 +852,12 @@ bool lb_is_type_proc_recursive(Type *t) {
void lb_emit_store(lbProcedure *p, lbValue ptr, lbValue value) {
GB_ASSERT(value.value != nullptr);
Type *a = type_deref(ptr.type);
+
+ if (LLVMIsNull(value.value)) {
+ LLVMTypeRef src_t = LLVMGetElementType(LLVMTypeOf(ptr.value));
+ LLVMBuildStore(p->builder, LLVMConstNull(src_t), ptr.value);
+ return;
+ }
if (is_type_boolean(a)) {
// NOTE(bill): There are multiple sized booleans, thus force a conversion (if necessarily)
value = lb_emit_conv(p, value, a);
@@ -861,6 +867,20 @@ void lb_emit_store(lbProcedure *p, lbValue ptr, lbValue value) {
GB_ASSERT_MSG(are_types_identical(ca, core_type(value.type)), "%s != %s", type_to_string(a), type_to_string(value.type));
}
+ enum {MAX_STORE_SIZE = 64};
+
+ if (LLVMIsALoadInst(value.value) && lb_sizeof(LLVMTypeOf(value.value)) > MAX_STORE_SIZE) {
+ LLVMValueRef dst_ptr = ptr.value;
+ LLVMValueRef src_ptr = LLVMGetOperand(value.value, 0);
+ src_ptr = LLVMBuildPointerCast(p->builder, src_ptr, LLVMTypeOf(dst_ptr), "");
+
+ LLVMBuildMemMove(p->builder,
+ dst_ptr, 1,
+ src_ptr, 1,
+ LLVMConstInt(LLVMInt64TypeInContext(p->module->ctx), lb_sizeof(LLVMTypeOf(value.value)), false));
+ return;
+ }
+
if (lb_is_type_proc_recursive(a)) {
// NOTE(bill, 2020-11-11): Because of certain LLVM rules, a procedure value may be
// stored as regular pointer with no procedure information
diff --git a/src/types.cpp b/src/types.cpp
index ad83e0568..5f112ce09 100644
--- a/src/types.cpp
+++ b/src/types.cpp
@@ -724,10 +724,11 @@ gb_global RecursiveMutex g_type_mutex;
struct TypePath;
-i64 type_size_of (Type *t);
-i64 type_align_of (Type *t);
-i64 type_offset_of (Type *t, i32 index);
-gbString type_to_string (Type *type, bool shorthand=false);
+i64 type_size_of (Type *t);
+i64 type_align_of (Type *t);
+i64 type_offset_of (Type *t, i32 index);
+gbString type_to_string (Type *type, bool shorthand=true);
+gbString type_to_string (Type *type, gbAllocator allocator, bool shorthand=true);
i64 type_size_of_internal(Type *t, TypePath *path);
void init_map_internal_types(Type *type);
Type * bit_set_to_int(Type *t);
@@ -4287,7 +4288,7 @@ gbString write_type_to_string(gbString str, Type *type, bool shorthand=false) {
}
-gbString type_to_string(Type *type, gbAllocator allocator, bool shorthand=false) {
+gbString type_to_string(Type *type, gbAllocator allocator, bool shorthand) {
return write_type_to_string(gb_string_make(allocator, ""), type, shorthand);
}
gbString type_to_string(Type *type, bool shorthand) {