[PATCH] D125167: [WIP] Fix member access of anonymous struct/union fields in C
Tom Honermann via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 9 08:56:43 PDT 2022
tahonermann added inline comments.
================
Comment at: clang/docs/ReleaseNotes.rst:152-157
+- When forming a member expression, now consider any qualifiers written on an
+ anonymous structure or union as also applying to the field being referenced.
+ This fixes an issue where qualifiers were being ignored, allowing you to
+ assign to a ``const`` field. Note that qualifiers are ignored in C++ and for
+ Microsoft's extension of anonymous objects. This fixes
+ `Issues 48099 <https://github.com/llvm/llvm-project/issues/48099>`_.
----------------
Perhaps the first sentence should clarify that it applies only to C modes? Though the code changes don't appear to be specific to C.
I'm confused by "Note that qualifiers are ignored in C++ and for Microsoft's extension of anonymous objects". I find it very surprising that cv-qualifiers would be ignored in C++. Unless there is a relevant core issue?
================
Comment at: clang/test/Sema/anonymous-struct-union.c:137-140
+ // It's the access path that picks up the qualifiers, not the direct
+ // declaration of the field itself. So 'i' and 'j' are both 'int'.
+ _Static_assert(_Generic(x.i, int : 1, default : 0), "i is not int?");
+ _Static_assert(_Generic(x.j, int : 1, default : 0), "j is not int?");
----------------
Top-level cv-qualifiers are ignored in generic selection expressions, so I'm not sure what these assertions are intended to ensure.
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