Fix use of deprecated function. Fix bug when compile time subtracting a distinct type. Fix test/benchmark debug info use.

This commit is contained in:
Christoffer Lerno
2024-08-19 09:36:45 +02:00
parent cb7116f08b
commit 6de17b9ae9
5 changed files with 70 additions and 14 deletions

View File

@@ -78,6 +78,7 @@
- Incorrect zero analysis on `foo["test"] = {}` #1360.
- Bug converting untyped list #1360.
- Benchmark / test no longer suppresses debug info. #1364.
- Bug when compile time subtracting a distinct type.
### Stdlib changes

View File

@@ -1303,6 +1303,9 @@ INLINE GenContext *llvm_gen_tests(Module** modules, unsigned module_count, LLVMC
Path *test_path = path_create_from_string("_$test", 5, INVALID_SPAN);
Module *test_module = compiler_find_or_create_module(test_path, NULL);
DebugInfo actual_debug_info = compiler.build.debug_info;
compiler.build.debug_info = DEBUG_INFO_NONE;
GenContext *c = cmalloc(sizeof(GenContext));
gencontext_init(c, test_module, shared_context);
gencontext_begin_module(c);
@@ -1365,11 +1368,7 @@ INLINE GenContext *llvm_gen_tests(Module** modules, unsigned module_count, LLVMC
llvm_gen_test_main(c);
}
if (llvm_use_debug(c))
{
LLVMDIBuilderFinalize(c->debug.builder);
LLVMDisposeDIBuilder(c->debug.builder);
}
compiler.build.debug_info = actual_debug_info;
return c;
}
@@ -1401,6 +1400,8 @@ INLINE GenContext *llvm_gen_benchmarks(Module** modules, unsigned module_count,
Path *benchmark_path = path_create_from_string("$benchmark", 10, INVALID_SPAN);
Module *benchmark_module = compiler_find_or_create_module(benchmark_path, NULL);
DebugInfo actual_debug_info = compiler.build.debug_info;
compiler.build.debug_info = DEBUG_INFO_NONE;
GenContext *c = cmalloc(sizeof(GenContext));
gencontext_init(c, benchmark_module, shared_context);
gencontext_begin_module(c);
@@ -1463,11 +1464,7 @@ INLINE GenContext *llvm_gen_benchmarks(Module** modules, unsigned module_count,
llvm_gen_benchmark_main(c);
}
if (llvm_use_debug(c))
{
LLVMDIBuilderFinalize(c->debug.builder);
LLVMDisposeDIBuilder(c->debug.builder);
}
compiler.build.debug_info = actual_debug_info;
return c;
}

View File

@@ -5739,12 +5739,12 @@ static bool sema_expr_analyse_sub(SemaContext *context, Expr *expr, Expr *left,
Type *type = expr->type;
expr_replace(expr, left);
expr->type = type;
switch (left_type->type_kind)
switch (left->const_expr.const_kind)
{
case ALL_INTS:
case CONST_INTEGER:
expr->const_expr.ixx = int_sub(left->const_expr.ixx, right->const_expr.ixx);
break;
case ALL_FLOATS:
case CONST_FLOAT:
expr->const_expr.fxx = float_sub(left->const_expr.fxx, right->const_expr.fxx);
break;
default:

View File

@@ -0,0 +1,58 @@
distinct Foo = uint;
macro @test($abc)
{
return 1u << ($abc - 1);
}
const Foo TEST = 5;
const Foo TEST_1 = @test(TEST);
macro @test2($abc)
{
return 1u << ($abc + 1);
}
const Foo TEST_2 = @test2(TEST);
macro @test3($abc)
{
return 1u << ($abc * 2);
}
const Foo TEST_3 = @test3(TEST);
macro @test4($abc)
{
return 1u << ($abc / 2);
}
const Foo TEST_4 = @test4(TEST);
macro @test5($abc)
{
return 1u << ($abc % 2);
}
const Foo TEST_5 = @test5(TEST);
macro @test6($abc)
{
return 1u << ($abc >> 1);
}
const Foo TEST_6 = @test6(TEST);
macro @test7($abc)
{
return 1u << ($abc >> 1);
}
const Foo TEST_7 = @test7(TEST);
macro @test8($abc)
{
return 1u << ($abc ^ 1);
}
const Foo TEST_8 = @test8(TEST);

View File

@@ -363,7 +363,7 @@ fn void! test_path_is_absolute()
fn void! test_path_absolute()
{
$if env::WIN32:
assert(path::new_windows(`C:\abs`).absolute()!.str_view() == `C:\abs`);
assert(path::new_windows(`C:\abs`).new_absolute()!.str_view() == `C:\abs`);
$else
assert(path::new_posix("/").new_absolute()!.str_view() == "/");
assert(path::new_posix(".").new_absolute()!.str_view() == path::temp_cwd()!!.str_view());