mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
- Bug with slice acces as inline struct member #2088.
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
- Regression with invalid setup of the WASM temp allocator.
|
- Regression with invalid setup of the WASM temp allocator.
|
||||||
- Correctly detect multiple overloads of the same type.
|
- Correctly detect multiple overloads of the same type.
|
||||||
- ABI bug on x64 Linux / MacOS when passing a union containing a struct of 3 floats. #2087
|
- ABI bug on x64 Linux / MacOS when passing a union containing a struct of 3 floats. #2087
|
||||||
|
- Bug with slice acces as inline struct member #2088.
|
||||||
|
|
||||||
### Stdlib changes
|
### Stdlib changes
|
||||||
- Hash functions for integer vectors and arrays.
|
- Hash functions for integer vectors and arrays.
|
||||||
|
|||||||
@@ -5362,13 +5362,13 @@ CHECK_DEEPER:
|
|||||||
if (flat_type->type_kind == TYPE_SLICE)
|
if (flat_type->type_kind == TYPE_SLICE)
|
||||||
{
|
{
|
||||||
// Handle literal "foo".len which is now a slice.
|
// Handle literal "foo".len which is now a slice.
|
||||||
sema_expr_flatten_const_ident(parent);
|
sema_expr_flatten_const_ident(current_parent);
|
||||||
if (expr_is_const_string(parent))
|
if (expr_is_const_string(current_parent))
|
||||||
{
|
{
|
||||||
expr_rewrite_const_int(expr, type_isz, parent->const_expr.bytes.len);
|
expr_rewrite_const_int(expr, type_isz, current_parent->const_expr.bytes.len);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
expr_rewrite_slice_len(expr, parent, type_usz);
|
expr_rewrite_slice_len(expr, current_parent, type_usz);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (flat_type->type_kind == TYPE_ARRAY || flat_type->type_kind == TYPE_VECTOR)
|
if (flat_type->type_kind == TYPE_ARRAY || flat_type->type_kind == TYPE_VECTOR)
|
||||||
@@ -5385,7 +5385,7 @@ CHECK_DEEPER:
|
|||||||
if (flat_type->type_kind == TYPE_TYPEID)
|
if (flat_type->type_kind == TYPE_TYPEID)
|
||||||
{
|
{
|
||||||
bool was_error = false;
|
bool was_error = false;
|
||||||
if (sema_expr_rewrite_to_typeid_property(context, expr, parent, kw, &was_error)) return !was_error;
|
if (sema_expr_rewrite_to_typeid_property(context, expr, current_parent, kw, &was_error)) return !was_error;
|
||||||
}
|
}
|
||||||
if (flat_type->type_kind == TYPE_VECTOR)
|
if (flat_type->type_kind == TYPE_VECTOR)
|
||||||
{
|
{
|
||||||
@@ -5486,7 +5486,7 @@ CHECK_DEEPER:
|
|||||||
if (!sema_analyse_decl(context, decl)) return false;
|
if (!sema_analyse_decl(context, decl)) return false;
|
||||||
Decl *ref = current_parent->const_expr.enum_val;
|
Decl *ref = current_parent->const_expr.enum_val;
|
||||||
if (!sema_analyse_decl(context, ref)) return false;
|
if (!sema_analyse_decl(context, ref)) return false;
|
||||||
ASSERT_SPAN(expr, parent->const_expr.const_kind == CONST_ENUM);
|
ASSERT_SPAN(expr, current_parent->const_expr.const_kind == CONST_ENUM);
|
||||||
Expr *copy_init = copy_expr_single(ref->enum_constant.args[member->var.index]);
|
Expr *copy_init = copy_expr_single(ref->enum_constant.args[member->var.index]);
|
||||||
expr_replace(expr, copy_init);
|
expr_replace(expr, copy_init);
|
||||||
ASSERT_SPAN(expr, copy_init->resolve_status == RESOLVE_DONE);
|
ASSERT_SPAN(expr, copy_init->resolve_status == RESOLVE_DONE);
|
||||||
|
|||||||
22
test/test_suite/struct/inline_slice_access_2088.c3t
Normal file
22
test/test_suite/struct/inline_slice_access_2088.c3t
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
// #target: macos-x64
|
||||||
|
module test;
|
||||||
|
|
||||||
|
struct Foo
|
||||||
|
{
|
||||||
|
inline String str;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn int main()
|
||||||
|
{
|
||||||
|
(Foo){}.len;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* #expect: test.ll
|
||||||
|
|
||||||
|
entry:
|
||||||
|
%literal = alloca %Foo, align 8
|
||||||
|
call void @llvm.memset.p0.i64(ptr align 8 %literal, i8 0, i64 16, i1 false)
|
||||||
|
%ptradd = getelementptr inbounds i8, ptr %literal, i64 8
|
||||||
|
ret i32 0
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user