]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Mon, 26 Oct 2015 11:51:46 +0000 (12:51 +0100)
committerArnaud Charlet <charlet@gcc.gnu.org>
Mon, 26 Oct 2015 11:51:46 +0000 (12:51 +0100)
2015-10-26  Bob Duff  <duff@adacore.com>

* s-fileio.adb (Fopen_Mode): Use "r+" for Out_File/Stream_IO,
so the file won't be truncated on 'fopen', as required by
AI95-00283-1.

2015-10-26  Bob Duff  <duff@adacore.com>

* gnat1drv.adb, prj.adb, sem_ch6.adb, s-regpat.adb,
sem_prag.adb: Fix typos.
* einfo.ads, restrict.ads: Minor comment fixes.
* err_vars.ads, sem_util.adb, errout.ads: Code clean up.

2015-10-26  Ed Schonberg  <schonberg@adacore.com>

* sem_ch5.adb (Analyze_Assignment): Do not check that the
Left-hand side is legal in an inlined body, check is done on
the original template.

2015-10-26  Ed Schonberg  <schonberg@adacore.com>

* exp_util.ads, exp_util.adb (Find_Primitive_Operations): New
subprogram to retrieve by name the possibly overloaded set of
primitive operations of a type.
* sem_ch4.adb (Try_Container_Indexing): Use
Find_Primitive_Operations to handle overloaded indexing operations
of a derived type.

From-SVN: r229343

16 files changed:
gcc/ada/ChangeLog
gcc/ada/einfo.ads
gcc/ada/err_vars.ads
gcc/ada/errout.ads
gcc/ada/exp_util.adb
gcc/ada/exp_util.ads
gcc/ada/gnat1drv.adb
gcc/ada/prj.adb
gcc/ada/restrict.ads
gcc/ada/s-fileio.adb
gcc/ada/s-regpat.adb
gcc/ada/sem_ch4.adb
gcc/ada/sem_ch5.adb
gcc/ada/sem_ch6.adb
gcc/ada/sem_prag.adb
gcc/ada/sem_util.adb

index 76f1356b279d39d4be846ab20982b12d321cfb99..8b146ae655e7e2d0ccb2bb69478b6a7663e69076 100644 (file)
@@ -1,3 +1,31 @@
+2015-10-26  Bob Duff  <duff@adacore.com>
+
+       * s-fileio.adb (Fopen_Mode): Use "r+" for Out_File/Stream_IO,
+       so the file won't be truncated on 'fopen', as required by
+       AI95-00283-1.
+
+2015-10-26  Bob Duff  <duff@adacore.com>
+
+       * gnat1drv.adb, prj.adb, sem_ch6.adb, s-regpat.adb,
+       sem_prag.adb: Fix typos.
+       * einfo.ads, restrict.ads: Minor comment fixes.
+       * err_vars.ads, sem_util.adb, errout.ads: Code clean up.
+
+2015-10-26  Ed Schonberg  <schonberg@adacore.com>
+
+       * sem_ch5.adb (Analyze_Assignment): Do not check that the
+       Left-hand side is legal in an inlined body, check is done on
+       the original template.
+
+2015-10-26  Ed Schonberg  <schonberg@adacore.com>
+
+       * exp_util.ads, exp_util.adb (Find_Primitive_Operations): New
+       subprogram to retrieve by name the possibly overloaded set of
+       primitive operations of a type.
+       * sem_ch4.adb (Try_Container_Indexing): Use
+       Find_Primitive_Operations to handle overloaded indexing operations
+       of a derived type.
+
 2015-10-26  Arnaud Charlet  <charlet@adacore.com>
 
        * osint-c.ads: Minor comment update.
index e74a0a7ffc20ae0b23c2352764fc11e1a64aba58..22e42dd6de103f641faa3bc2ce9e9678c6d6a5a2 100644 (file)
@@ -1566,7 +1566,7 @@ package Einfo is
 --       delayed and is one of the characteristics that may be inherited by
 --       types derived from this type if not overridden. If this flag is set,
 --       then types derived from this type have May_Inherit_Delayed_Rep_Aspects
---       set, signalling that Freeze.Inhert_Delayed_Rep_Aspects must be called
+--       set, signalling that Freeze.Inherit_Delayed_Rep_Aspects must be called
 --       at the freeze point of the derived type.
 
 --    Has_Discriminants (Flag5)
index c9beb0ccc30e697443950d057fc560d8c3435b9a..0c2fb6f7c9245bdda87c16a903e6ff823750b4de 100644 (file)
@@ -54,7 +54,7 @@ package Err_Vars is
    --  variables are not reset by calls to the error message routines, so the
    --  caller is responsible for resetting the default behavior after use.
 
-   Error_Msg_Qual_Level : Int := 0;
+   Error_Msg_Qual_Level : Nat := 0;
    --  Number of levels of qualification required for type name (see the
    --  description of the } insertion character. Note that this value does
    --  not get reset by any Error_Msg call, so the caller is responsible
index be0c936d29857c3d33172a797388cdc030f35ebe..4540c9380ae4eb2652512f9023e2128294c1c546 100644 (file)
@@ -474,7 +474,7 @@ package Errout is
    Error_Msg_Node_2 : Node_Id renames Err_Vars.Error_Msg_Node_2;
    --  Node_Id values for & insertion characters in message
 
-   Error_Msg_Qual_Level : Int renames Err_Vars.Error_Msg_Qual_Level;
+   Error_Msg_Qual_Level : Nat renames Err_Vars.Error_Msg_Qual_Level;
    --  Number of levels of qualification required for type name (see the
    --  description of the } insertion character). Note that this value does
    --  not get reset by any Error_Msg call, so the caller is responsible
index 790556fdd2553bcfe7c1d43138373ceacd44c998..73fb9b85deabe997362ba908f8a42b58d21bebbb 100644 (file)
@@ -2707,6 +2707,50 @@ package body Exp_Util is
       end if;
    end Find_Optional_Prim_Op;
 
+   -------------------------------
+   -- Find_Primitive_Operations --
+   -------------------------------
+
+   function Find_Primitive_Operations
+     (T    : Entity_Id;
+      Name : Name_Id) return Node_Id
+   is
+      Prim_Elmt : Elmt_Id;
+      Prim_Id   : Entity_Id;
+      Ref       : Node_Id;
+      Typ       : Entity_Id := T;
+
+   begin
+      if Is_Class_Wide_Type (Typ) then
+         Typ := Root_Type (Typ);
+      end if;
+
+      Typ := Underlying_Type (Typ);
+
+      Ref := Empty;
+      Prim_Elmt := First_Elmt (Primitive_Operations (Typ));
+      while Present (Prim_Elmt) loop
+         Prim_Id := Node (Prim_Elmt);
+            if Chars (Prim_Id) = Name then
+
+               --  If this is the first primitive operation found,
+               --  create a reference to it.
+
+               if No (Ref) then
+                  Ref := New_Occurrence_Of (Prim_Id, Sloc (T));
+
+               --  Otherwise, add interpretation to existing reference
+
+               else
+                  Add_One_Interp (Ref, Prim_Id, Etype (Prim_Id));
+               end if;
+            end if;
+         Next_Elmt (Prim_Elmt);
+      end loop;
+
+      return Ref;
+   end Find_Primitive_Operations;
+
    ------------------
    -- Find_Prim_Op --
    ------------------
index 913c71b97c521c21eb4325d6ed9cd52b77df814d..b6cf41d3b59f0b14ad43bb1c81ac50bb0b6859c4 100644 (file)
@@ -467,6 +467,13 @@ package Exp_Util is
    --  Ada 2005 (AI-251): Given a type T implementing the interface Iface,
    --  return the record component containing the tag of Iface.
 
+   function Find_Primitive_Operations
+     (T    : Entity_Id;
+      Name : Name_Id) return Node_Id;
+   --  Return a reference to a primitive operation with given name. If
+   --  operation is overloaded, the node carries the corresponding set
+   --  of overloaded interpretations.
+
    function Find_Prim_Op (T : Entity_Id; Name : Name_Id) return Entity_Id;
    --  Find the first primitive operation of a tagged type T with name Name.
    --  This function allows the use of a primitive operation which is not
index 727e90a44013eb1aab7adf430c6a0511bee48fbe..cd89cb570fdd78cea52b8db148b3e5fd451e0372 100644 (file)
@@ -1036,7 +1036,7 @@ begin
       Original_Operating_Mode := Operating_Mode;
       Frontend;
 
-      --  Exit with errors if the main source could not be parsed.
+      --  Exit with errors if the main source could not be parsed
 
       if Sinput.Main_Source_File = No_Source_File then
          Errout.Finalize (Last_Call => True);
index d1c0b169f06f31d466672e4ca40d6fa19b488e9f..ac5b445cdaf23b7c7eecceaff9097c03c6fa6534 100644 (file)
@@ -143,7 +143,7 @@ package body Prj is
 
       while Last + S'Length > To'Last loop
          declare
-            New_Buffer : constant  String_Access :=
+            New_Buffer : constant String_Access :=
                            new String (1 .. 2 * To'Length);
          begin
             New_Buffer (1 .. Last) := To (1 .. Last);
index 48a531d0350df1f4e3ea6d822c7fa972ed01e068..c34113a7da761272a23e686f5952bb29b44c3627 100644 (file)
@@ -546,7 +546,7 @@ package Restrict is
    function Cunit_Boolean_Restrictions_Save
      return Save_Cunit_Boolean_Restrictions;
    --  This function saves the compilation unit restriction settings, leaving
-   --  then unchanged. This is used e.g. at the start of processing a context
+   --  them unchanged. This is used e.g. at the start of processing a context
    --  clause, so that the main unit restrictions can be restored after all
    --  the with'ed units have been processed.
 
index 1d8882e3ad8b5a303fe1789507a5a24a4727e692..e9d54f84f47ba86c99237d7abe8556df3597a199 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2014, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2015, 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- --
@@ -433,8 +433,8 @@ package body System.File_IO is
    --                                     OPEN         CREATE
    --     Append_File                     "r+"           "w+"
    --     In_File                         "r"            "w+"
-   --     Out_File (Direct_IO)            "r+"           "w"
-   --     Out_File (all others)           "w"            "w"
+   --     Out_File (Direct_IO, Stream_IO) "r+"           "w"
+   --     Out_File (others)               "w"            "w"
    --     Inout_File                      "r+"           "w+"
 
    --  Note: we do not use "a" or "a+" for Append_File, since this would not
@@ -479,7 +479,7 @@ package body System.File_IO is
             end if;
 
          when Out_File =>
-            if Amethod = 'D' and then not Creat then
+            if Amethod in 'D' | 'S' and then not Creat then
                Fopstr (1) := 'r';
                Fopstr (2) := '+';
                Fptr := 3;
index d5ef0229e475fe49dc8b3292de4eaff628a1ba49..4127ec995231128cd557300e2aa08551ca55f81f 100644 (file)
@@ -7,7 +7,7 @@
 --                                 B o d y                                  --
 --                                                                          --
 --               Copyright (C) 1986 by University of Toronto.               --
---                      Copyright (C) 1999-2014, AdaCore                    --
+--                      Copyright (C) 1999-2015, AdaCore                    --
 --                                                                          --
 -- 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- --
@@ -413,7 +413,7 @@ package body System.Regpat is
          Capturing     : Boolean;
          Flags         : out Expression_Flags;
          IP            : out Pointer);
-      --  Parse regular expression, i.e. main body or parenthesized thing
+      --  Parse regular expression, i.e. main body or parenthesized thing.
       --  Caller must absorb opening parenthesis. Capturing should be set to
       --  True when we have an open parenthesis from which we want the user
       --  to extra text.
@@ -422,7 +422,7 @@ package body System.Regpat is
         (Flags         : out Expression_Flags;
          First         : Boolean;
          IP            : out Pointer);
-      --  Implements the concatenation operator and handles '|'
+      --  Implements the concatenation operator and handles '|'.
       --  First should be true if this is the first item of the alternative.
 
       procedure Parse_Piece
index 9928c3b0cfb11521a710892e46f3c5ae9d776f57..3b55ea3971f9685d3716fa94314bc1c75e22754a 100644 (file)
@@ -7215,20 +7215,17 @@ package body Sem_Ch4 is
 
       --  However, Reference is also a primitive operation of the type, and
       --  the inherited operation has a different signature. We retrieve the
-      --  right one from the list of primitive operations of the derived type.
+      --  right ones (the function may be overloaded) from the list of
+      --  primitive operations of the derived type.
 
       --  Note that predefined containers are typically all derived from one
       --  of the Controlled types. The code below is motivated by containers
       --  that are derived from other types with a Reference aspect.
 
-      --  Additional machinery may be needed for types that have several user-
-      --  defined Reference operations with different signatures ???
-
       elsif Is_Derived_Type (C_Type)
         and then Etype (First_Formal (Entity (Func_Name))) /= Etype (Prefix)
       then
-         Func := Find_Prim_Op (C_Type, Chars (Func_Name));
-         Func_Name := New_Occurrence_Of (Func, Loc);
+         Func_Name := Find_Primitive_Operations (C_Type, Chars (Func_Name));
       end if;
 
       Assoc := New_List (Relocate_Node (Prefix));
index 24e641ebfea19e1ca40a4b883e37d487d0d6f393..3e791799c2adc8605fccf199f02a8b5b0ff753b2 100644 (file)
@@ -394,7 +394,13 @@ package body Sem_Ch5 is
 
       --  Cases where Lhs is not a variable
 
-      if not Is_Variable (Lhs) then
+      --  Cases where Lhs is not a variable. In an instance or an inlined body
+      --  no need for further check because assignment was legal in template.
+
+      if In_Inlined_Body then
+         null;
+
+      elsif not Is_Variable (Lhs) then
 
          --  Ada 2005 (AI-327): Check assignment to the attribute Priority of a
          --  protected object.
index d36cf850b4bcfe04f67dbf73ab8958d9e158ec79..97d852005871568a79e5378c4deefb516e23a76a 100644 (file)
@@ -4833,7 +4833,7 @@ package body Sem_Ch6 is
 
                else
                   declare
-                     T : constant  Entity_Id := Find_Dispatching_Type (New_Id);
+                     T : constant Entity_Id := Find_Dispatching_Type (New_Id);
                   begin
                      if Is_Protected_Type (Corresponding_Concurrent_Type (T))
                      then
index 779e91e0d16c85fdd0cf7475f0d9f39e16f5ac8e..cd0a392c7fc5db9a4ca899aba9f7b4f55f91b3ec 100644 (file)
@@ -4635,7 +4635,7 @@ package body Sem_Prag is
          P : constant Node_Id := Parent (N);
 
       begin
-         --  Must be at in subprogram body
+         --  Must be in subprogram body
 
          if Nkind (P) /= N_Subprogram_Body then
             Error_Pragma ("% pragma allowed only in subprogram");
index 464619a2061623c6d416b35dc2f55129b3525309..cf7c57e3c0171bdf530e4c604e2c25e170e47acb 100644 (file)
@@ -19690,7 +19690,7 @@ package body Sem_Util is
             Expec_Scope := Expec_Type;
             Found_Scope := Found_Type;
 
-            for Levels in Int range 0 .. 3 loop
+            for Levels in Nat range 0 .. 3 loop
                if Chars (Expec_Scope) /= Chars (Found_Scope) then
                   Error_Msg_Qual_Level := Levels;
                   exit;