From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 93893 invoked by alias); 20 Dec 2018 21:43:13 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 93876 invoked by uid 89); 20 Dec 2018 21:43:10 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-ot1-f66.google.com Received: from mail-ot1-f66.google.com (HELO mail-ot1-f66.google.com) (209.85.210.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 20 Dec 2018 21:43:09 +0000 Received: by mail-ot1-f66.google.com with SMTP id 32so3306197ota.12 for ; Thu, 20 Dec 2018 13:43:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=36LMze8fS+QQCG9vFODfVL5j4eAYwwB4TS8t3/W72dw=; b=nIpdU1T6Ps4k9XI40Xy0JGsE07+3xTDN81ZPiKvQPyup8SGwknGfevlLAOqvYiZ/KD V0QqcOi+E7+VdhWX8KIGMIvzG4W5PfzcZYQEMgXZWP+p82F7Qq3bCfh5f4LIVrSQ2b9/ 7sZStBh3zlE7aIVNnzGl3dfXMXCZmDMbs/aP7E9YCzCGMm+cfVTFVoCMc/nDOd04qBlJ BED0HvJiPmLXGcKazpgqtn6CJVUTWy6OY/gQ9Zk7S7mLYHVIbUvk79480mDpP03hpwF6 IedtFDmPwasa/hShvj16YqK9eniQMiMpRuZ4wZlKkcIG11t1q7eH5kabAFlYBExr9A5K xVIA== MIME-Version: 1.0 References: <24f8a201-bb3e-3acb-b679-570a8796358d@redhat.com> <20181218141051.GA3461@gmail.com> <14946d45-0983-12ad-3f93-99da07b3886e@redhat.com> <7f0ae96e-87b8-5db9-97b5-90094c4dace7@redhat.com> <63472b60-a401-5c43-de38-87187cdc95c5@redhat.com> In-Reply-To: From: "H.J. Lu" Date: Thu, 20 Dec 2018 21:47:00 -0000 Message-ID: Subject: Re: V10 [PATCH] C/C++: Add -Waddress-of-packed-member To: Jason Merrill Cc: Sandra Loosemore , Richard Guenther , "Joseph S. Myers" , Martin Sebor , GCC Patches Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-12/txt/msg01505.txt.bz2 On Thu, Dec 20, 2018 at 1:28 PM Jason Merrill wrote: > > On 12/20/18 2:52 PM, H.J. Lu wrote: > > On Thu, Dec 20, 2018 at 11:28 AM Jason Merrill wrote: > >> > >> On 12/19/18 12:35 PM, H.J. Lu wrote: > >>> + while (handled_component_p (rhs)) > >>> + { > >>> + if (TREE_CODE (rhs) == COMPONENT_REF) > >>> + break; > >>> + rhs = TREE_OPERAND (rhs, 0); > >>> + } > >>> + > >>> + if (TREE_CODE (rhs) != COMPONENT_REF) > >>> + return NULL_TREE; > >>> + > >>> + object = TREE_OPERAND (rhs, 0); > >>> + field = TREE_OPERAND (rhs, 1); > >>> + > >>> + tree context = check_alignment_of_packed_member (type, field); > >>> + if (context) > >>> + return context; > >> > >> All the above looks unnecessary; it will be handled by the loop below. > >> > >>> + /* Check alignment of the object. */ > >>> + while (handled_component_p (object)) > >>> + { > >>> + if (TREE_CODE (object) == COMPONENT_REF) > >>> + { > >>> + do > >>> + { > >>> + field = TREE_OPERAND (object, 1); > >>> + context = check_alignment_of_packed_member (type, field); > >>> + if (context) > >>> + return context; > >>> + object = TREE_OPERAND (object, 0); > >>> + } > >>> + while (TREE_CODE (object) == COMPONENT_REF); > >> > >> This inner loop also seems unnecessary. > >> > >>> + } > >>> + else > >>> + object = TREE_OPERAND (object, 0); > >>> + } > >> > >> Jason > > > > I changed it to > > > > static tree > > check_address_of_packed_member (tree type, tree rhs) > > { > > if (INDIRECT_REF_P (rhs)) > > rhs = TREE_OPERAND (rhs, 0); > > > > if (TREE_CODE (rhs) == ADDR_EXPR) > > rhs = TREE_OPERAND (rhs, 0); > > > > tree context = NULL_TREE; > > > > /* Check alignment of the object. */ > > while (handled_component_p (rhs)) > > { > > if (TREE_CODE (rhs) == COMPONENT_REF) > > { > > tree field = TREE_OPERAND (rhs, 1); > > context = check_alignment_of_packed_member (type, field); > > if (context) > > break; > > } > > rhs = TREE_OPERAND (rhs, 0); > > } > > > > return context; > > } > > > > Here is the updated patch. OK for trunk? > > OK. > Checked in. Thanks for everyone, especially Jason. -- H.J.