Stricter checking of compare_exchange builtin.

This commit is contained in:
Christoffer Lerno
2023-09-16 22:25:03 +02:00
parent ff05128a87
commit 03345bef10
3 changed files with 11 additions and 4 deletions

View File

@@ -215,14 +215,21 @@ static bool sema_expr_analyse_compare_exchange(SemaContext *context, Expr *expr)
Expr *pointer = args[0];
if (!sema_analyse_expr(context, pointer)) return false;
bool optional = IS_OPTIONAL(pointer);
Type *comp_type = type_flatten(pointer->type);
if (!type_is_pointer(comp_type)) RETURN_SEMA_ERROR(pointer, "Expected a pointer here.");
Type *pointee = comp_type->pointer;
for (int i = 1; i < 3; i++)
{
if (!sema_analyse_expr_rhs(context, pointee, args[i], true)) return false;
Expr *arg = args[i];
if (!sema_analyse_expr_rhs(context, pointee == type_void ? NULL : pointee, arg, true)) return false;
if (pointee == type_void) pointee = arg->type->canonical;
if (!type_is_atomic(type_flatten(arg->type)))
{
RETURN_SEMA_ERROR(arg, "%s may not be used with atomics.", type_quoted_error_string(arg->type));
}
optional = optional || IS_OPTIONAL(args[i]);
}
for (int i = 3; i < 5; i++)

View File

@@ -459,7 +459,7 @@ static void x86features_as_diff_to_scratch(X86Features *cpu_features, X86CpuSet
x86_features_add_feature(&diff, X86_FEAT_CMPXCHG8B);
break;
}
for (int i = 0; i <= X86_FEATURE_LAST; i++)
for (X86Feature i = 0; i <= X86_FEATURE_LAST; i++)
{
if (i == X86_FEAT_AVX5124FMAPS || i == X86_FEAT_AVX5124VNNIW) continue;
bool diff_has = x64features_contains(&diff, (X86Feature)i);

View File

@@ -1 +1 @@
#define COMPILER_VERSION "0.4.648"
#define COMPILER_VERSION "0.4.649"