mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-11 18:33:14 +01:00
Mitigate a nested unions crash/wrong code bug.
This fixes the std.format unit tests for assertion-enabled LLVM builds. What the actual solution for the problem should be depends entirely on the outcome of the "Nested Unions?" discussion on dmd-internals.
This commit is contained in:
@@ -436,6 +436,17 @@ void StructDeclaration::semantic(Scope *sc)
|
||||
protection = sc->protection;
|
||||
alignment = sc->structalign;
|
||||
storage_class |= sc->stc;
|
||||
#if IN_LLVM
|
||||
// DMD allows nested unions with functions that access the outer scope, but
|
||||
// generates invalid code for them (the context pointer is stored at the
|
||||
// same offset as all the union fields, just as if it was a regular member).
|
||||
// LDC would assert on this instead due to a type mismatch when trying to
|
||||
// store the context pointer. This change mitigates the wrong-code/crash
|
||||
// bug – see "[dmd-internals] Nested Unions?" for a discussion on whether
|
||||
// this should be legal or not.
|
||||
if (isUnionDeclaration())
|
||||
storage_class |= STCstatic;
|
||||
#endif
|
||||
if (sc->stc & STCdeprecated)
|
||||
isdeprecated = true;
|
||||
assert(!isAnonymous());
|
||||
|
||||
Reference in New Issue
Block a user