]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Sem_Util: fix a bug in New_Copy_Tree
authorpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 14 Aug 2019 09:51:29 +0000 (09:51 +0000)
committerpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 14 Aug 2019 09:51:29 +0000 (09:51 +0000)
No impact on GCC-based compilation.

2019-08-14  Javier Miranda  <miranda@adacore.com>

gcc/ada/

* sem_util.adb (New_Copy_Tree.Copy_Node_With_Replacement):
Update the Chars attribute of identifiers.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@274455 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/sem_util.adb

index 1d139475aeec6339d8afe3675874ff42c4180708..c661a3832ddfa840b1f65549ba1a24e6719968e4 100644 (file)
@@ -1,3 +1,8 @@
+2019-08-14  Javier Miranda  <miranda@adacore.com>
+
+       * sem_util.adb (New_Copy_Tree.Copy_Node_With_Replacement):
+       Update the Chars attribute of identifiers.
+
 2019-08-14  Yannick Moy  <moy@adacore.com>
 
        * sem_spark.adb, sem_spark.ads (Is_Legal): New function exposed
index db9233a539173f640a5ddf6887f4eabe7d58ec48..10f8ffb940e822198ab430f43b314526f8fcbf8f 100644 (file)
@@ -20427,6 +20427,21 @@ package body Sem_Util is
                Update_First_Real_Statement
                  (Old_HSS => N,
                   New_HSS => Result);
+
+            --  Update the Chars attribute of identifiers
+
+            elsif Nkind (N) = N_Identifier then
+
+               --  The Entity field of identifiers that denote aspects is used
+               --  to store arbitrary expressions (and hence we must check that
+               --  they reference an actual entity before copying their Chars
+               --  value).
+
+               if Present (Entity (Result))
+                 and then Nkind (Entity (Result)) in N_Entity
+               then
+                  Set_Chars (Result, Chars (Entity (Result)));
+               end if;
             end if;
          end if;