mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
- Member access on a struct returned by the assignment expression, cause crash #2947
This commit is contained in:
@@ -46,6 +46,7 @@
|
|||||||
- `--safe=no` disabled compile-time errors on compile-time known runtime @require checks #2936
|
- `--safe=no` disabled compile-time errors on compile-time known runtime @require checks #2936
|
||||||
- On assert known false, the message was not show for no-args.
|
- On assert known false, the message was not show for no-args.
|
||||||
- Adding the incorrect sized vector to a pointer vector would cause a crash.
|
- Adding the incorrect sized vector to a pointer vector would cause a crash.
|
||||||
|
- Member access on a struct returned by the assignment expression, cause crash #2947
|
||||||
|
|
||||||
## 0.7.9 Change list
|
## 0.7.9 Change list
|
||||||
|
|
||||||
|
|||||||
@@ -216,7 +216,14 @@ BEValue llvm_emit_assign_expr(GenContext *c, BEValue *ref, Expr *ref_expr, Expr
|
|||||||
if (ref_expr && c->current_block) llvm_emit_expr(c, ref, ref_expr);
|
if (ref_expr && c->current_block) llvm_emit_expr(c, ref, ref_expr);
|
||||||
}
|
}
|
||||||
if (!c->current_block) goto AFTER_STORE;
|
if (!c->current_block) goto AFTER_STORE;
|
||||||
if (value.type != type_void) llvm_store(c, ref, &value);
|
if (value.type == type_void)
|
||||||
|
{
|
||||||
|
value = *ref;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
llvm_store(c, ref, &value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optional)
|
if (optional)
|
||||||
|
|||||||
28
test/test_suite/expressions/assign_from_call_to_struct.c3t
Normal file
28
test/test_suite/expressions/assign_from_call_to_struct.c3t
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
// #target: macos-x64
|
||||||
|
module test;
|
||||||
|
struct Test
|
||||||
|
{
|
||||||
|
long a;
|
||||||
|
long b;
|
||||||
|
char c;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn Test f() => {};
|
||||||
|
|
||||||
|
fn int main()
|
||||||
|
{
|
||||||
|
Test t;
|
||||||
|
(t = f()).b;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* #expect: test.ll
|
||||||
|
|
||||||
|
define i32 @main() #0 {
|
||||||
|
entry:
|
||||||
|
%t = alloca %Test, align 8
|
||||||
|
call void @llvm.memset.p0.i64(ptr align 8 %t, i8 0, i64 24, i1 false)
|
||||||
|
call void @test.f(ptr sret(%Test) align 8 %t)
|
||||||
|
%ptradd = getelementptr inbounds i8, ptr %t, i64 8
|
||||||
|
ret i32 0
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user