[PATCH] D125167: [WIP] Fix member access of anonymous struct/union fields in C

Nick Desaulniers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 9 12:10:45 PDT 2022


nickdesaulniers accepted this revision.
nickdesaulniers added a comment.
This revision is now accepted and ready to land.

Consider adding an AST test; that was something that came up in my patch https://reviews.llvm.org/D95408.

> I'm pushing back on the WG14 lists to see if this is a good opportunity to clarify the other direction and be compatible with C++ in the process.

It would really be good to have some clarification from WG14 added to the spec; as is, code is being written in the Linux kernel that uses this functionality to avoid marking all members of an anonymous aggregate as `const`. This is resulting in code being submitted where clang doesn't error on modification of such members, while GCC errors, so such patches are rejected.  So developers using clang are getting caught off guard for a code base that needs to be compiler portable.

Kernel developers were of the opinion that it is nice syntactic sugar. For that reason, I agree with them. But I'm also fine leaving this out of clang until the spec is amended to clarify.  That said, if WG14 doesn't pursue this (but doesn't reject or accept), I'd like to have this in clang sooner for better compatibility with GCC.  It is too bad though if WG14 chooses to further diverge C from C++ over this...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125167/new/

https://reviews.llvm.org/D125167



More information about the cfe-commits mailing list