From patchwork Tue Sep 27 09:54:22 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Charlet X-Patchwork-Id: 116563 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]) by ozlabs.org (Postfix) with SMTP id 6D732B6F72 for ; Tue, 27 Sep 2011 19:54:43 +1000 (EST) Received: (qmail 9575 invoked by alias); 27 Sep 2011 09:54:41 -0000 Received: (qmail 9566 invoked by uid 22791); 27 Sep 2011 09:54:40 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 27 Sep 2011 09:54:22 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 4CD782BAB96; Tue, 27 Sep 2011 05:54:22 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id xXq0yqyTrghu; Tue, 27 Sep 2011 05:54:22 -0400 (EDT) Received: from kwai.gnat.com (kwai.gnat.com [205.232.38.4]) by rock.gnat.com (Postfix) with ESMTP id 39A322BAB91; Tue, 27 Sep 2011 05:54:22 -0400 (EDT) Received: by kwai.gnat.com (Postfix, from userid 4192) id 36EDA92BF6; Tue, 27 Sep 2011 05:54:22 -0400 (EDT) Date: Tue, 27 Sep 2011 05:54:22 -0400 From: Arnaud Charlet To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [Ada] Small cleanup in Safe_Prefixed_Reference Message-ID: <20110927095422.GA8554@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) 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 This fixes a few things in Safe_Prefixed_Reference that are hard to grasp by the reader and restores the original semantics of the function with regard to the Variable_Ref parameter. Tested on x86_64-pc-linux-gnu, committed on trunk 2011-09-27 Eric Botcazou * exp_util.adb (Safe_Prefixed_Reference): Remove always-false test in the N_Explicit_Dereference case. Fold double logical negation in the special loop case and conditionalize it on Variable_Ref being true. Index: exp_util.adb =================================================================== --- exp_util.adb (revision 179247) +++ exp_util.adb (working copy) @@ -5912,30 +5912,22 @@ -- We do NOT exclude dereferences of access-to-constant types because -- we handle them as constant view of variables. - -- Exception is an access to an entity that is a constant or an - -- in-parameter. - elsif Nkind (Prefix (N)) = N_Explicit_Dereference and then Variable_Ref then - declare - DDT : constant Entity_Id := - Designated_Type (Etype (Prefix (Prefix (N)))); - begin - return Ekind_In (DDT, E_Constant, E_In_Parameter); - end; + return False; -- The following test is the simplest way of solving a complex - -- problem uncovered by BB08-010: Side effect on loop bound that + -- problem uncovered by B808-010: Side effect on loop bound that -- is a subcomponent of a global variable: -- If a loop bound is a subcomponent of a global variable, a -- modification of that variable within the loop may incorrectly -- affect the execution of the loop. - elsif not - (Nkind (Parent (Parent (N))) /= N_Loop_Parameter_Specification - or else not Within_In_Parameter (Prefix (N))) + elsif Nkind (Parent (Parent (N))) = N_Loop_Parameter_Specification + and then Within_In_Parameter (Prefix (N)) + and then Variable_Ref then return False;