From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1914) id E60623945C27; Thu, 17 Jun 2021 14:33:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E60623945C27 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Pierre-Marie de Rodat To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-1572] [Ada] Apply aliasing checks only to names and not to objects as actuals X-Act-Checkin: gcc X-Git-Author: Piotr Trojanek X-Git-Refname: refs/heads/master X-Git-Oldrev: f54fb769ec25976858e6bdea9c6a1beeb70f91fa X-Git-Newrev: 9e1ca4e3ab0fb7156fed4480c8f35810d00ff84d Message-Id: <20210617143308.E60623945C27@sourceware.org> Date: Thu, 17 Jun 2021 14:33:08 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jun 2021 14:33:09 -0000 https://gcc.gnu.org/g:9e1ca4e3ab0fb7156fed4480c8f35810d00ff84d commit r12-1572-g9e1ca4e3ab0fb7156fed4480c8f35810d00ff84d Author: Piotr Trojanek Date: Mon Mar 1 16:23:38 2021 +0100 [Ada] Apply aliasing checks only to names and not to objects as actuals gcc/ada/ * checks.adb (Apply_Parameter_Aliasing_Checks): Replace calls to Is_Object_Reference with calls to Is_Name_Reference; remove asymmetric condition that only detected an aggregate as the first actual (aggregate objects were just a special case of an object reference that was not a name). Diff: --- gcc/ada/checks.adb | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb index 877a982b840..d8cdb64c454 100644 --- a/gcc/ada/checks.adb +++ b/gcc/ada/checks.adb @@ -2507,29 +2507,16 @@ package body Checks is while Present (Actual_1) and then Present (Formal_1) loop Orig_Act_1 := Original_Actual (Actual_1); - -- Ensure that the actual is an object that is not passed by value. - -- Elementary types are always passed by value, therefore actuals of - -- such types cannot lead to aliasing. An aggregate is an object in - -- Ada 2012, but an actual that is an aggregate cannot overlap with - -- another actual. - - if Nkind (Orig_Act_1) = N_Aggregate - or else (Nkind (Orig_Act_1) = N_Qualified_Expression - and then Nkind (Expression (Orig_Act_1)) = N_Aggregate) - then - null; - - elsif Is_Object_Reference (Orig_Act_1) then + if Is_Name_Reference (Orig_Act_1) then Actual_2 := Next_Actual (Actual_1); Formal_2 := Next_Formal (Formal_1); while Present (Actual_2) and then Present (Formal_2) loop Orig_Act_2 := Original_Actual (Actual_2); - -- The other actual we are testing against must also denote - -- a non pass-by-value object. Generate the check only when - -- the mode of the two formals may lead to aliasing. + -- Generate the check only when the mode of the two formals may + -- lead to aliasing. - if Is_Object_Reference (Orig_Act_2) + if Is_Name_Reference (Orig_Act_2) and then May_Cause_Aliasing (Formal_1, Formal_2) then