aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2020-07-01 20:25:09 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2020-10-16 03:34:43 -0400
commit853f7f8ba8ff3ae7eff0678a5d28273ba951ba1d (patch)
treecd6e6c384cbeeff36163c3bb7f07bbc9d7a93133 /gcc
parent5742eed7a6e567c3fc28adea17d0788ea4be136f (diff)
downloadgcc-853f7f8ba8ff3ae7eff0678a5d28273ba951ba1d.zip
gcc-853f7f8ba8ff3ae7eff0678a5d28273ba951ba1d.tar.gz
gcc-853f7f8ba8ff3ae7eff0678a5d28273ba951ba1d.tar.bz2
[Ada] Attribute Img on derived types
gcc/ada/ * exp_imgv.adb (Expand_Image_Attribute): Refine previous patch to use root type (and not base type) on enumeration types.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/exp_imgv.adb10
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/ada/exp_imgv.adb b/gcc/ada/exp_imgv.adb
index 731d010..a3c73fa 100644
--- a/gcc/ada/exp_imgv.adb
+++ b/gcc/ada/exp_imgv.adb
@@ -481,9 +481,15 @@ package body Exp_Imgv is
-- Ada 2020 allows 'Image on private types, so fetch the underlying
-- type to obtain the structure of the type. We use the base type,
- -- not the root type, to handle properly derived types.
+ -- not the root type, to handle properly derived types, but we use
+ -- the root type for enumeration types, because the literal map is
+ -- attached to the root. Should be inherited ???
- Rtyp := Underlying_Type (Base_Type (Ptyp));
+ if Is_Enumeration_Type (Ptyp) then
+ Rtyp := Underlying_Type (Root_Type (Ptyp));
+ else
+ Rtyp := Underlying_Type (Base_Type (Ptyp));
+ end if;
-- Enable speed-optimized expansion of user-defined enumeration types
-- if we are compiling with optimizations enabled and enumeration type