]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Correct A'First (N) where N is an object name
authorBob Duff <duff@adacore.com>
Wed, 17 Mar 2021 16:14:12 +0000 (12:14 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Fri, 18 Jun 2021 08:36:50 +0000 (04:36 -0400)
gcc/ada/

* sem_attr.adb (Check_Array_Or_Scalar_Type): Use Expr_Value
instead of Intval, because the latter only exists in literals.
Remove Set_Etype on E1; setting the type is done elsewhere.

gcc/ada/sem_attr.adb

index 63b0f09ea5d464662ce0e7ece87945532b48bd06..f9b17c75d4bb2f39aede81aa8d9f2f230b091188 100644 (file)
@@ -1603,7 +1603,6 @@ package body Sem_Attr is
 
          --  Local variables
 
-         Dims  : Int;
          Index : Entity_Id;
 
       --  Start of processing for Check_Array_Or_Scalar_Type
@@ -1667,14 +1666,16 @@ package body Sem_Attr is
                Set_Etype (N, Base_Type (Etype (Index)));
 
             else
-               Dims := UI_To_Int (Intval (E1));
-
-               for J in 1 .. Dims - 1 loop
-                  Next_Index (Index);
-               end loop;
+               declare
+                  Udims : constant Uint := Expr_Value (E1);
+                  Dims  : constant Int  := UI_To_Int (Udims);
+               begin
+                  for J in 1 .. Dims - 1 loop
+                     Next_Index (Index);
+                  end loop;
+               end;
 
                Set_Etype (N, Base_Type (Etype (Index)));
-               Set_Etype (E1, Standard_Integer);
             end if;
          end if;
       end Check_Array_Or_Scalar_Type;