mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
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:
@@ -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
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
58
test/test_suite/distinct/distinct_sub.c3t
Normal file
58
test/test_suite/distinct/distinct_sub.c3t
Normal 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);
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user