exp_imgv.adb (Expand_Image_Attribute): Generate extra boolean parameter in call to...
authorRobert Dewar <dewar@adacore.com>
Fri, 9 Dec 2005 17:19:19 +0000 (18:19 +0100)
committerArnaud Charlet <charlet@gcc.gnu.org>
Fri, 9 Dec 2005 17:19:19 +0000 (18:19 +0100)
2005-12-05  Robert Dewar  <dewar@adacore.com>

* exp_imgv.adb (Expand_Image_Attribute): Generate extra boolean
parameter in call to Image_Wide_Character.

* s-imgwch.ads, s-imgwch.adb (Image_Wide_Character): Add boolean
parameter Ada_2005 to deal with annoying FFFE/FFFF inconsistency.
(Image_Wide_Character): Add boolean parameter Ada_2005 to deal with
annoying FFFE/FFFF inconsistency.

From-SVN: r108293

gcc/ada/exp_imgv.adb
gcc/ada/s-imgwch.adb
gcc/ada/s-imgwch.ads

index 1fdbced68140193de6127db076d39e23c8f5ddfc..2f76d639b7c1d3471b0b97e652b2e2ff50deed06 100644 (file)
@@ -32,6 +32,7 @@ with Exp_Util; use Exp_Util;
 with Namet;    use Namet;
 with Nmake;    use Nmake;
 with Nlists;   use Nlists;
+with Opt;      use Opt;
 with Rtsfind;  use Rtsfind;
 with Sem_Res;  use Sem_Res;
 with Sinfo;    use Sinfo;
@@ -148,7 +149,6 @@ package body Exp_Imgv is
               Make_Aggregate (Loc,
                 Expressions => Ind))),
         Suppress => All_Checks);
-
    end Build_Enumeration_Image_Tables;
 
    ----------------------------
@@ -191,6 +191,7 @@ package body Exp_Imgv is
    --    For types whose root type is Wide_Character
    --      xx = Wide_Character
    --      tv = Wide_Character (Expr)
+   --      pm = Boolean, true if Ada 2005 mode, False otherwise
 
    --    For types whose root type is Wide_Wide_Character
    --      xx = Wide_Wide_haracter
@@ -398,6 +399,12 @@ package body Exp_Imgv is
 
          Set_Conversion_OK (First (Arglist));
          Set_Etype (First (Arglist), Tent);
+
+         --  For Wide_Character, append Ada 2005 indication
+
+      elsif Rtyp = Standard_Wide_Character then
+         Append_To (Arglist,
+           New_Reference_To (Boolean_Literals (Ada_Version >= Ada_05), Loc));
       end if;
 
       Rewrite (N,
index dc524da531e3879301b83ab5ebb968489e5fd912..a408ef62828699368aa46cad387cebf06e7b8b31 100644 (file)
@@ -42,9 +42,24 @@ package body System.Img_WChar is
    --------------------------
 
    function Image_Wide_Character
-     (V : Wide_Character) return String
+     (V        : Wide_Character;
+      Ada_2005 : Boolean) return String
    is
    begin
+      --  Annoying Ada 95 incompatibility with FFFE/FFFF
+
+      if V >= Wide_Character'Val (16#FFFE#)
+        and then not Ada_2005
+      then
+         if V = Wide_Character'Val (16#FFFE#) then
+            return "FFFE";
+         else
+            return "FFFF";
+         end if;
+      end if;
+
+      --  Normal case, same as Wide_Wide_Character
+
       return
         Image_Wide_Wide_Character
           (Wide_Wide_Character'Val (Wide_Character'Pos (V)));
index 61f4441f53a3d54ea874170f9f5194a820680851..b827b803b92c18cb4c4c28c521422259034d9132 100644 (file)
 package System.Img_WChar is
    pragma Pure;
 
-   function Image_Wide_Character (V : Wide_Character) return String;
-   --  Computes Wide_Character'Image (V) and returns the computed result
+   function Image_Wide_Character
+     (V        : Wide_Character;
+      Ada_2005 : Boolean) return String;
+   --  Computes Wide_Character'Image (V) and returns the computed result. The
+   --  parameter Ada_2005 is True if operating in Ada 2005 mode (or beyond).
+   --  This is needed for the annoying FFFE/FFFF incompatibility.
 
    function Image_Wide_Wide_Character (V : Wide_Wide_Character) return String;
    --  Computes Wide_Wide_Character'Image (V) and returns the computed result