diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2021-06-17 18:49:11 +0200 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2021-07-12 12:50:55 +0000 |
commit | 86b228b87b64ffa6991fce0dc188985d7a9a173a (patch) | |
tree | e513afd4637c91ce23ef38c6cbd62ba9c96230ca | |
parent | c03cae4e066066278c8435c409829a9bf851e49f (diff) | |
download | gcc-86b228b87b64ffa6991fce0dc188985d7a9a173a.zip gcc-86b228b87b64ffa6991fce0dc188985d7a9a173a.tar.gz gcc-86b228b87b64ffa6991fce0dc188985d7a9a173a.tar.bz2 |
[Ada] Avoid unnecessary work when expanding 'Image into 'Put_Image
gcc/ada/
* exp_imgv.adb (Expand_Image_Attribute): Move rewriting to
attribute Put_Image to the beginning of expansion of attribute
Image.
-rw-r--r-- | gcc/ada/exp_imgv.adb | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/gcc/ada/exp_imgv.adb b/gcc/ada/exp_imgv.adb index d2605fb..69b9f2d 100644 --- a/gcc/ada/exp_imgv.adb +++ b/gcc/ada/exp_imgv.adb @@ -1044,6 +1044,15 @@ package body Exp_Imgv is return; end if; + -- If Image should be transformed using Put_Image, then do so. See + -- Exp_Put_Image for details. + + if Exp_Put_Image.Image_Should_Call_Put_Image (N) then + Rewrite (N, Exp_Put_Image.Build_Image_Call (N)); + Analyze_And_Resolve (N, Standard_String, Suppress => All_Checks); + return; + end if; + Ptyp := Underlying_Type (Entity (Pref)); -- Ada 2022 allows 'Image on private types, so fetch the underlying @@ -1063,15 +1072,7 @@ package body Exp_Imgv is Enum_Case := False; - -- If this is a case where Image should be transformed using Put_Image, - -- then do so. See Exp_Put_Image for details. - - if Exp_Put_Image.Image_Should_Call_Put_Image (N) then - Rewrite (N, Exp_Put_Image.Build_Image_Call (N)); - Analyze_And_Resolve (N, Standard_String, Suppress => All_Checks); - return; - - elsif Rtyp = Standard_Boolean then + if Rtyp = Standard_Boolean then -- Use inline expansion if the -gnatd_x switch is not passed to the -- compiler. Otherwise expand into a call to the runtime. |