From patchwork Wed May 29 10:34:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 247231 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 1920D2C0097 for ; Wed, 29 May 2013 20:34:39 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:references:mime-version:content-type :in-reply-to; q=dns; s=default; b=hVAfAXuHaDijEP5r1kdmA1uPJ5m8Yb AVGteWu7Vc1SgECzs+k2i2JSohIGOqD9KWmpE6cLATA6ErHod90qSV6dSiJip0ek G3gfZLygq6MNjVt7zWOUpQicuiMK4S4TMtqCn9Uf1aGNFWURpQ0WkZm4LXrA5kPc 103IXQnbJYlro= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:references:mime-version:content-type :in-reply-to; s=default; bh=CSsr+6x6xv6MDBAitR03i8R4mpg=; b=gTRF 3+3ELeIW/FDcyHi153oCsphv+0YP0axhRLUe2kjzrD3aGDjjlkiD5O7x+lLXSwMu vjwadijkEySjQPqlcLE8C55ypT3CBV7Wl9hQgmg96zVUQtM2CtFQBw3HbImbQ8fT u2D9wKOr7laFngyzNp1J+6b4B7wPIYYmU6T8/w0= Received: (qmail 27105 invoked by alias); 29 May 2013 10:34:32 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 27095 invoked by uid 89); 29 May 2013 10:34:32 -0000 X-Spam-SWARE-Status: No, score=-5.0 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL autolearn=ham version=3.3.1 Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Wed, 29 May 2013 10:34:31 +0000 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D0FEFA5230 for ; Wed, 29 May 2013 12:34:28 +0200 (CEST) Date: Wed, 29 May 2013 12:34:28 +0200 From: Martin Jambor To: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Do not allow non-top-level BIT_FIELD_REFs, IMAGPART_EXPRs or REALPART_EXPRs Message-ID: <20130529103428.GF27165@virgil.suse> Mail-Followup-To: gcc-patches@gcc.gnu.org References: <20130522151105.GF23266@virgil.suse> <4311044.6dSfYhQ6mB@polaris> <20130524132634.GA27165@virgil.suse> <20130528132709.GE27165@virgil.suse> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Hi, On Tue, May 28, 2013 at 03:40:25PM +0200, Richard Biener wrote: > On Tue, 28 May 2013, Martin Jambor wrote: > > I've committed it s revision 199379, thanks. As far as the > > non-top-levelness is concerned, the following (on top of the previous > > patch) also survives bootstrap and testsuite on x86_64 (all languages > > including Ada and Obj-C++). Do you think it would be acceptable as > > well? > > With the following minor adjustment: > > > Thanks, > > > > Martin > > > > > > 2013-05-27 Martin Jambor > > > > * tree-cfg.c (verify_expr): Verify that BIT_FIELD_REF, REALPART_EXPR > > and IMAGPART_EXPR do not occur within other handled_components. > > > > Index: src/gcc/tree-cfg.c > > =================================================================== > > --- src.orig/gcc/tree-cfg.c > > +++ src/gcc/tree-cfg.c > > @@ -2675,6 +2675,33 @@ verify_expr (tree *tp, int *walk_subtree > > return t; > > } > > > > + if (TREE_CODE (t) == BIT_FIELD_REF) > > + { > > + if (!host_integerp (TREE_OPERAND (t, 1), 1) > > + || !host_integerp (TREE_OPERAND (t, 2), 1)) > > + { > > + error ("invalid position or size operand to BIT_FIELD_REF"); > > + return t; > > + } > > + if (INTEGRAL_TYPE_P (TREE_TYPE (t)) > > + && (TYPE_PRECISION (TREE_TYPE (t)) > > + != TREE_INT_CST_LOW (TREE_OPERAND (t, 1)))) > > + { > > + error ("integral result type precision does not match " > > + "field size of BIT_FIELD_REF"); > > + return t; > > + } > > + else if (!INTEGRAL_TYPE_P (TREE_TYPE (t)) > > + && TYPE_MODE (TREE_TYPE (t)) != BLKmode > > + && (GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (t))) > > + != TREE_INT_CST_LOW (TREE_OPERAND (t, 1)))) > > + { > > + error ("mode precision of non-integral result does not " > > + "match field size of BIT_FIELD_REF"); > > + return t; > > + } > > + } > > + > > t = TREE_OPERAND (t, 0); > > here instead of ... > > > /* Fall-through. */ > > case COMPONENT_REF: > > case ARRAY_REF: > > @@ -2697,35 +2724,16 @@ verify_expr (tree *tp, int *walk_subtree > > if (TREE_OPERAND (t, 3)) > > CHECK_OP (3, "invalid array stride"); > > } > > - else if (TREE_CODE (t) == BIT_FIELD_REF) > > - { > > - if (!host_integerp (TREE_OPERAND (t, 1), 1) > > - || !host_integerp (TREE_OPERAND (t, 2), 1)) > > - { > > - error ("invalid position or size operand to BIT_FIELD_REF"); > > - return t; > > - } > > - if (INTEGRAL_TYPE_P (TREE_TYPE (t)) > > - && (TYPE_PRECISION (TREE_TYPE (t)) > > - != TREE_INT_CST_LOW (TREE_OPERAND (t, 1)))) > > - { > > - error ("integral result type precision does not match " > > - "field size of BIT_FIELD_REF"); > > - return t; > > - } > > - else if (!INTEGRAL_TYPE_P (TREE_TYPE (t)) > > - && !AGGREGATE_TYPE_P (TREE_TYPE (t)) > > - && TYPE_MODE (TREE_TYPE (t)) != BLKmode > > - && (GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (t))) > > - != TREE_INT_CST_LOW (TREE_OPERAND (t, 1)))) > > - { > > - error ("mode precision of non-integral result does not " > > - "match field size of BIT_FIELD_REF"); > > - return t; > > - } > > - } > > > > t = TREE_OPERAND (t, 0); > > + if (TREE_CODE (t) == BIT_FIELD_REF > > + || TREE_CODE (t) == REALPART_EXPR > > + || TREE_CODE (t) == IMAGPART_EXPR) > > + { > > + error ("non-top-level BIT_FIELD_REF, IMAGPART_EXPR or " > > + "REALPART_EXPR"); > > + return t; > > + } > > ... doing this after t = TREE_OPERAND (t, 0) (so, do it before). > All right, I have committed the following as revision 199405. Thanks, Martin 2013-05-29 Martin Jambor * tree-cfg.c (verify_expr): Verify that BIT_FIELD_REF, REALPART_EXPR and IMAGPART_EXPR do not occur within other handled_components. Index: src/gcc/tree-cfg.c =================================================================== --- src.orig/gcc/tree-cfg.c +++ src/gcc/tree-cfg.c @@ -2675,6 +2675,34 @@ verify_expr (tree *tp, int *walk_subtree return t; } + if (TREE_CODE (t) == BIT_FIELD_REF) + { + if (!host_integerp (TREE_OPERAND (t, 1), 1) + || !host_integerp (TREE_OPERAND (t, 2), 1)) + { + error ("invalid position or size operand to BIT_FIELD_REF"); + return t; + } + if (INTEGRAL_TYPE_P (TREE_TYPE (t)) + && (TYPE_PRECISION (TREE_TYPE (t)) + != TREE_INT_CST_LOW (TREE_OPERAND (t, 1)))) + { + error ("integral result type precision does not match " + "field size of BIT_FIELD_REF"); + return t; + } + else if (!INTEGRAL_TYPE_P (TREE_TYPE (t)) + && TYPE_MODE (TREE_TYPE (t)) != BLKmode + && (GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (t))) + != TREE_INT_CST_LOW (TREE_OPERAND (t, 1)))) + { + error ("mode precision of non-integral result does not " + "match field size of BIT_FIELD_REF"); + return t; + } + } + t = TREE_OPERAND (t, 0); + /* Fall-through. */ case COMPONENT_REF: case ARRAY_REF: @@ -2697,32 +2725,13 @@ verify_expr (tree *tp, int *walk_subtree if (TREE_OPERAND (t, 3)) CHECK_OP (3, "invalid array stride"); } - else if (TREE_CODE (t) == BIT_FIELD_REF) + else if (TREE_CODE (t) == BIT_FIELD_REF + || TREE_CODE (t) == REALPART_EXPR + || TREE_CODE (t) == IMAGPART_EXPR) { - if (!host_integerp (TREE_OPERAND (t, 1), 1) - || !host_integerp (TREE_OPERAND (t, 2), 1)) - { - error ("invalid position or size operand to BIT_FIELD_REF"); - return t; - } - if (INTEGRAL_TYPE_P (TREE_TYPE (t)) - && (TYPE_PRECISION (TREE_TYPE (t)) - != TREE_INT_CST_LOW (TREE_OPERAND (t, 1)))) - { - error ("integral result type precision does not match " - "field size of BIT_FIELD_REF"); - return t; - } - else if (!INTEGRAL_TYPE_P (TREE_TYPE (t)) - && !AGGREGATE_TYPE_P (TREE_TYPE (t)) - && TYPE_MODE (TREE_TYPE (t)) != BLKmode - && (GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (t))) - != TREE_INT_CST_LOW (TREE_OPERAND (t, 1)))) - { - error ("mode precision of non-integral result does not " - "match field size of BIT_FIELD_REF"); - return t; - } + error ("non-top-level BIT_FIELD_REF, IMAGPART_EXPR or " + "REALPART_EXPR"); + return t; } t = TREE_OPERAND (t, 0);