[multiple changes]
authorArnaud Charlet <charlet@gcc.gnu.org>
Fri, 5 Jul 2013 10:40:03 +0000 (12:40 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Fri, 5 Jul 2013 10:40:03 +0000 (12:40 +0200)
2013-07-05  Claire Dross  <dross@adacore.com>

* a-cfdlli.ads: Add preconditions when needed.

2013-07-05  Robert Dewar  <dewar@adacore.com>

* sem_ch8.adb: Minor reformatting.

2013-07-05  Ed Schonberg  <schonberg@adacore.com>

* sem_ch3.adb (Access_Subprogram_Declaration): Use
Generate_Reference_To_Formals.
* lib-xref.adb (Generate_Reference_To_Formals): In the case of
access to subprograms, the formals are found in the designated
subprogram type.

2013-07-05  Robert Dewar  <dewar@adacore.com>

* gnat_ugn.texi: Document that comments can be lined up with
previous non-blank line.
* styleg.adb (Check_Comment): Allow indentation to match previous
non-blank line (Same_Column_As_Previous_Line): New function

From-SVN: r200705

gcc/ada/ChangeLog
gcc/ada/a-cfdlli.ads
gcc/ada/gnat_ugn.texi
gcc/ada/lib-xref.adb
gcc/ada/lib-xref.ads
gcc/ada/sem_ch3.adb
gcc/ada/sem_ch8.adb
gcc/ada/styleg.adb

index c395a27ca516c100485bac75d82d0aebea182086..3b1202dfba351f212f32821379940fc7de8d7473 100644 (file)
@@ -1,3 +1,26 @@
+2013-07-05  Claire Dross  <dross@adacore.com>
+
+       * a-cfdlli.ads: Add preconditions when needed.
+
+2013-07-05  Robert Dewar  <dewar@adacore.com>
+
+       * sem_ch8.adb: Minor reformatting.
+
+2013-07-05  Ed Schonberg  <schonberg@adacore.com>
+
+       * sem_ch3.adb (Access_Subprogram_Declaration): Use
+       Generate_Reference_To_Formals.
+       * lib-xref.adb (Generate_Reference_To_Formals): In the case of
+       access to subprograms, the formals are found in the designated
+       subprogram type.
+
+2013-07-05  Robert Dewar  <dewar@adacore.com>
+
+       * gnat_ugn.texi: Document that comments can be lined up with
+       previous non-blank line.
+       * styleg.adb (Check_Comment): Allow indentation to match previous
+       non-blank line (Same_Column_As_Previous_Line): New function
+
 2013-07-05  Robert Dewar  <dewar@adacore.com>
 
        * gnat_rm.texi: Update doc on missing pragmas.
index 1078c1f5a341d3c5d852a0777e5086a19bf9fbb5..8340abb2ae450f5c5ad1bff6e21c7f7548aa1696 100644 (file)
@@ -78,112 +78,145 @@ package Ada.Containers.Formal_Doubly_Linked_Lists is
 
    procedure Clear (Container : in out List);
 
-   procedure Assign (Target : in out List; Source : List);
+   procedure Assign (Target : in out List; Source : List)
+   with Pre => Target.Capacity >= Length (Source);
 
    function Copy (Source : List; Capacity : Count_Type := 0) return List;
 
-   function Element (Container : List; Position : Cursor) return Element_Type;
+   function Element (Container : List; Position : Cursor) return Element_Type
+   with Pre => Has_Element (Container, Position);
 
    procedure Replace_Element
      (Container : in out List;
       Position  : Cursor;
-      New_Item  : Element_Type);
+      New_Item  : Element_Type)
+   with Pre => Has_Element (Container, Position);
 
-   procedure Move (Target : in out List; Source : in out List);
+   procedure Move (Target : in out List; Source : in out List)
+   with Pre => Target.Capacity >= Length (Source);
 
    procedure Insert
      (Container : in out List;
       Before    : Cursor;
       New_Item  : Element_Type;
-      Count     : Count_Type := 1);
+      Count     : Count_Type := 1)
+   with Pre => Length (Container) + Count <= Container.Capacity and then
+     (Has_Element (Container, Before) or else Before = No_Element);
 
    procedure Insert
      (Container : in out List;
       Before    : Cursor;
       New_Item  : Element_Type;
       Position  : out Cursor;
-      Count     : Count_Type := 1);
+      Count     : Count_Type := 1)
+   with Pre => Length (Container) + Count <= Container.Capacity and then
+     (Has_Element (Container, Before) or else Before = No_Element);
 
    procedure Insert
      (Container : in out List;
       Before    : Cursor;
       Position  : out Cursor;
-      Count     : Count_Type := 1);
+      Count     : Count_Type := 1)
+   with Pre => Length (Container) + Count <= Container.Capacity and then
+     (Has_Element (Container, Before) or else Before = No_Element);
 
    procedure Prepend
      (Container : in out List;
       New_Item  : Element_Type;
-      Count     : Count_Type := 1);
+      Count     : Count_Type := 1)
+   with Pre => Length (Container) + Count <= Container.Capacity;
 
    procedure Append
      (Container : in out List;
       New_Item  : Element_Type;
-      Count     : Count_Type := 1);
+      Count     : Count_Type := 1)
+   with Pre => Length (Container) + Count <= Container.Capacity;
 
    procedure Delete
      (Container : in out List;
       Position  : in out Cursor;
-      Count     : Count_Type := 1);
+      Count     : Count_Type := 1)
+   with Pre => Has_Element (Container, Position);
 
    procedure Delete_First
      (Container : in out List;
-      Count     : Count_Type := 1);
+      Count     : Count_Type := 1)
+   with Pre => not Is_Empty (Container);
 
    procedure Delete_Last
      (Container : in out List;
-      Count     : Count_Type := 1);
+      Count     : Count_Type := 1)
+   with Pre => not Is_Empty (Container);
 
    procedure Reverse_Elements (Container : in out List);
 
    procedure Swap
      (Container : in out List;
-      I, J      : Cursor);
+      I, J      : Cursor)
+   with Pre => Has_Element (Container, I) and then Has_Element (Container, J);
 
    procedure Swap_Links
      (Container : in out List;
-      I, J      : Cursor);
+      I, J      : Cursor)
+   with Pre => Has_Element (Container, I) and then Has_Element (Container, J);
 
    procedure Splice
      (Target : in out List;
       Before : Cursor;
-      Source : in out List);
+      Source : in out List)
+   with Pre => Length (Source) + Length (Target) <= Target.Capacity and then
+     (Has_Element (Target, Before) or else Before = No_Element);
 
    procedure Splice
      (Target   : in out List;
       Before   : Cursor;
       Source   : in out List;
-      Position : in out Cursor);
+      Position : in out Cursor)
+   with Pre => Length (Source) + Length (Target) <= Target.Capacity and then
+     (Has_Element (Target, Before) or else Before = No_Element) and then
+     Has_Element (Source, Position);
 
    procedure Splice
      (Container : in out List;
       Before    : Cursor;
-      Position  : Cursor);
+      Position  : Cursor)
+   with Pre => 2 * Length (Container) <= Container.Capacity and then
+     (Has_Element (Container, Before) or else Before = No_Element) and then
+     Has_Element (Container, Position);
 
    function First (Container : List) return Cursor;
 
-   function First_Element (Container : List) return Element_Type;
+   function First_Element (Container : List) return Element_Type
+   with Pre => not Is_Empty (Container);
 
    function Last (Container : List) return Cursor;
 
-   function Last_Element (Container : List) return Element_Type;
+   function Last_Element (Container : List) return Element_Type
+   with Pre => not Is_Empty (Container);
 
-   function Next (Container : List; Position : Cursor) return Cursor;
+   function Next (Container : List; Position : Cursor) return Cursor
+   with Pre => Has_Element (Container, Position) or else Position = No_Element;
 
-   procedure Next (Container : List; Position : in out Cursor);
+   procedure Next (Container : List; Position : in out Cursor)
+   with Pre => Has_Element (Container, Position) or else Position = No_Element;
 
-   function Previous (Container : List; Position : Cursor) return Cursor;
+   function Previous (Container : List; Position : Cursor) return Cursor
+   with Pre => Has_Element (Container, Position) or else Position = No_Element;
 
-   procedure Previous (Container : List; Position : in out Cursor);
+   procedure Previous (Container : List; Position : in out Cursor)
+   with Pre => Has_Element (Container, Position) or else Position = No_Element;
 
    function Find
      (Container : List;
       Item      : Element_Type;
-      Position  : Cursor := No_Element) return Cursor;
+      Position  : Cursor := No_Element) return Cursor
+   with Pre => Has_Element (Container, Position) or else Position = No_Element;
 
    function Reverse_Find
      (Container : List;
       Item      : Element_Type;
-      Position  : Cursor := No_Element) return Cursor;
+      Position  : Cursor := No_Element) return Cursor
+   with Pre => Has_Element (Container, Position) or else Position = No_Element;
 
    function Contains
      (Container : List;
@@ -208,8 +241,10 @@ package Ada.Containers.Formal_Doubly_Linked_Lists is
    --  they are structurally equal (function "=" returns True) and that they
    --  have the same set of cursors.
 
-   function Left  (Container : List; Position : Cursor) return List;
-   function Right (Container : List; Position : Cursor) return List;
+   function Left  (Container : List; Position : Cursor) return List
+   with Pre => Has_Element (Container, Position) or else Position = No_Element;
+   function Right (Container : List; Position : Cursor) return List
+   with Pre => Has_Element (Container, Position) or else Position = No_Element;
    --  Left returns a container containing all elements preceding Position
    --  (excluded) in Container. Right returns a container containing all
    --  elements following Position (included) in Container. These two new
index da16217fe29d247276cc5c88bf533c4ec4b94e02..5a6b6afe56f29906e513034abeda391b1d7fad6d 100644 (file)
@@ -6065,7 +6065,8 @@ the examples in the Ada Reference Manual. Full line comments must be
 aligned with the @code{--} starting on a column that is a multiple of
 the alignment level, or they may be aligned the same way as the following
 non-blank line (this is useful when full line comments appear in the middle
-of a statement.
+of a statement, or they may be aligned with the source line on the previous
+non-blank line.
 
 @item ^a^ATTRIBUTE^
 @emph{Check attribute casing.}
index 8825f066f4ec59ba079a037de7fff3b1069730c1..182c2b0a97949c626a1c8cf8bba40bd70210806c 100644 (file)
@@ -1079,6 +1079,9 @@ package body Lib.Xref is
             Next_Entity (Formal);
          end loop;
 
+      elsif Ekind (E) in Access_Subprogram_Kind then
+         Formal := First_Formal (Designated_Type (E));
+
       else
          Formal := First_Formal (E);
       end if;
index cfb43d8b1dc59fb5a7e6d1b39ac6346ad8d07d5a..baa07daade9c3a82f5606ff4c12b28ed7bf5246e 100644 (file)
@@ -718,7 +718,7 @@ package Lib.Xref is
 
    procedure Generate_Reference_To_Formals (E : Entity_Id);
    --  Add a reference to the definition of each formal on the line for
-   --  a subprogram.
+   --  a subprogram or an access_to_subprogram type.
 
    procedure Generate_Reference_To_Generic_Formals (E : Entity_Id);
    --  Add a reference to the definition of each generic formal on the line
index a3b2c4e3a3e132ebab38ddd271078267a6448fa2..7cbb9b92fee84bad66787eeaa6af4582492551a6 100644 (file)
@@ -1283,6 +1283,8 @@ package body Sem_Ch3 is
       Init_Size_Align              (T_Name);
       Set_Directly_Designated_Type (T_Name, Desig_Type);
 
+      Generate_Reference_To_Formals (T_Name);
+
       --  Ada 2005 (AI-231): Propagate the null-excluding attribute
 
       Set_Can_Never_Be_Null (T_Name, Null_Exclusion_Present (T_Def));
index f00300222d2ce95bbe2df7e9d44a77bee56d4220..a8b8491fc0bdb1c3aa0d6fa4be0caedccb742aee 100644 (file)
@@ -2081,7 +2081,7 @@ package body Sem_Ch8 is
                      else
                         Error_Msg_NE
                           ("type& must be frozen before this point",
-                             Instantiation_Node, Etype (F));
+                           Instantiation_Node, Etype (F));
                      end if;
                   end if;
 
index 04634d171a68bc4ed3872b8cbf154a4345b890dc..6e4a44207e60648913bf83227d174820e4d5394b 100644 (file)
@@ -351,7 +351,9 @@ package body Styleg is
    --    6. In addition, the comment must be properly indented if comment
    --       indentation checking is active (Style_Check_Indentation non-zero).
    --       Either the start column must be a multiple of this indentation,
-   --       or the indentation must match that of the next non-blank line.
+   --       or the indentation must match that of the next non-blank line,
+   --       or must match the indentation of the immediately preciding line
+   --       if it is non-blank.
 
    procedure Check_Comment is
       S : Source_Ptr;
@@ -369,6 +371,12 @@ package body Styleg is
       --  matches that of the next non-blank line in the source, then True is
       --  returned, otherwise False.
 
+      function Same_Column_As_Previous_Line return Boolean;
+      --  Called for a full line comment. If the previous line is blank, then
+      --  returns False. Otherwise, if the indentation of this comment matches
+      --  that of the previous line in the source, then True is returned,
+      --  otherwise False.
+
       --------------------
       -- Is_Box_Comment --
       --------------------
@@ -429,6 +437,39 @@ package body Styleg is
          return Get_Column_Number (Scan_Ptr) = Get_Column_Number (P);
       end Same_Column_As_Next_Non_Blank_Line;
 
+      ----------------------------------
+      -- Same_Column_As_Previous_Line --
+      ----------------------------------
+
+      function Same_Column_As_Previous_Line return Boolean is
+         S, P : Source_Ptr;
+
+      begin
+         --  Point S to start of this line, and P to start of previous line
+
+         S := Line_Start (Scan_Ptr);
+         P := S;
+         Backup_Line (P);
+
+         --  Step P to first non-blank character on line
+
+         loop
+            --  If we get back to start of current line, then the previous line
+            --  was blank, and we always return False in that situation.
+
+            if P = S then
+               return False;
+            end if;
+
+            exit when Source (P) /= ' ' and then Source (P) /= ASCII.HT;
+            P := P + 1;
+         end loop;
+
+         --  Compare columns
+
+         return Get_Column_Number (Scan_Ptr) = Get_Column_Number (P);
+      end Same_Column_As_Previous_Line;
+
    --  Start of processing for Check_Comment
 
    begin
@@ -466,7 +507,9 @@ package body Styleg is
 
          if Style_Check_Indentation /= 0 then
             if Start_Column rem Style_Check_Indentation /= 0 then
-               if not Same_Column_As_Next_Non_Blank_Line then
+               if not Same_Column_As_Next_Non_Blank_Line
+                 and then not Same_Column_As_Previous_Line
+               then
                   Error_Msg_S -- CODEFIX
                     ("(style) bad column");
                end if;