mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Bug when defers and $if were combined in a macro, which would cause miscompilation.
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
- Fix broken sincos function.
|
- Fix broken sincos function.
|
||||||
- Bug when a continue is copied in a defer.
|
- Bug when a continue is copied in a defer.
|
||||||
- Compiler error when any/interface initialized using {} #1533.
|
- Compiler error when any/interface initialized using {} #1533.
|
||||||
|
- Bug when defers and $if were combined in a macro, which would cause miscompilation.
|
||||||
|
|
||||||
### Stdlib changes
|
### Stdlib changes
|
||||||
- Remove unintended print of `char[]` as String
|
- Remove unintended print of `char[]` as String
|
||||||
|
|||||||
@@ -2148,7 +2148,7 @@ static inline bool sema_analyse_compound_statement_no_scope(SemaContext *context
|
|||||||
all_ok = false;
|
all_ok = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AstId *next = ast ? &ast->next : &compound_statement->compound_stmt.first_stmt;
|
AstId *next = ast ? &ast_last(ast)->next : &compound_statement->compound_stmt.first_stmt;
|
||||||
context_pop_defers(context, next);
|
context_pop_defers(context, next);
|
||||||
return all_ok;
|
return all_ok;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// #target: macos-x64
|
||||||
int x @if(false) = 1;
|
int x @if(false) = 1;
|
||||||
|
|
||||||
int d @if(true) = 5;
|
int d @if(true) = 5;
|
||||||
|
|||||||
32
test/test_suite/compile_time/ct_if_folding.c3t
Normal file
32
test/test_suite/compile_time/ct_if_folding.c3t
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
// #target: macos-x64
|
||||||
|
module test;
|
||||||
|
|
||||||
|
macro void @test(bool $skip = false)
|
||||||
|
{
|
||||||
|
$if $skip:
|
||||||
|
|
||||||
|
$else
|
||||||
|
int a;
|
||||||
|
int b;
|
||||||
|
defer
|
||||||
|
{
|
||||||
|
a = b;
|
||||||
|
}
|
||||||
|
$endif
|
||||||
|
}
|
||||||
|
|
||||||
|
fn int main() {
|
||||||
|
@test();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/* #expect: test.ll
|
||||||
|
|
||||||
|
entry:
|
||||||
|
%a = alloca i32, align 4
|
||||||
|
%b = alloca i32, align 4
|
||||||
|
store i32 0, ptr %a, align 4
|
||||||
|
store i32 0, ptr %b, align 4
|
||||||
|
%0 = load i32, ptr %b, align 4
|
||||||
|
store i32 %0, ptr %a, align 4
|
||||||
|
ret i32 0
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user