diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2010-06-22 18:22:58 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2010-06-22 18:22:58 +0200 |
commit | 5087048c12395ee380b8040e9ecf399b64e1cf66 (patch) | |
tree | a9a02f49a226ae852a959602d7df85ceb26d807b /gcc/ada/exp_imgv.adb | |
parent | 50b2e859965b43c6537acabd9a4e882204c89b42 (diff) | |
download | gcc-5087048c12395ee380b8040e9ecf399b64e1cf66.tar.gz |
[multiple changes]
2010-06-22 Thomas Quinot <quinot@adacore.com>
* exp_aggr.adb (Rewrite_Discriminant): Fix predicate used to identify
reference to discriminant (can be an expanded name as well as an
identifier).
2010-06-22 Ed Schonberg <schonberg@adacore.com>
* exp_ch6.adb: Clarify comment.
2010-06-22 Geert Bosch <bosch@adacore.com>
* exp_imgv.adb (Expand_Image_Attribute): Treat ordinary fixed point
with decimal small as decimal types, avoiding floating-point arithmetic.
(Has_Decimal_Small): New function.
* einfo.ads, einfo.adb (Aft_Value): New synthesized attributed for
fixed point types.
* sem_attr.adb (Eval_Attribute): Remove Aft_Value function and update
callers to call the new function in Einfo that takes the entity as
parameter.
From-SVN: r161200
Diffstat (limited to 'gcc/ada/exp_imgv.adb')
-rw-r--r-- | gcc/ada/exp_imgv.adb | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/gcc/ada/exp_imgv.adb b/gcc/ada/exp_imgv.adb index 1ec4727107e..9c0be21634e 100644 --- a/gcc/ada/exp_imgv.adb +++ b/gcc/ada/exp_imgv.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2001-2009, Free Software Foundation, Inc. -- +-- Copyright (C) 2001-2010, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -43,9 +43,15 @@ with Stringt; use Stringt; with Tbuild; use Tbuild; with Ttypes; use Ttypes; with Uintp; use Uintp; +with Urealp; use Urealp; package body Exp_Imgv is + function Has_Decimal_Small (E : Entity_Id) return Boolean; + -- Applies to all entities. True for a Decimal_Fixed_Point_Type, or an + -- Ordinary_Fixed_Point_Type with a small that is a negative power of ten. + -- Shouldn't this be in einfo.adb or sem_aux.adb??? + ------------------------------------ -- Build_Enumeration_Image_Tables -- ------------------------------------ @@ -330,7 +336,7 @@ package body Exp_Imgv is Tent := RTE (RE_Long_Long_Unsigned); end if; - elsif Is_Decimal_Fixed_Point_Type (Rtyp) then + elsif Is_Fixed_Point_Type (Rtyp) and then Has_Decimal_Small (Rtyp) then if UI_To_Int (Esize (Rtyp)) <= Standard_Integer_Size then Imid := RE_Image_Decimal; Tent := Standard_Integer; @@ -451,6 +457,11 @@ package body Exp_Imgv is Prefix => New_Reference_To (Ptyp, Loc), Attribute_Name => Name_Aft)); + if Has_Decimal_Small (Rtyp) then + Set_Conversion_OK (First (Arg_List)); + Set_Etype (First (Arg_List), Tent); + end if; + -- For decimal, append Scale and also set to do literal conversion elsif Is_Decimal_Fixed_Point_Type (Rtyp) then @@ -1240,4 +1251,16 @@ package body Exp_Imgv is Analyze_And_Resolve (N, Typ); end Expand_Width_Attribute; + ----------------------- + -- Has_Decimal_Small -- + ----------------------- + + function Has_Decimal_Small (E : Entity_Id) return Boolean is + begin + return Is_Decimal_Fixed_Point_Type (E) + or else + (Is_Ordinary_Fixed_Point_Type (E) + and then Ureal_10**Aft_Value (E) * Small_Value (E) = Ureal_1); + end Has_Decimal_Small; + end Exp_Imgv; |