From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25935 invoked by alias); 2 Jun 2016 15:31:05 -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 25905 invoked by uid 89); 2 Jun 2016 15:31:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=rarely X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 02 Jun 2016 15:30:58 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C1F90C0467C9 for ; Thu, 2 Jun 2016 15:30:57 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-51.ams2.redhat.com [10.36.116.51]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u52FUuZB007918 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 2 Jun 2016 11:30:57 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id u52FUsAH002996; Thu, 2 Jun 2016 17:30:54 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id u52FUqtX002995; Thu, 2 Jun 2016 17:30:52 +0200 Date: Thu, 02 Jun 2016 15:31:00 -0000 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches List Subject: Re: [C++ PATCH] Fix cp_fold dropping TREE_THIS_VOLATILE flag (PR c++/71372) Message-ID: <20160602153052.GL28550@tucnak.redhat.com> Reply-To: Jakub Jelinek References: <20160602121327.GD28550@tucnak.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes X-SW-Source: 2016-06/txt/msg00183.txt.bz2 On Thu, Jun 02, 2016 at 11:14:48AM -0400, Jason Merrill wrote: > On Thu, Jun 2, 2016 at 8:13 AM, Jakub Jelinek wrote: > > When cp_fold is called on INDIRECT_REF and ARRAY*_REF and any of the > > arguments change in the recursive calls, we fail to copy TREE_THIS_VOLATILE > > flag. > > > > PR c++/71372 > > * cp-gimplify.c (cp_fold): For INDIRECT_REF, if the folded expression > > is INDIRECT_REF or MEM_REF, copy over TREE_READONLY, TREE_SIDE_EFFECTS > > and TREE_THIS_VOLATILE flags. For ARRAY_REF and ARRAY_RANGE_REF, copy > > over TREE_READONLY, TREE_SIDE_EFFECTS and TREE_THIS_VOLATILE flags > > to the newly built tree. > > Hmm, maybe we should be using build_indirect_ref and build_array_ref. Those look too much front-endish to me (having lots of diagnostics etc. in them for something that should have been already long diagnosed). > Or perhaps factor the simple build and set flags out of > cp_build_indirect_ref and call that. > > If you don't feel like making that change, the patch is also OK as is. I've tried to follow what the C FE does here: if (op0 != orig_op0 && code == ADDR_EXPR && (op1 = get_base_address (op0)) != NULL_TREE && INDIRECT_REF_P (op1) && TREE_CONSTANT (TREE_OPERAND (op1, 0))) ret = fold_convert_loc (loc, TREE_TYPE (expr), fold_offsetof_1 (op0)); else if (op0 != orig_op0 || in_init) ret = in_init ? fold_build1_initializer_loc (loc, code, TREE_TYPE (expr), op0) : fold_build1_loc (loc, code, TREE_TYPE (expr), op0); else ret = fold (expr); if (code == INDIRECT_REF && ret != expr && INDIRECT_REF_P (ret)) { TREE_READONLY (ret) = TREE_READONLY (expr); TREE_SIDE_EFFECTS (ret) = TREE_SIDE_EFFECTS (expr); TREE_THIS_VOLATILE (ret) = TREE_THIS_VOLATILE (expr); } and similar. Note, we have also the same problem in fold-const.c (fold), though we'd hit that more rarely than this, and there we also should just copy the flags. Jakub