[Ada] Bug in Enum_Subtype'Image in Ada 2020 mode

Message ID 20200727080552.GA36435@adacore.com
State New
Headers show
Series
  • [Ada] Bug in Enum_Subtype'Image in Ada 2020 mode
Related show

Commit Message

Pierre-Marie de Rodat July 27, 2020, 8:05 a.m.
This patch fixes a bug in which Enum_Subtype'Image, where Enum_Subtype
is a non-first subtype of an enumeration type, would return the image of
the 'Pos -- that is, an integer instead of the text of the enumeration
literal.

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

gcc/ada/

	* exp_imgv.adb (Expand_Image_Attribute): Add Root_Type, so
	constrained subtypes work.

Patch

diff --git a/gcc/ada/exp_imgv.adb b/gcc/ada/exp_imgv.adb
--- a/gcc/ada/exp_imgv.adb
+++ b/gcc/ada/exp_imgv.adb
@@ -483,7 +483,7 @@  package body Exp_Imgv is
       --  underlying type.
 
       if Ada_Version >= Ada_2020 then
-         Rtyp := Underlying_Type (Ptyp);
+         Rtyp := Underlying_Type (Root_Type (Ptyp));
       else
          Rtyp := Root_Type (Ptyp);
       end if;