Merge remote-tracking branch 'offical/master'

This commit is contained in:
2024-06-06 10:31:33 -04:00
183 changed files with 9801 additions and 6663 deletions
+22 -1
View File
@@ -125,6 +125,8 @@ gb_internal Entity *find_polymorphic_record_entity(GenTypesData *found_gen_types
gb_internal bool complete_soa_type(Checker *checker, Type *t, bool wait_to_finish);
gb_internal bool check_is_castable_to(CheckerContext *c, Operand *operand, Type *y);
enum LoadDirectiveResult {
LoadDirective_Success = 0,
LoadDirective_Error = 1,
@@ -2252,6 +2254,17 @@ gb_internal bool check_representable_as_constant(CheckerContext *c, ExactValue i
gb_internal bool check_integer_exceed_suggestion(CheckerContext *c, Operand *o, Type *type, i64 max_bit_size=0) {
if (is_type_integer(type) && o->value.kind == ExactValue_Integer) {
gbString b = type_to_string(type);
defer (gb_string_free(b));
if (is_type_enum(o->type)) {
if (check_is_castable_to(c, o, type)) {
gbString ot = type_to_string(o->type);
error_line("\tSuggestion: Try casting the '%s' expression to '%s'", ot, b);
gb_string_free(ot);
}
return true;
}
i64 sz = type_size_of(type);
i64 bit_size = 8*sz;
@@ -2301,7 +2314,6 @@ gb_internal bool check_integer_exceed_suggestion(CheckerContext *c, Operand *o,
}
}
gb_string_free(b);
return true;
}
@@ -7408,6 +7420,7 @@ gb_internal ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *c
String name = bd->name.string;
if (
name == "location" ||
name == "exists" ||
name == "assert" ||
name == "panic" ||
name == "region" ||
@@ -8331,6 +8344,7 @@ gb_internal ExprKind check_basic_directive_expr(CheckerContext *c, Operand *o, A
name == "assert" ||
name == "defined" ||
name == "config" ||
name == "exists" ||
name == "load" ||
name == "load_hash" ||
name == "load_directory" ||
@@ -8854,6 +8868,10 @@ gb_internal void check_compound_literal_field_values(CheckerContext *c, Slice<As
case Type_Array:
ft = bt->Array.elem;
break;
case Type_BitField:
is_constant = false;
ft = bt->BitField.fields[index]->type;
break;
default:
GB_PANIC("invalid type: %s", type_to_string(ft));
break;
@@ -8880,6 +8898,9 @@ gb_internal void check_compound_literal_field_values(CheckerContext *c, Slice<As
case Type_Array:
nested_ft = bt->Array.elem;
break;
case Type_BitField:
nested_ft = bt->BitField.fields[index]->type;
break;
default:
GB_PANIC("invalid type %s", type_to_string(nested_ft));
break;