aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2020-09-04 12:34:02 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2020-10-23 04:24:58 -0400
commit3a5c9377f6d99ea23520f71340880b2fcb7bef11 (patch)
treed01a14d86851f762b68d02482bc877df458932a4 /gcc
parent995e0727ce999d3f4d5976e98ce31c70cb0469ed (diff)
downloadgcc-3a5c9377f6d99ea23520f71340880b2fcb7bef11.zip
gcc-3a5c9377f6d99ea23520f71340880b2fcb7bef11.tar.gz
gcc-3a5c9377f6d99ea23520f71340880b2fcb7bef11.tar.bz2
[Ada] Do not use Long_Long_Long_Integer'Image with pragma Discard_Names
gcc/ada/ * exp_imgv.adb (Expand_Image_Attribute): For an enumeration type subject to pragma Discard_Names, convert 'Pos to Long_Long_Integer before applying 'Img to the result.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/exp_imgv.adb13
1 files changed, 8 insertions, 5 deletions
diff --git a/gcc/ada/exp_imgv.adb b/gcc/ada/exp_imgv.adb
index 5850b5d..40cb514 100644
--- a/gcc/ada/exp_imgv.adb
+++ b/gcc/ada/exp_imgv.adb
@@ -619,15 +619,18 @@ package body Exp_Imgv is
or else No (Lit_Strings (Rtyp))
then
-- When pragma Discard_Names applies to the first subtype, build
- -- (Pref'Pos (Expr))'Img.
+ -- (Long_Long_Integer (Pref'Pos (Expr)))'Img. The conversion is
+ -- there to avoid applying 'Img directly in Universal_Integer,
+ -- which can be a very large type. See also the handling of 'Val.
Rewrite (N,
Make_Attribute_Reference (Loc,
Prefix =>
- Make_Attribute_Reference (Loc,
- Prefix => Pref,
- Attribute_Name => Name_Pos,
- Expressions => New_List (Expr)),
+ Convert_To (Standard_Long_Long_Integer,
+ Make_Attribute_Reference (Loc,
+ Prefix => Pref,
+ Attribute_Name => Name_Pos,
+ Expressions => New_List (Expr))),
Attribute_Name =>
Name_Img));
Analyze_And_Resolve (N, Standard_String);