Skip to content

Commit

Permalink
Enum attributes would be overwritten by enum value attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
lerno committed Sep 19, 2024
1 parent ff36380 commit 2fec1c8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions releasenotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/sema_decls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion test/test_suite/compile_time/comptime_array_folding.c3t
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 2fec1c8

Please sign in to comment.