mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Fix of issue with "a ?? false"
This commit is contained in:
@@ -296,6 +296,7 @@ extern fn CFile tmpnam(char* str);
|
|||||||
extern fn int fprintf(CFile stream, char* format, ...);
|
extern fn int fprintf(CFile stream, char* format, ...);
|
||||||
extern fn int printf(char* format, ...);
|
extern fn int printf(char* format, ...);
|
||||||
extern fn int sprintf(char* str, char* format, ...);
|
extern fn int sprintf(char* str, char* format, ...);
|
||||||
|
extern fn int snprintf(char* str, usize size, char* format, ...);
|
||||||
extern fn int fscanf(CFile stream, char* format, ...);
|
extern fn int fscanf(CFile stream, char* format, ...);
|
||||||
extern fn int scanf(char* format, ...);
|
extern fn int scanf(char* format, ...);
|
||||||
extern fn int sscanf(char* str, char* format, ...);
|
extern fn int sscanf(char* str, char* format, ...);
|
||||||
|
|||||||
@@ -3523,13 +3523,27 @@ static void gencontext_emit_or_error(GenContext *c, BEValue *be_value, Expr *exp
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMValueRef phi = LLVMBuildPhi(c->builder, llvm_get_type(c, expr->type), "val");
|
if (expr->type->type_kind == TYPE_BOOL)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
LLVMValueRef logic_values[2] = { normal_value.value, else_value.value };
|
LLVMValueRef logic_values[2] = { normal_value.value, else_value.value };
|
||||||
LLVMBasicBlockRef blocks[2] = { success_end_block, else_block_exit };
|
LLVMBasicBlockRef blocks[2] = { success_end_block, else_block_exit };
|
||||||
LLVMAddIncoming(phi, logic_values, blocks, 2);
|
|
||||||
|
|
||||||
llvm_value_set(be_value, phi, expr->type);
|
|
||||||
|
if (expr->type->type_kind == TYPE_BOOL)
|
||||||
|
{
|
||||||
|
LLVMValueRef phi = LLVMBuildPhi(c->builder, c->bool_type, "val");
|
||||||
|
LLVMAddIncoming(phi, logic_values, blocks, 2);
|
||||||
|
llvm_value_set_bool(be_value, phi);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LLVMValueRef phi = LLVMBuildPhi(c->builder, llvm_get_type(c, expr->type), "val");
|
||||||
|
LLVMAddIncoming(phi, logic_values, blocks, 2);
|
||||||
|
llvm_value_set(be_value, phi, expr->type);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
#define COMPILER_VERSION "PRE.27"
|
#define COMPILER_VERSION "PRE.28"
|
||||||
32
test/test_suite/errors/or_err_bool.c3t
Normal file
32
test/test_suite/errors/or_err_bool.c3t
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
module test;
|
||||||
|
|
||||||
|
fn void tester()
|
||||||
|
{
|
||||||
|
bool! x = false;
|
||||||
|
x ?? true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* #expect: test.ll
|
||||||
|
|
||||||
|
define void @test.tester() #0 {
|
||||||
|
entry:
|
||||||
|
%x = alloca i8, align 1
|
||||||
|
%x.f = alloca i64, align 8
|
||||||
|
store i8 0, i8* %x, align 1
|
||||||
|
store i64 0, i64* %x.f, align 8
|
||||||
|
%0 = load i64, i64* %x.f, align 8
|
||||||
|
%not_err = icmp eq i64 %0, 0
|
||||||
|
br i1 %not_err, label %after_check, label %else_block
|
||||||
|
|
||||||
|
after_check: ; preds = %entry
|
||||||
|
%1 = load i8, i8* %x, align 1
|
||||||
|
%2 = trunc i8 %1 to i1
|
||||||
|
br label %phi_block
|
||||||
|
|
||||||
|
else_block: ; preds = %entry
|
||||||
|
br label %phi_block
|
||||||
|
|
||||||
|
phi_block: ; preds = %else_block, %after_check
|
||||||
|
%val = phi i1 [ %2, %after_check ], [ true, %else_block ]
|
||||||
|
ret void
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user