Commit graph

7 commits

Author SHA1 Message Date
Martin
bda56b7263 Adapt lit-tests to new mangling scheme
Only those failing on Win64 so far.
2017-11-05 21:58:12 +01:00
Martin
a3caabdce8 Fix tests/codegen/union.d on 32-bit Linux
Where ulong.alignof == 4.
2017-10-20 21:02:45 +02:00
Martin
d53ffb6ebb Adapt lit-tests to new Win32 D mangling 2017-10-07 14:06:17 +02:00
Martin
6eb62236d4 Use IRState::setGlobalVarInitializer() for struct/class init symbols
Thereby allowing T.init with explicit initializers for dominated members in
nested unions, fixing issue #2108.
2017-06-17 23:57:24 +02:00
Martin
0fda2d271f Fix dynamic initialization of unions
The front-end fills in missing init expressions (except for the nested
context pointer in most cases), so there are no implicitly initialized
fields for dynamically initialized struct literals.

The front-end is also supposed to make sure there are no overlapping
initializers by using null-expressions for overridden fields, but doesn't
in some cases (DMD issue 16471).
Instead of preferring the first one in lexical field order, now use the
lexically last one to mimic DMD.

The previous code iterated over the fields in lexical order and ignored
the initializer for a field if there were earlier declared fields with
greater offset (and an initializer expression), which is wrong for
anonymous structs inside a union:

union {
  struct { int i1;            long l = 123; }
  struct { int i2; int x = 1;               }
}

`x` was previously initialized with 0 (treated as padding).
2016-10-25 01:06:44 +02:00
Martin
10b0261200 Zext i1 constants for scalar Boolean struct fields to i8 2016-10-23 17:31:02 +02:00
Martin
ab1432ed06 Use the regular LL type for all init symbols and most globals
There's no <Type>_init type for aggregates (structs and classes) anymore,
effectively eliminating a *lot* of named LLVM types, some bitcasts as well
as replacements of globals etc.

To get there, it was even required to use the regular type for compatible
literals too, otherwise structs embedded as fields in other aggregates had
an anonymous type (well, the LLVM constant for the field initializer had)
and so the container initializer wasn't compatible with the regular type
anymore.

What was also necessary was a fix wrt. static arrays of bools (LLVM
constant of type `[N x i1]` vs. `[N x i8]` for regular type).
I also had to change the initializer for `char[2][3] x = 0xff` from
`[6 x i8]` to `[3 x [2 x i8]]`, i.e., NOT flattening multi-dimensional
inits from a scalar.

So only literals with overlapping (union) fields and an explicit
initializer initializing dominated non-alias union fields should still
have a mismatching anonymous type - i.e., very, very few cases.
2016-10-23 02:52:51 +02:00