From 2fec1c83a42a6bd0ff0a02ccd9df70c87ba409d5 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Thu, 19 Sep 2024 23:02:06 +0200 Subject: [PATCH] Enum attributes would be overwritten by enum value attributes. --- releasenotes.md | 1 + src/compiler/sema_decls.c | 2 +- test/test_suite/compile_time/comptime_array_folding.c3t | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/releasenotes.md b/releasenotes.md index c30c04e40..cb09b4278 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -40,6 +40,7 @@ - Temp allocator overwrites data when doing reset on extra allocated pages. #1462 - User defined attributes could not have more than 1 parameter due to bug. - Folding a constant array of structs at compile time would cause an assert. +- Enum attributes would be overwritten by enum value attributes. ### Stdlib changes - Additional init functions for hashmap. diff --git a/src/compiler/sema_decls.c b/src/compiler/sema_decls.c index 0cd88c0cd..2e717177f 100644 --- a/src/compiler/sema_decls.c +++ b/src/compiler/sema_decls.c @@ -1498,7 +1498,7 @@ static inline bool sema_analyse_enum(SemaContext *context, Decl *decl, bool *era Decl *enum_value = enum_values[i]; bool erase_val = false; - if (!sema_analyse_attributes(context, decl, enum_value->attributes, ATTR_ENUM, &erase_val)) return decl_poison(decl); + if (!sema_analyse_attributes(context, enum_value, enum_value->attributes, ATTR_ENUM_VALUE, &erase_val)) return decl_poison(decl); if (erase_val) { diff --git a/test/test_suite/compile_time/comptime_array_folding.c3t b/test/test_suite/compile_time/comptime_array_folding.c3t index 5d695d07a..709f78d16 100644 --- a/test/test_suite/compile_time/comptime_array_folding.c3t +++ b/test/test_suite/compile_time/comptime_array_folding.c3t @@ -59,5 +59,5 @@ fn void main() @test.BAZ2 = local_unnamed_addr constant i32 2, align 4 @test.ABC = local_unnamed_addr constant [1 x %TestUnion] [%TestUnion { i32 112 }], align 4 @test.BCD = local_unnamed_addr constant %TestUnion { i32 112 }, align 4 -@test.MY_VALUE_1 = local_unnamed_addr constant i32 -1, align 4 +@test.MY_VALUE_1 = local_unnamed_addr constant i32 32, align 4 @test.MY_VALUE_2 = local_unnamed_addr constant i32 32, align 4