Skip to content

Commit

Permalink
Fix Bugzilla Issue 24504
Browse files Browse the repository at this point in the history
  • Loading branch information
just-harry committed Apr 19, 2024
1 parent ec25e56 commit 42c9ad6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
15 changes: 13 additions & 2 deletions compiler/src/dmd/tocvdebug.d
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ enum CV8_NAMELENMAX = 0xffff; // length record is 16-bit only

uint cv4_Denum(EnumDeclaration e)
{
import dmd.expression : IntegerExp;

//dbg_printf("cv4_Denum(%s)\n", e.toChars());
const uint property = (!e.members || !e.memtype || !e.memtype.isintegral())
? 0x80 // enum is forward referenced or non-integer
Expand All @@ -159,7 +161,11 @@ uint cv4_Denum(EnumDeclaration e)
EnumMember sf = (*e.members)[i].isEnumMember();
if (!sf)
continue;
const value = sf.value().toInteger();

auto valueExp = sf.value();
if (auto castExp = valueExp.isCastExp())
valueExp = new IntegerExp(castExp.loc, castExp.e1.toInteger(), castExp.type);
const value = valueExp.toInteger();

// store only member's simple name
uint len = 4 + cv4_numericbytes(cast(uint)value) + cv_stringbytes(sf.toChars());
Expand Down Expand Up @@ -218,7 +224,12 @@ uint cv4_Denum(EnumDeclaration e)
continue;

ubyte* p = mc.writePtr();
dinteger_t value = sf.value().toInteger();

auto valueExp = sf.value();
if (auto castExp = valueExp.isCastExp())
valueExp = new IntegerExp(castExp.loc, castExp.e1.toInteger(), castExp.type);
dinteger_t value = valueExp.toInteger();

TOWORD(p, (config.fulltypes == CV8) ? LF_ENUMERATE_V3 : LF_ENUMERATE);
uint attribute = 0;
TOWORD(p + 2, attribute);
Expand Down
7 changes: 7 additions & 0 deletions compiler/test/compilable/test24504.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// REQUIRED_ARGS: -c -os=windows -g

typedef enum
{
HasIntAndUIntValuesInt = 0,
HasIntAndUIntValuesUInt = 0x80000000
} HasIntAndUIntValues;

0 comments on commit 42c9ad6

Please sign in to comment.