From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTPS id 722823951878 for ; Thu, 17 Jun 2021 14:33:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 722823951878 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id EB9C8561AF; Thu, 17 Jun 2021 10:33:10 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com 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 cz2RSrZ9SDv1; Thu, 17 Jun 2021 10:33:10 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [205.232.38.10]) by rock.gnat.com (Postfix) with ESMTP id D60EB116AF6; Thu, 17 Jun 2021 10:33:10 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4862) id D5412A3; Thu, 17 Jun 2021 10:33:10 -0400 (EDT) Date: Thu, 17 Jun 2021 10:33:10 -0400 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [Ada] Use source casing in messages for aliasing checks Message-ID: <20210617143310.GA9490@adacore.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="FL5UXtIhxfXey3p5" Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jun 2021 14:33:14 -0000 --FL5UXtIhxfXey3p5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline When compiling code with -gnateA -gnateE switches, i.e. with aliasing checks and extra information in exception messages, the runtime error includes names the overlapping formal parameters. Those parameters are now printed exactly as they appear in the source code, not in casing that has been determined for the compilation unit. For example, error emitted for GNATprove included name "Fa" for a formal parameter that appears in the code as "FA", because GNATprove uses mixed case coding convention (just like GNAT). Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * checks.adb (Overlap_Check): Replace Set_Casing with Adjust_Name_Case and adapt surrounding code as needed. --FL5UXtIhxfXey3p5 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb --- a/gcc/ada/checks.adb +++ b/gcc/ada/checks.adb @@ -24,7 +24,6 @@ ------------------------------------------------------------------------------ with Atree; use Atree; -with Casing; use Casing; with Debug; use Debug; with Einfo; use Einfo; with Einfo.Entities; use Einfo.Entities; @@ -2417,9 +2416,8 @@ package body Checks is Formal_2 : Entity_Id; Check : in out Node_Id) is - Cond : Node_Id; - ID_Casing : constant Casing_Type := - Identifier_Casing (Source_Index (Current_Sem_Unit)); + Cond : Node_Id; + Formal_Name : Bounded_String; begin -- Generate: @@ -2451,15 +2449,17 @@ package body Checks is Store_String_Chars ("aliased parameters, actuals for """); - Get_Name_String (Chars (Formal_1)); - Set_Casing (ID_Casing); - Store_String_Chars (Name_Buffer (1 .. Name_Len)); + Append (Formal_Name, Chars (Formal_1)); + Adjust_Name_Case (Formal_Name, Sloc (Formal_1)); + Store_String_Chars (To_String (Formal_Name)); Store_String_Chars (""" and """); - Get_Name_String (Chars (Formal_2)); - Set_Casing (ID_Casing); - Store_String_Chars (Name_Buffer (1 .. Name_Len)); + Formal_Name.Length := 0; + + Append (Formal_Name, Chars (Formal_2)); + Adjust_Name_Case (Formal_Name, Sloc (Formal_2)); + Store_String_Chars (To_String (Formal_Name)); Store_String_Chars (""" overlap"); --FL5UXtIhxfXey3p5--