It was previously the natural type alignment, defined as the maximum of
the field alignments for an aggregate. Make sure an explicit align(N)
overrides it.
Reviewed-on: https://github.com/dlang/dmd/pull/12646
gcc/d/ChangeLog:
PR d/100935
* dmd/MERGE: Merge upstream dmd
f3fdeb578.
-b7d146c4c34469f876a63f26ff19091a7f9d54d7
+f3fdeb578f8cc6d9426d47d2fa144d2078f9ab29
The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository.
}
else if (ident == Id::__xalignof)
{
- e = new IntegerExp(loc, alignsize(), Type::tsize_t);
+ unsigned explicitAlignment = alignment();
+ unsigned naturalAlignment = alignsize();
+ unsigned actualAlignment = (explicitAlignment == STRUCTALIGN_DEFAULT ? naturalAlignment : explicitAlignment);
+ e = new IntegerExp(loc, actualAlignment, Type::tsize_t);
}
else if (ident == Id::_init)
{
static assert(C2.alignof == size_t.sizeof);
static assert(__traits(classInstanceSize, C2) == payloadOffset + 12);
+align(8) struct PaddedStruct
+{
+ bool flag;
+ align(2) S1 s1;
+}
+
+static assert(PaddedStruct.s1.offsetof == 2);
+static assert(PaddedStruct.alignof == 8);
+static assert(PaddedStruct.sizeof == 16);
+
+align(1) struct UglyStruct
+{
+ bool flag;
+ int i;
+ ubyte u;
+}
+
+static assert(UglyStruct.i.offsetof == 4);
+static assert(UglyStruct.alignof == 1);
+static assert(UglyStruct.sizeof == 9);
/***************************************************/
// https://issues.dlang.org/show_bug.cgi?id=19914