Slices that denote the same objects can be indexed either by integer or
character literals, but the latter was not detected.

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

gcc/ada/

        * sem_util.adb (Denotes_Same_Object): Handle character literals
        just like integer literals.
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -7504,13 +7504,20 @@ package body Sem_Util is
       then
          return Denotes_Same_Object (A1, Renamed_Entity (Entity (A2)));
 
-      --  In the recursion, literals appear as slice bounds
+      --  In the recursion, integer literals appear as slice bounds
 
       elsif Nkind (A1) = N_Integer_Literal
         and then Nkind (A2) = N_Integer_Literal
       then
          return Intval (A1) = Intval (A2);
 
+      --  Likewise for character literals
+
+      elsif Nkind (A1) = N_Character_Literal
+        and then Nkind (A2) = N_Character_Literal
+      then
+         return Char_Literal_Value (A1) = Char_Literal_Value (A2);
+
       else
          return False;
       end if;


Reply via email to