aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorVincent Billet <vingtsang.billet@gmail.com>2025-05-26 08:16:45 +0200
committerGitHub <noreply@github.com>2025-05-26 08:16:45 +0200
commitbb274ab512c6f379930643853c90f3ae7fa03f7e (patch)
tree3737c8dbbdf8e116553cbafcfe70942985328b18 /src/check_expr.cpp
parent1ed05c2498325c97fd6d2856a6a190ab7e5820fc (diff)
parent655fab7227fbd92837c82fdbeea65c9121b0f70b (diff)
Merge branch 'odin-lang:master' into badaxis/Windows-Audio&Winmm
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 167052772..60a4d3a98 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -5461,8 +5461,18 @@ gb_internal Entity *check_selector(CheckerContext *c, Operand *operand, Ast *nod
}
}
+ if (operand->type && is_type_simd_vector(type_deref(operand->type))) {
+ String field_name = selector->Ident.token.string;
+ if (field_name.len == 1) {
+ error(op_expr, "Extracting an element from a #simd array using .%.*s syntax is disallowed, prefer `simd.extract`", LIT(field_name));
+ } else {
+ error(op_expr, "Extracting elements from a #simd array using .%.*s syntax is disallowed, prefer `swizzle`", LIT(field_name));
+ }
+ return nullptr;
+ }
+
if (entity == nullptr && selector->kind == Ast_Ident && operand->type != nullptr &&
- (is_type_array(type_deref(operand->type)) || is_type_simd_vector(type_deref(operand->type)))) {
+ (is_type_array(type_deref(operand->type)))) {
String field_name = selector->Ident.token.string;
if (1 < field_name.len && field_name.len <= 4) {
u8 swizzles_xyzw[4] = {'x', 'y', 'z', 'w'};
@@ -5517,7 +5527,7 @@ gb_internal Entity *check_selector(CheckerContext *c, Operand *operand, Ast *nod
Type *original_type = operand->type;
Type *array_type = base_type(type_deref(original_type));
- GB_ASSERT(array_type->kind == Type_Array || array_type->kind == Type_SimdVector);
+ GB_ASSERT(array_type->kind == Type_Array);
i64 array_count = get_array_type_count(array_type);
@@ -5558,10 +5568,6 @@ gb_internal Entity *check_selector(CheckerContext *c, Operand *operand, Ast *nod
break;
}
- if (array_type->kind == Type_SimdVector) {
- operand->mode = Addressing_Value;
- }
-
Entity *swizzle_entity = alloc_entity_variable(nullptr, make_token_ident(field_name), operand->type, EntityState_Resolved);
add_type_and_value(c, operand->expr, operand->mode, operand->type, operand->value);
return swizzle_entity;
@@ -8070,7 +8076,9 @@ gb_internal ExprKind check_call_expr(CheckerContext *c, Operand *operand, Ast *c
if (pt->kind == Type_Proc && pt->Proc.calling_convention == ProcCC_Odin) {
if ((c->scope->flags & ScopeFlag_ContextDefined) == 0) {
+ ERROR_BLOCK();
error(call, "'context' has not been defined within this scope, but is required for this procedure call");
+ error_line("\tSuggestion: 'context = runtime.default_context()'");
}
}