V3 [PATCH] C/C++: Add -Waddress-of-packed-member
H.J. Lu
hjl.tools@gmail.com
Mon Jul 23 21:24:00 GMT 2018
On Mon, Jun 18, 2018 at 12:26 PM, Joseph Myers <joseph@codesourcery.com> wrote:
> On Mon, 18 Jun 2018, Jason Merrill wrote:
>
>> On Mon, Jun 18, 2018 at 11:59 AM, Joseph Myers <joseph@codesourcery.com> wrote:
>> > On Mon, 18 Jun 2018, Jason Merrill wrote:
>> >
>> >> > + if (TREE_CODE (rhs) == COND_EXPR)
>> >> > + {
>> >> > + /* Check the THEN path first. */
>> >> > + tree op1 = TREE_OPERAND (rhs, 1);
>> >> > + context = check_address_of_packed_member (type, op1);
>> >>
>> >> This should handle the GNU extension of re-using operand 0 if operand
>> >> 1 is omitted.
>> >
>> > Doesn't that just use a SAVE_EXPR?
>>
>> Hmm, I suppose it does, but many places in the compiler seem to expect
>> that it produces a COND_EXPR with TREE_OPERAND 1 as NULL_TREE.
>
> Maybe that's used somewhere inside the C++ front end. For C a SAVE_EXPR
> is produced directly.
>
Here is the updated patch. Changes from the last one:
1. Handle COMPOUND_EXPR.
2. Fixed typos in comments.
3. Combined warn_for_pointer_of_packed_member and
warn_for_address_of_packed_member into
warn_for_address_or_pointer_of_packed_member.
Tested on Linux/x86-64 and Linux/i686. OK for trunk.
Thanks.
--
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-C-C-Add-Waddress-of-packed-member.patch
Type: text/x-patch
Size: 46953 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20180723/3d85c21c/attachment.bin>
More information about the Gcc-patches
mailing list