Pass 'va_end'

This commit is contained in:
David Gonzalez Martin 2025-06-13 18:15:26 -06:00
parent 4c0b77d8ba
commit 5702d601df
4 changed files with 13 additions and 2 deletions

View File

@ -51,3 +51,6 @@ target_link_libraries(bb PUBLIC llvm_bindings)
add_compile_options(-Wall -Wextra -pedantic -Wpedantic -Werror -Wno-c99-extensions -Wno-unused-function -Wno-missing-designated-field-initializers -fno-signed-char -fwrapv -fno-strict-aliasing) add_compile_options(-Wall -Wextra -pedantic -Wpedantic -Werror -Wno-c99-extensions -Wno-unused-function -Wno-missing-designated-field-initializers -fno-signed-char -fwrapv -fno-strict-aliasing)
add_compile_definitions(CMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}") add_compile_definitions(CMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}")
add_compile_definitions(BB_CI=${BB_CI}) add_compile_definitions(BB_CI=${BB_CI})
# add_compile_options(-fsanitize=address)
# add_link_options(-fsanitize=address)

View File

@ -8510,6 +8510,7 @@ analyze_type = fn (module: &Module, value: &Value, expected_type: &Type, analysi
// TODO: this is the default case // TODO: this is the default case
.ampersand, .ampersand,
.exclamation, .exclamation,
.va_end,
=> =>
{ {
>is_boolean = unary_is_boolean(unary_id); >is_boolean = unary_is_boolean(unary_id);
@ -11120,6 +11121,10 @@ emit_value = fn (module: &Module, value: &Value, type_kind: TypeKind, expect_con
{ {
llvm_value = llvm_unary_value; llvm_value = llvm_unary_value;
}, },
.va_end =>
{
llvm_value = emit_intrinsic_call(module, ."llvm.va_end", [ module.llvm.pointer_type ][..], [ llvm_unary_value ][..]);
},
else => { #trap(); }, else => { #trap(); },
} }
}, },
@ -13717,6 +13722,7 @@ names: [_][]u8 =
"struct_varargs", "struct_varargs",
"struct_zero", "struct_zero",
"unreachable", "unreachable",
"varargs",
]; ];
[export] main = fn [cc(c)] (argument_count: u32, argv: &&u8, envp: &&u8) s32 [export] main = fn [cc(c)] (argument_count: u32, argv: &&u8, envp: &&u8) s32

View File

@ -7065,7 +7065,8 @@ fn void analyze_block(Module* module, Block* block)
fn LLVMValueRef emit_constant_array(Module* module, Slice<Value*> elements, Type* element_type) fn LLVMValueRef emit_constant_array(Module* module, Slice<Value*> elements, Type* element_type)
{ {
LLVMValueRef value_buffer[64]; LLVMValueRef value_buffer[128];
assert(elements.length <= array_length(value_buffer));
resolve_type_in_place(module, element_type); resolve_type_in_place(module, element_type);

View File

@ -1937,7 +1937,7 @@ fn Value* parse_left(Module* module, Scope* scope, ValueBuilder builder)
case TokenId::left_bracket: case TokenId::left_bracket:
{ {
u64 element_count = 0; u64 element_count = 0;
Value* value_buffer[64]; Value* value_buffer[128];
skip_space(module); skip_space(module);
@ -1976,6 +1976,7 @@ fn Value* parse_left(Module* module, Scope* scope, ValueBuilder builder)
} }
auto value = parse_value(module, scope, {}); auto value = parse_value(module, scope, {});
assert(element_count < array_length(value_buffer));
value_buffer[element_count] = value; value_buffer[element_count] = value;
element_count += 1; element_count += 1;