public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/c++-modules] [Ada] Small improvement to Expand_N_Unchecked_Type_Conversion
@ 2020-06-11 13:09 Nathan Sidwell
  0 siblings, 0 replies; only message in thread
From: Nathan Sidwell @ 2020-06-11 13:09 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:b5b032ec6e3532d9362d4dd4b1097ebf53509b81

commit b5b032ec6e3532d9362d4dd4b1097ebf53509b81
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Fri Jan 10 21:55:33 2020 +0100

    [Ada] Small improvement to Expand_N_Unchecked_Type_Conversion
    
    2020-06-03  Eric Botcazou  <ebotcazou@adacore.com>
    
    gcc/ada/
    
            * exp_ch4.adb (Expand_N_Unchecked_Type_Conversion): Also fold the
            conversion for literals of enumeration types.

Diff:
---
 gcc/ada/exp_ch4.adb | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index 66ebc531af7..8d6ddd7cd4c 100644
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -12460,7 +12460,7 @@ package body Exp_Ch4 is
       --  If we have a conversion of a compile time known value to a target
       --  type and the value is in range of the target type, then we can simply
       --  replace the construct by an integer literal of the correct type. We
-      --  only apply this to integer types being converted. Possibly it may
+      --  only apply this to discrete types being converted. Possibly it may
       --  apply in other cases, but it is too much trouble to worry about.
 
       --  Note that we do not do this transformation if the Kill_Range_Check
@@ -12473,13 +12473,13 @@ package body Exp_Ch4 is
 
       if Is_Integer_Type (Target_Type)
         and then not Has_Biased_Representation (Target_Type)
-        and then Is_Integer_Type (Operand_Type)
+        and then Is_Discrete_Type (Operand_Type)
         and then not Has_Biased_Representation (Operand_Type)
         and then Compile_Time_Known_Value (Operand)
         and then not Kill_Range_Check (N)
       then
          declare
-            Val : constant Uint := Expr_Value (Operand);
+            Val : constant Uint := Expr_Rep_Value (Operand);
 
          begin
             if Compile_Time_Known_Value (Type_Low_Bound (Target_Type))


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-06-11 13:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-11 13:09 [gcc/devel/c++-modules] [Ada] Small improvement to Expand_N_Unchecked_Type_Conversion Nathan Sidwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).