[PATCH] D23325: [WIP] Binding of references to packed fields

Roger Ferrer Ibanez via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 16 10:10:02 PST 2016


rogfer01 marked 15 inline comments as done.
rogfer01 added a comment.

I am retaking this, will upload an updated patch soon.



================
Comment at: lib/AST/Decl.cpp:3523
+  return !isBitField() &&
+         (this->hasAttr<PackedAttr>() || getParent()->hasAttr<PackedAttr>()) &&
+         Context.getDeclAlign(this) <
----------------
rsmith wrote:
> Does this properly handle anonymous struct/union members:
> 
>   struct A __attribute__((packed)) {
>     char a;
>     union { int b; };
>   } a;
>   int &r = a.b;
This test (modulo swapping `A` and `__attribute__((packed))`  positions) works. Do you think we may be missing some case here?


================
Comment at: test/SemaCXX/bind-packed-member.cpp:68-73
+struct F
+{
+    char c;
+    NonTrivialCopy x __attribute__((packed));
+    int w __attribute__((packed));
+} f;
----------------
rsmith wrote:
> Another interesting case:
> 
>     struct __attribute__((packed)) G {
>       char c;
>       NonTrivialCopy x;
>     };
> 
> Here, GCC ignores the `packed` attribute entirely (with a warning). For ABI compatibility, we should do the same.
Will do this in a later update of this patch.

I still have to check what is the best place to check this, though I think once the class-specifier has been completed.


https://reviews.llvm.org/D23325





More information about the cfe-commits mailing list