]> gcc.gnu.org Git - gcc.git/commitdiff
[Ada] Error issued on string literal assigned to fixed-lower-bound array
authorGary Dismukes <dismukes@adacore.com>
Fri, 19 Mar 2021 00:23:04 +0000 (20:23 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Fri, 18 Jun 2021 08:36:51 +0000 (04:36 -0400)
gcc/ada/

* exp_util.adb (Expand_Sliding_Conversion): Move test of
Is_Fixed_Lower_Bound_Subtype to an assertion. Exclude string
literals from sliding expansion.

gcc/ada/exp_util.adb

index 19b8c656e2cb2ead57c08c467b7250ab4c1ca2c4..ed1a016be48dd3c60fe489530317786d8b4064e6 100644 (file)
@@ -5323,7 +5323,8 @@ package body Exp_Util is
    procedure Expand_Sliding_Conversion (N : Node_Id; Arr_Typ : Entity_Id) is
 
       pragma Assert (Is_Array_Type (Arr_Typ)
-                      and then not Is_Constrained (Arr_Typ));
+                      and then not Is_Constrained (Arr_Typ)
+                      and then Is_Fixed_Lower_Bound_Array_Subtype (Arr_Typ));
 
       Constraints : List_Id;
       Index       : Node_Id := First_Index (Arr_Typ);
@@ -5342,7 +5343,10 @@ package body Exp_Util is
       All_FLBs_Match : Boolean := True;
 
    begin
-      if Is_Fixed_Lower_Bound_Array_Subtype (Arr_Typ) then
+      --  Sliding should never be needed for string literals, because they have
+      --  their bounds set according to the applicable index constraint.
+
+      if Nkind (N) /= N_String_Literal then
          Constraints := New_List;
 
          Act_Subt  := Get_Actual_Subtype (N);
This page took 0.081407 seconds and 5 git commands to generate.