]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Wed, 16 Sep 2009 12:25:44 +0000 (14:25 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Wed, 16 Sep 2009 12:25:44 +0000 (14:25 +0200)
2009-09-16  Vincent Celier  <celier@adacore.com>

* gprep.adb (Yes_No): New global constant
Unix_Line_Terminators: New global Boolean variable
(Process_One_File): Create the out file with a "Text_Translation=" form
that depends on the use of option -T.
(Scan_Command_Line): Add option -T
(Usage): Add line for option -T

2009-09-16  Ed Schonberg  <schonberg@adacore.com>

* exp_disp.ads, exp_disp.adb (Is_Predefined_Internal_Operation): New
predicate that describes a proper subset of
Is_Predefined_Dispatching_Operation and excludes stream operations,
which can be overridden by the user.
* sem_ch6.adb (Create_Extra_Formals): use
Is_Predefined_Internal_Operation, so that stream operations get extra
formals.
* exp_ch6.adb (Prevent double generation of extra actuals in calls to
'Input, which may be expanded twice, first as a function call and then
as a dispatching call.

From-SVN: r151748

gcc/ada/ChangeLog
gcc/ada/exp_ch6.adb
gcc/ada/exp_disp.adb
gcc/ada/exp_disp.ads
gcc/ada/gprep.adb
gcc/ada/sem_ch6.adb

index 6c975b45034f3a561e5a319edd2b96c454b57c8e..158d9094315d0a1fc7e6780e6834e2c8633eeefe 100644 (file)
@@ -1,3 +1,25 @@
+2009-09-16  Vincent Celier  <celier@adacore.com>
+
+       * gprep.adb (Yes_No): New global constant
+       Unix_Line_Terminators: New global Boolean variable
+       (Process_One_File): Create the out file with a "Text_Translation=" form
+       that depends on the use of option -T.
+       (Scan_Command_Line): Add option -T
+       (Usage): Add line for option -T
+
+2009-09-16  Ed Schonberg  <schonberg@adacore.com>
+
+       * exp_disp.ads, exp_disp.adb (Is_Predefined_Internal_Operation): New
+       predicate that describes a proper subset of
+       Is_Predefined_Dispatching_Operation and excludes stream operations,
+       which can be overridden by the user.
+       * sem_ch6.adb (Create_Extra_Formals): use
+       Is_Predefined_Internal_Operation, so that stream operations get extra
+       formals.
+       * exp_ch6.adb (Prevent double generation of extra actuals in calls to
+       'Input, which may be expanded twice, first as a function call and then
+       as a dispatching call.
+
 2009-09-16  Thomas Quinot  <quinot@adacore.com>
 
        * s-oscons-tmplt.c (Target_OS, Target_Name): New constants.
index 44944aecaf9f07122c13c7c34bdf7967cf0db474..8827870432d5fc6bd3906ebeed4f189832254d2b 100644 (file)
@@ -2282,14 +2282,31 @@ package body Exp_Ch6 is
                   when N_Attribute_Reference =>
                      case Get_Attribute_Id (Attribute_Name (Prev_Orig)) is
 
-                        --  For X'Access, pass on the level of the prefix X
+                        --  For X'Access, pass on the level of the prefix X.
+                        --  If the call is a rewritten attribute reference to
+                        --  'Input and the prefix is a tagged type, prevent
+                        --  double expansion (once as a function call and once
+                        --  as a dispatching call)
 
                         when Attribute_Access =>
-                           Add_Extra_Actual
-                             (Make_Integer_Literal (Loc,
-                                Intval =>
-                                  Object_Access_Level (Prefix (Prev_Orig))),
-                              Extra_Accessibility (Formal));
+                           declare
+                              Onode : constant Node_Id :=
+                                        Original_Node (Parent (N));
+                           begin
+                              if Nkind (Onode) = N_Attribute_Reference
+                                and then Attribute_Name (Onode) = Name_Input
+                                and then Is_Tagged_Type (Etype (Subp))
+                              then
+                                 null;
+                              else
+                                 Add_Extra_Actual
+                                   (Make_Integer_Literal (Loc,
+                                      Intval =>
+                                        Object_Access_Level
+                                          (Prefix (Prev_Orig))),
+                                    Extra_Accessibility (Formal));
+                              end if;
+                           end;
 
                         --  Treat the unchecked attributes as library-level
 
@@ -2328,7 +2345,6 @@ package body Exp_Ch6 is
                        (Make_Integer_Literal (Loc,
                           Intval => Type_Access_Level (Etype (Prev))),
                         Extra_Accessibility (Formal));
-
                end case;
             end if;
          end if;
index f34b1e9af336bdca77d28a399698eb64e9c3a996..671b6633e4ac68bd9cd93d0d6a6e7019d46f4f7b 100644 (file)
@@ -1740,6 +1740,48 @@ package body Exp_Disp is
       return False;
    end Is_Predefined_Dispatching_Operation;
 
+   ---------------------------------------
+   -- Is_Predefined_Internal_Operation  --
+   ---------------------------------------
+
+   function Is_Predefined_Internal_Operation
+     (E : Entity_Id) return Boolean
+   is
+      TSS_Name : TSS_Name_Type;
+
+   begin
+      if not Is_Dispatching_Operation (E) then
+         return False;
+      end if;
+
+      Get_Name_String (Chars (E));
+
+      --  Most predefined primitives have internally generated names. Equality
+      --  must be treated differently; the predefined operation is recognized
+      --  as a homogeneous binary operator that returns Boolean.
+
+      if Name_Len > TSS_Name_Type'Last then
+         TSS_Name :=
+           TSS_Name_Type
+             (Name_Buffer (Name_Len - TSS_Name'Length + 1 .. Name_Len));
+
+         if        Chars (E) = Name_uSize
+           or else Chars (E) = Name_uAlignment
+           or else
+             (Chars (E) = Name_Op_Eq
+                and then Etype (First_Entity (E)) = Etype (Last_Entity (E)))
+           or else Chars (E) = Name_uAssign
+           or else TSS_Name  = TSS_Deep_Adjust
+           or else TSS_Name  = TSS_Deep_Finalize
+           or else Is_Predefined_Interface_Primitive (E)
+         then
+            return True;
+         end if;
+      end if;
+
+      return False;
+   end Is_Predefined_Internal_Operation;
+
    -------------------------------------
    -- Is_Predefined_Dispatching_Alias --
    -------------------------------------
index 18f751d978dc8bb96670d7756223947ec3168f9a..4aea2ca1e6519eefebb8f36816e886d900aa63b1 100644 (file)
@@ -218,6 +218,11 @@ package Exp_Disp is
    function Is_Predefined_Dispatching_Operation (E : Entity_Id) return Boolean;
    --  Ada 2005 (AI-251): Determines if E is a predefined primitive operation
 
+   function Is_Predefined_Internal_Operation (E : Entity_Id) return Boolean;
+   --  Similar to the previous one, but excludes stream operations, because
+   --  these may be overridden, and need extra formals, like user-defined
+   --  operations.
+
    function Is_Predefined_Interface_Primitive (E : Entity_Id) return Boolean;
    --  Ada 2005 (AI-345): Returns True if E is one of the predefined primitives
    --  required to implement interfaces.
index ec56bcc171f27a89081e85b7478a0cff5f9b1326..b5e6b063cac445fc148db02455c7f5040356a3cc 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 2002-2008, Free Software Foundation, Inc.         --
+--          Copyright (C) 2002-2009, 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- --
@@ -55,6 +55,14 @@ package body GPrep is
    -- Argument Line Data --
    ------------------------
 
+   Unix_Line_Terminators : Boolean := False;
+   --  Set to True with option -T
+
+   type String_Array is array (Boolean) of String_Access;
+   Yes_No : constant String_Array :=
+     (False => new String'("YES"),
+      True  => new String'("NO"));
+
    Infile_Name  : Name_Id := No_Name;
    Outfile_Name : Name_Id := No_Name;
    Deffile_Name : Name_Id := No_Name;
@@ -484,7 +492,12 @@ package body GPrep is
          --  Create the output file (fails if this does not work)
 
          begin
-            Create (Text_Outfile, Out_File, Get_Name_String (Outfile_Name));
+            Create
+              (File => Text_Outfile,
+               Mode => Out_File,
+               Name => Get_Name_String (Outfile_Name),
+               Form => "Text_Translation=" &
+                       Yes_No (Unix_Line_Terminators).all);
 
          exception
             when others =>
@@ -722,7 +735,7 @@ package body GPrep is
 
       loop
          begin
-            Switch := GNAT.Command_Line.Getopt ("D: b c C r s u v");
+            Switch := GNAT.Command_Line.Getopt ("D: b c C r s u v");
 
             case Switch is
 
@@ -748,6 +761,9 @@ package body GPrep is
                when 's' =>
                   Opt.List_Preprocessing_Symbols := True;
 
+               when 'T' =>
+                  Unix_Line_Terminators := True;
+
                when 'u' =>
                   Opt.Undefined_Symbols_Are_False := True;
 
@@ -813,6 +829,7 @@ package body GPrep is
       Write_Line ("   -D  Associate symbol with value");
       Write_Line ("   -r  Generate Source_Reference pragma");
       Write_Line ("   -s  Print a sorted list of symbol names and values");
+      Write_Line ("   -T  Use LF as line terminators");
       Write_Line ("   -u  Treat undefined symbols as FALSE");
       Write_Line ("   -v  Verbose mode");
       Write_Eol;
index 32323400b6d61d56aca845058753c95c98bda490..94ed69e2598016cf7420c356f912cb140a6edc6c 100644 (file)
@@ -5465,7 +5465,7 @@ package body Sem_Ch6 is
       --  generated stream attributes do get passed through because extra
       --  build-in-place formals are needed in some cases (limited 'Input).
 
-      if Is_Predefined_Dispatching_Operation (E) then
+      if Is_Predefined_Internal_Operation (E) then
          goto Test_For_BIP_Extras;
       end if;