aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorGary Dismukes <dismukes@adacore.com>2021-03-18 20:23:04 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2021-06-18 04:36:51 -0400
commitf44441d80fa8523a2e1b294b8563180202879727 (patch)
treea0df130f54da75ece76aa0f04dce09a8f943eeb3 /gcc/ada
parent1be46d12a7b76e62f25f3e4e148cda3a6c8948c3 (diff)
downloadgcc-f44441d80fa8523a2e1b294b8563180202879727.zip
gcc-f44441d80fa8523a2e1b294b8563180202879727.tar.gz
gcc-f44441d80fa8523a2e1b294b8563180202879727.tar.bz2
[Ada] Error issued on string literal assigned to fixed-lower-bound array
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.
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/exp_util.adb8
1 files changed, 6 insertions, 2 deletions
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index 19b8c65..ed1a016 100644
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -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);