hubert.reinterpretcast added inline comments.

Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:1908
   // The align if the field is not packed. This is to check if the attribute
   // was unnecessary (-Wpacked).
   CharUnits UnpackedFieldAlign = FieldAlign;
Testing using my build with this patch seems to indicate that tracking 
`FieldAlign` for `UnpackedFieldAlign` does not lead to the desired result.

The `QQ` and `ZZ` cases differ only on the `packed` attribute on `Q`. They are 
observed to have different sizes; however, we get a `-Wpacked` diagnostic 
claiming that the `packed` attribute was unnecessary (and could therefore be 

struct [[gnu::packed]] Q {
  double x [[gnu::aligned(4)]];
struct QQ : Q { char x; };

struct Z {
  double x [[gnu::aligned(4)]];
struct ZZ : Z { char x; };

extern char qx[sizeof(QQ)];
extern char qx[12];
extern char qz[sizeof(ZZ)];
extern char qz[16];

<stdin>:1:24: warning: packed attribute is unnecessary for 'Q' [-Wpacked]
struct [[gnu::packed]] Q {
1 warning generated.

  rG LLVM Github Monorepo


cfe-commits mailing list

Reply via email to