erichkeane added inline comments.
================
Comment at: lib/AST/ASTContext.cpp:2213
+ Field->isBitField()
+ ? Field->getBitWidthValue(Context)
+ : Context.toBits(Context.getTypeSizeInChars(Field->getType()));
----------------
erichkeane wrote:
> rsmith wrote:
> > This isn't quite right; you want min(bitfield length, bit size of type)
> > here. Eg, a `bool b : 8` or `int n : 1000` bitfield has padding bits.
> I guess I'm missing something with this comment... why would a bitfield with
> bool b: 8 have padding?
>
> Additionally, isn't int n : 1000 illegal, since 1000 > 32 (# bits in an int)?
> Both clang and GCC reject the 2nd case. Curiously, GCC rejects bool b: 9,
> but Clang seems to allow 'bool' to have ANY size. Is that an error itself?
>
> Finally: Should we consider ANY bool to be not a unique object
> representation? It has 1 bit of data, but 8 bits of storage. GCC's
> implementation of this trait accepts them, but I'm second guessing that at
> the moment...
I did a bit more looking into this... In the 'TYPE b: X' case, 'X' is always
the size of the field, so :
struct Bitfield {
bool b: 16;
};
static_assert(sizeof(Bitfield) == 2);
The rest of my padding detection works correctly.
https://reviews.llvm.org/D39347
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits