[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Fri, 8 Sep 2017 13:44:39 +0000 (15:44 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Fri, 8 Sep 2017 13:44:39 +0000 (15:44 +0200)
2017-09-08  Eric Botcazou  <ebotcazou@adacore.com>

* sem_util.adb (NCT_Tables_In_Use): Move to library level from...
(New_Copy_Tree): ...there.  Reset the hash tables only if they
were used in the previous invocation.
* s-htable.adb: Fix typo.

2017-09-08  Bob Duff  <duff@adacore.com>

* a-ssicst.adb (Open): Set File.Last_Op to the appropriate value.

2017-09-08  Arnaud Charlet  <charlet@adacore.com>

* sem_aggr.adb: minor style fix.

2017-09-08  Bob Duff  <duff@adacore.com>

* sprint.adb (Write_Corresponding_Source): Ignore if there is
no current source file.
(Write_Name_With_Col_Check, Write_Name_With_Col_Check_Sloc):
Print something helpful in case N is invalid.
* sprint.ads: Minor comment fix.

From-SVN: r251897

gcc/ada/ChangeLog
gcc/ada/a-ssicst.adb
gcc/ada/s-htable.adb
gcc/ada/sem_aggr.adb
gcc/ada/sem_util.adb
gcc/ada/sprint.adb
gcc/ada/sprint.ads

index 2302293f545c22f1ed8593a1dc7e6627d2433e58..566b7a4fd6b15bd0b85fe83dc28e8aafe4d3e09b 100644 (file)
@@ -1,3 +1,26 @@
+2017-09-08  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * sem_util.adb (NCT_Tables_In_Use): Move to library level from...
+       (New_Copy_Tree): ...there.  Reset the hash tables only if they
+       were used in the previous invocation.
+       * s-htable.adb: Fix typo.
+
+2017-09-08  Bob Duff  <duff@adacore.com>
+
+       * a-ssicst.adb (Open): Set File.Last_Op to the appropriate value.
+
+2017-09-08  Arnaud Charlet  <charlet@adacore.com>
+
+       * sem_aggr.adb: minor style fix.
+
+2017-09-08  Bob Duff  <duff@adacore.com>
+
+       * sprint.adb (Write_Corresponding_Source): Ignore if there is
+       no current source file.
+       (Write_Name_With_Col_Check, Write_Name_With_Col_Check_Sloc):
+       Print something helpful in case N is invalid.
+       * sprint.ads: Minor comment fix.
+
 2017-09-08  Eric Botcazou  <ebotcazou@adacore.com>
 
        * exp_aggr.adb: (Aggr_Assignment_OK_For_Backend): Add early return for
index 4cf49f29c11e6db0b87a8c827e2ed5e6be65fc4e..1e5b394bcb582434728e42894ed9450033ca7927 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 B o d y                                  --
 --                                                                          --
---          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2017, 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- --
@@ -79,6 +79,9 @@ package body Ada.Streams.Stream_IO.C_Streams is
                 Creat     => False,
                 Text      => False,
                 C_Stream  => C_Stream);
+
+      File.Last_Op := (if Mode = Out_File then Op_Write else Op_Read);
+      --  See comment in Ada.Streams.Stream_IO.Open for the reason
    end Open;
 
 end Ada.Streams.Stream_IO.C_Streams;
index 8ad6eafb863a95fd5f3e022b85e59c6face6d244..f72b64923e417ce23feb86c9ce40ad8ad5b4b0e9 100644 (file)
@@ -171,7 +171,7 @@ package body System.HTable is
 
       procedure Reset is
       begin
-         --  Use an aggregate for efficient reasons
+         --  Use an aggregate for efficiency reasons
 
          Table := (others => Null_Ptr);
       end Reset;
index e02913d50dabc5269a9193397352d6df9d9ee96b..aa2510dd94331efc48e4b7f9b344ec3fc3792759 100644 (file)
@@ -4048,9 +4048,7 @@ package body Sem_Aggr is
             end if;
          end Rewrite_Bound;
 
-         ---------------------
-         -- Local Variables --
-         ---------------------
+         --  Local variables
 
          Low, High : Node_Id;
          Disc      : Entity_Id;
index 7e2dbe24757c537b32636c2bcf01814000597a3c..228a1d54a7e7567ba143c8b040dab038cf6ec90d 100644 (file)
@@ -17316,6 +17316,13 @@ package body Sem_Util is
    function NCT_Table_Hash (Key : Node_Or_Entity_Id) return NCT_Table_Index;
    --  Obtain the hash value of node or entity Key
 
+   NCT_Tables_In_Use : Boolean := False;
+   --  This flag keeps track of whether the two tables NCT_New_Entities and
+   --  NCT_Pending_Itypes are in use. The flag is part of an optimization
+   --  where certain operations are not performed if the tables are not in
+   --  use. This saves up to 8% of the entire compilation time spent in the
+   --  front end.
+
    --------------------
    -- NCT_Table_Hash --
    --------------------
@@ -17389,13 +17396,6 @@ package body Sem_Util is
       --  This counter keeps track of how many scoping constructs appear within
       --  an N_Expression_With_Actions node.
 
-      NCT_Tables_In_Use : Boolean := False;
-      --  This flag keeps track of whether the two tables NCT_New_Entities and
-      --  NCT_Pending_Itypes are in use. The flag is part of an optimization
-      --  where certain operations are not performed if the tables are not in
-      --  use. This saves up to 8% of the entire compilation time spent in the
-      --  front end.
-
       procedure Add_New_Entity (Old_Id : Entity_Id; New_Id : Entity_Id);
       pragma Inline (Add_New_Entity);
       --  Add an entry in the NCT_New_Entities table which maps key Old_Id to
@@ -18744,8 +18744,12 @@ package body Sem_Util is
       --  NCT_Pending_Itypes in case a previous call to New_Copy_Tree left some
       --  data inside.
 
-      NCT_New_Entities.Reset;
-      NCT_Pending_Itypes.Reset;
+      if NCT_Tables_In_Use then
+         NCT_Tables_In_Use := False;
+
+         NCT_New_Entities.Reset;
+         NCT_Pending_Itypes.Reset;
+      end if;
 
       --  Populate tables NCT_New_Entities and NCT_Pending_Itypes with data
       --  supplied by a linear entity map. The tables offer faster access to
index 85908cb7f57ca15c1c398d81be672334ce8939c8..d97a1f78dd7701eb1cef189881699964289e83fc 100644 (file)
@@ -3749,9 +3749,13 @@ package body Sprint is
       Src : Source_Buffer_Ptr;
 
    begin
-      --  Ignore if not in dump source text mode, or if in freeze actions
+      --  Ignore if there is no current source file, or we're not in dump
+      --  source text mode, or if in freeze actions.
 
-      if Dump_Source_Text and then Freeze_Indent = 0 then
+      if Current_Source_File /= No_Source_File
+        and then Dump_Source_Text
+        and then Freeze_Indent = 0
+      then
 
          --  Ignore null string
 
@@ -4504,6 +4508,15 @@ package body Sprint is
       L : Natural;
 
    begin
+      --  Avoid crashing on invalid Name_Ids
+
+      if not Is_Valid_Name (N) then
+         Write_Str ("<invalid name ");
+         Write_Int (Int (N));
+         Write_Str (">");
+         return;
+      end if;
+
       Get_Name_String (N);
 
       --  Deal with -gnatdI which replaces any sequence Cnnnb where C is an
@@ -4552,6 +4565,15 @@ package body Sprint is
 
    procedure Write_Name_With_Col_Check_Sloc (N : Name_Id) is
    begin
+      --  Avoid crashing on invalid Name_Ids
+
+      if not Is_Valid_Name (N) then
+         Write_Str ("<invalid name ");
+         Write_Int (Int (N));
+         Write_Str (">");
+         return;
+      end if;
+
       Get_Name_String (N);
       Write_Str_With_Col_Check_Sloc (Name_Buffer (1 .. Name_Len));
    end Write_Name_With_Col_Check_Sloc;
index 85518bee259b7c45127f3b77478d2f74ee795e12..275960e23bbb2509476a64ba6483b720ffbef804 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---          Copyright (C) 1992-2013, Free Software Foundation, Inc.         --
+--          Copyright (C) 1992-2017, 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- --
@@ -42,7 +42,7 @@ package Sprint is
    --  When the generated tree is printed, it contains constructs that are not
    --  pure Ada. For convenience, syntactic extensions to Ada have been defined
    --  purely for the purposes of this printout (they are not recognized by the
-   --  parser)
+   --  parser).
 
    --  Could use more documentation for all of these ???