[PATCH] D145852: [Clang][AST] Fix __has_unique_object_representations computation for unnamed bitfields.
Shafik Yaghmour via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 28 18:50:25 PDT 2023
shafik added inline comments.
================
Comment at: clang/test/SemaCXX/type-traits.cpp:2886-2889
+struct UnnamedEmptyBitfield {
+ int named;
+ int : 0;
+};
----------------
royjacobson wrote:
> royjacobson wrote:
> > shafik wrote:
> > > aaron.ballman wrote:
> > > > I think there's one more test to add:
> > > > ```
> > > > struct UnnamedEmptyBitfieldSplit {
> > > > short named;
> > > > int : 0;
> > > > short also_named;
> > > > };
> > > > static_assert(sizeof(UnnamedEmptyBitfieldSplit) != (sizeof(short) * 2));
> > > > static_assert(!has_unique_object_representations<UnnamedEmptyBitfieldSplit>::value, "Bitfield padding");
> > > > ```
> > > Do we also want to check packed structs as well?
> > Do you have a test case where it would matter? Apparently `packed` is specified to ignore zero width bit fields.
> >
> small ping :) @shafik
Apologies, I just realized you thought I meant another zero sized bit-field case whereas I meant just test packed in general w/ non-zero sized bit-fields. The result should match for unpacked but it would be good to verify considering we seem to always get bitten by cases we don't cover.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D145852/new/
https://reviews.llvm.org/D145852
More information about the cfe-commits
mailing list