]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix negative value returned by 'Image for array with nonnegative component
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 11 Sep 2024 17:37:08 +0000 (19:37 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 8 Oct 2024 08:37:15 +0000 (10:37 +0200)
The problem is that Exp_Put_Image.Build_Elementary_Put_Image_Call uses the
signedness of the base type but the size of the first subtype, hence the
discrepancy between them.

gcc/ada/ChangeLog:
PR ada/115535
* exp_put_image.adb (Build_Elementary_Put_Image_Call): Use the size
of the underlying type to find the support type.

gcc/ada/exp_put_image.adb

index 190ac99b565302fcca5d136e401db4581ef36b9e..36254fffd618d48c8e2af21dc0fe1e3b27dc465c 100644 (file)
@@ -293,10 +293,9 @@ package body Exp_Put_Image is
       Loc     : constant Source_Ptr := Sloc (N);
       P_Type  : constant Entity_Id  := Entity (Prefix (N));
       U_Type  : constant Entity_Id  := Underlying_Type (P_Type);
-      FST     : constant Entity_Id  := First_Subtype (U_Type);
       Sink    : constant Node_Id    := First (Expressions (N));
       Item    : constant Node_Id    := Next (Sink);
-      P_Size  : constant Uint       := Esize (FST);
+      P_Size  : constant Uint       := Esize (U_Type);
       Lib_RE  : RE_Id;
 
    begin