This is an archive of the discontinued LLVM Phabricator instance.

Remove -Wpacked false positive for non-pod types where the layout isn't directly changed
ClosedPublic

Authored by dblaikie on Apr 25 2023, 1:06 PM.

Details

Summary

The packed attribute can still be useful in this case if the struct is
then placed inside another packed struct - the non-pod element type's
packed attribute declares that it's OK to misalign this element inside
the packed structure. (otherwise the non-pod element is not packed/its
alignment is preserved, as per D117616/2771233)

Fixes PR62353

Diff Detail

Event Timeline

dblaikie created this revision.Apr 25 2023, 1:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 25 2023, 1:06 PM
dblaikie requested review of this revision.Apr 25 2023, 1:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 25 2023, 1:06 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Precommit CI found a valid issue (at least on Debian, the Windows failure appears to be unrelated but it's really hard to tell from that output). Also, this should have a release note, right?

clang/lib/AST/RecordLayoutBuilder.cpp
2203–2208

You probably should update the comment to explain the new changes.

dblaikie updated this revision to Diff 519245.May 3 2023, 2:00 PM

Release note
Restrict change to Clang ABI 16 and above (& test that condition)
Fix AIX test

dblaikie updated this revision to Diff 519247.May 3 2023, 2:04 PM

Describe condition in comment

dblaikie marked an inline comment as done.May 3 2023, 2:05 PM

Precommit CI found a valid issue (at least on Debian, the Windows failure appears to be unrelated but it's really hard to tell from that output).

Hmm, right ,yeah, valid test failure - fixed.

Also, this should have a release note, right?

Happy to add one. (done)

aaron.ballman accepted this revision.May 4 2023, 1:34 PM

LGTM aside from a nit with the release notes. Thank you for the fix!

clang/docs/ReleaseNotes.rst
114–118

I think this should move down to Improvements to Clang's diagnostics instead of adding a new category for it.

This revision is now accepted and ready to land.May 4 2023, 1:34 PM
This revision was landed with ongoing or failed builds.May 8 2023, 5:15 PM
This revision was automatically updated to reflect the committed changes.
dblaikie marked an inline comment as done.
dblaikie added inline comments.May 8 2023, 5:15 PM
clang/docs/ReleaseNotes.rst
114–118

Ah, hadn't spotted that category - thanks!

dblaikie added inline comments.May 8 2023, 6:03 PM
clang/docs/ReleaseNotes.rst
114–118

Failed to include the fix there in the initial commit, but got it in 793c5b1