[PATCH] D79719: [AIX] Implement AIX special alignment rule about double/long double
Hubert Tong via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 7 17:59:51 PDT 2020
hubert.reinterpretcast added inline comments.
================
Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1254
+ // space or zero-extent array.
+ if (DefaultsToAIXPowerAlignment && !getDataSize().isZero()) {
+ PreferredBaseAlign = BaseAlign;
----------------
This needs to check `HandledFirstNonOverlappingEmptyField`:
```
struct A {
char x[0];
};
struct B {
double d;
};
struct C : A, B { char x; } c;
```
================
Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1255
+ if (DefaultsToAIXPowerAlignment && !getDataSize().isZero()) {
+ PreferredBaseAlign = BaseAlign;
+ }
----------------
Note that `PreferredBaseAlign` is only truly meaningful after this line, and related fields, such as `UnpackedPreferredBaseAlign`, require similar treatment. With `UnpackedAlignTo` being dependent on a meaningful value of `UnpackedPreferredBaseAlign`, it needs an update here as well.
Consider the following source. Noting that `C` and `D` are identical except for the packed attribute and yield identical layout properties despite that difference, we should be getting a `-Wpacked` warning with `-Wpacked` (but it is missing).
```
struct A {
double d;
};
struct B {
char x[8];
};
struct [[gnu::packed]] C : B, A { // expected-warning {{packed attribute is unnecessary}}
char x alignas(4)[8];
} c;
struct D : B, A {
char x alignas(4)[8];
} d;
```
```
*** Dumping AST Record Layout
0 | struct C
0 | struct B (base)
0 | char [8] x
8 | struct A (base)
8 | double d
16 | char [8] x
| [sizeof=24, dsize=24, align=4, preferredalign=4,
| nvsize=24, nvalign=4, preferrednvalign=4]
```
```
*** Dumping AST Record Layout
0 | struct D
0 | struct B (base)
0 | char [8] x
8 | struct A (base)
8 | double d
16 | char [8] x
| [sizeof=24, dsize=24, align=4, preferredalign=4,
| nvsize=24, nvalign=4, preferrednvalign=4]
```
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D79719/new/
https://reviews.llvm.org/D79719
More information about the cfe-commits
mailing list