Fix Bugzilla Issue 24504 - ImportC: Enum declarations with a mixture of int and uint literal values cause errors, when targeting Windows, when debug info generation is enabled. (#16385)

This commit is contained in:
Harry Gillanders 2024-06-01 05:58:50 +01:00 committed by GitHub
parent ee4f5a04ff
commit f053ab07d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 1 deletions

View file

@ -325,7 +325,10 @@ void enumSemantic(Scope* sc, EnumDeclaration ed)
if (EnumMember em = s.isEnumMember())
{
em.type = commonType;
em.value = em.value.castTo(sc, commonType);
// optimize out the cast so that other parts of the compiler can
// assume that an integral enum's members are `IntegerExp`s.
// https://issues.dlang.org/show_bug.cgi?id=24504
em.value = em.value.castTo(sc, commonType).optimize(WANTvalue);
}
});
}

View file

@ -0,0 +1,10 @@
// REQUIRED_ARGS: -os=windows -g
// DISABLED: osx
// This is disabled on macOS because ld complains about _main being undefined
// when clang attempts to preprocess the C file.
typedef enum
{
HasIntAndUIntValuesInt = 0,
HasIntAndUIntValuesUInt = 0x80000000
} HasIntAndUIntValues;