Imply #no_capture to all variadic parameters

This commit is contained in:
gingerBill
2024-07-14 12:19:47 +01:00
parent 891cf54b5c
commit 8642d719f0
25 changed files with 125 additions and 117 deletions
+9 -1
View File
@@ -2065,9 +2065,10 @@ gb_internal Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_para
} else if (p->flags & FieldFlag_c_vararg) {
error(name, "'#no_capture' cannot be applied to a #c_vararg parameter");
p->flags &= ~FieldFlag_no_capture;
} else {
error(name, "'#no_capture' is already implied on all variadic parameter");
}
}
if (is_poly_name) {
if (p->flags&FieldFlag_no_alias) {
error(name, "'#no_alias' can only be applied to non constant values");
@@ -2085,6 +2086,11 @@ gb_internal Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_para
error(name, "'#by_ptr' can only be applied to variable fields");
p->flags &= ~FieldFlag_by_ptr;
}
if (p->flags&FieldFlag_no_capture) {
error(name, "'#no_capture' can only be applied to variable fields");
p->flags &= ~FieldFlag_no_capture;
}
if (!is_type_polymorphic(type) && check_constant_parameter_value(type, params[i])) {
// failed
@@ -2104,6 +2110,8 @@ gb_internal Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_para
param->flags |= EntityFlag_Ellipsis;
if (is_c_vararg) {
param->flags |= EntityFlag_CVarArg;
} else {
param->flags |= EntityFlag_NoCapture;
}
}
-1
View File
@@ -344,7 +344,6 @@ struct lbProcedure {
Array<lbNoCaptureData> no_captures;
LLVMValueRef temp_callee_return_struct_memory;
Ast *curr_stmt;
Array<Scope *> scope_stack;
+3 -2
View File
@@ -330,10 +330,11 @@ enum FieldFlag : u32 {
FieldFlag_subtype = 1<<7,
FieldFlag_by_ptr = 1<<8,
FieldFlag_no_broadcast = 1<<9, // disallow array programming
FieldFlag_no_capture = 1<<10,
FieldFlag_no_capture = 1<<11,
// Internal use by the parser only
FieldFlag_Tags = 1<<11,
FieldFlag_Tags = 1<<15,
FieldFlag_Results = 1<<16,