public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Set related expression for external DISCR symbols in Build_Temporary
@ 2021-09-21 15:26 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-09-21 15:26 UTC (permalink / raw)
  To: gcc-patches; +Cc: Daniel Mercier

[-- Attachment #1: Type: text/plain, Size: 339 bytes --]

This is required for CodePeer to use a better name for a variable, or a
constant created by GNAT.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* exp_util.adb (Build_Temporary): In case of an external DISCR
	symbol, set the related expression for CodePeer so that a more
	comprehensible message can be emitted to the user.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1139 bytes --]

diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -11656,6 +11656,7 @@ package body Exp_Util is
       is
          Temp_Id  : Entity_Id;
          Temp_Nam : Name_Id;
+         Should_Set_Related_Expression : Boolean := False;
 
       begin
          --  The context requires an external symbol : expression is
@@ -11675,6 +11676,12 @@ package body Exp_Util is
 
             else
                pragma Assert (Discr_Number > 0);
+
+               --  We don't have any intelligible way of printing T_DISCR in
+               --  CodePeer. Thus, set a related expression in this case.
+
+               Should_Set_Related_Expression := True;
+
                --  Use fully qualified name to avoid ambiguities.
 
                Temp_Nam :=
@@ -11684,6 +11691,10 @@ package body Exp_Util is
 
             Temp_Id := Make_Defining_Identifier (Loc, Temp_Nam);
 
+            if Should_Set_Related_Expression then
+               Set_Related_Expression (Temp_Id, Related_Nod);
+            end if;
+
          --  Otherwise generate an internal temporary
 
          else



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-09-21 15:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-21 15:26 [Ada] Set related expression for external DISCR symbols in Build_Temporary Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).