From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30181 invoked by alias); 27 Jul 2010 15:00:26 -0000 Received: (qmail 30171 invoked by uid 22791); 27 Jul 2010 15:00:25 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 27 Jul 2010 15:00:19 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o6RF088A017694 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 27 Jul 2010 11:00:09 -0400 Received: from [IPv6:::1] (ovpn-113-24.phx2.redhat.com [10.3.113.24]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o6RF07YO023995; Tue, 27 Jul 2010 11:00:07 -0400 Message-ID: <4C4EF477.3060703@redhat.com> Date: Tue, 27 Jul 2010 15:02:00 -0000 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.11) Gecko/20100722 Lightning/1.0b1 Shredder/3.0.7pre MIME-Version: 1.0 To: Le-Chun Wu CC: =?ISO-8859-1?Q?Manuel_L=F3pez-Ib=E1=F1ez?= , "Joseph S. Myers" , rguenther@suse.de, Andrew Pinski , GCC Patches , Diego Novillo , sebastian.pop@inria.fr, jh@suse.cz Subject: Re: [patch] [C/C++] Add a new warning flag -Wself-assign References: <4C2AC83B.3040005@redhat.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 X-SW-Source: 2010-07/txt/msg02087.txt.bz2 On 07/21/2010 08:45 PM, Le-Chun Wu wrote: > On Tue, Jun 29, 2010 at 9:29 PM, Jason Merrill wrote: >> On 06/24/2010 06:54 PM, Le-Chun Wu wrote: >>> >>> + expr_folded_flag: >>> + >>> + EXPR_FOLDED in >>> + all expressions >>> + all decls >>> + all constants >> >> This seems problematic given that DECLs and some constants are shared. If at some point some expression is folded into a DECL, any subsequent appearance of that DECL will be marked EXPR_FOLDED; so if we have >> >> x = x+0; >> x = x; >> >> the second assignment won't warn. Right? > > Yes, that's right. This is a great catch. Wrapping uses of decls will > surely help in this case but, as you also said, it will require a > significant amount of work to make such a change to the IR. For now, > to fix this issue, I would clear the expr_folded flag after the > self-assign check (for each statement) is done. I also added comments > in tree.h to warn people not to use this flag in other places, and > added a new test for this case. What do you think? That's certainly better, but it still makes me a bit uncomfortable to have a flag that's just used for transient marking. Is it possible to avoid the need for this flag in the C front end, since it delays folding until c_fully_fold? Jason