From: Arnaud Charlet Date: Fri, 5 Jul 2013 10:40:03 +0000 (+0200) Subject: [multiple changes] X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=67a90476cfab907864d3c97decdba6373be1b8b7;p=gcc.git [multiple changes] 2013-07-05 Claire Dross * a-cfdlli.ads: Add preconditions when needed. 2013-07-05 Robert Dewar * sem_ch8.adb: Minor reformatting. 2013-07-05 Ed Schonberg * 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 * 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 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index c395a27ca51..3b1202dfba3 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,26 @@ +2013-07-05 Claire Dross + + * a-cfdlli.ads: Add preconditions when needed. + +2013-07-05 Robert Dewar + + * sem_ch8.adb: Minor reformatting. + +2013-07-05 Ed Schonberg + + * 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 + + * 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 * gnat_rm.texi: Update doc on missing pragmas. diff --git a/gcc/ada/a-cfdlli.ads b/gcc/ada/a-cfdlli.ads index 1078c1f5a34..8340abb2ae4 100644 --- a/gcc/ada/a-cfdlli.ads +++ b/gcc/ada/a-cfdlli.ads @@ -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 diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi index da16217fe29..5a6b6afe56f 100644 --- a/gcc/ada/gnat_ugn.texi +++ b/gcc/ada/gnat_ugn.texi @@ -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.} diff --git a/gcc/ada/lib-xref.adb b/gcc/ada/lib-xref.adb index 8825f066f4e..182c2b0a979 100644 --- a/gcc/ada/lib-xref.adb +++ b/gcc/ada/lib-xref.adb @@ -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; diff --git a/gcc/ada/lib-xref.ads b/gcc/ada/lib-xref.ads index cfb43d8b1dc..baa07daade9 100644 --- a/gcc/ada/lib-xref.ads +++ b/gcc/ada/lib-xref.ads @@ -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 diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index a3b2c4e3a3e..7cbb9b92fee 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -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)); diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index f00300222d2..a8b8491fc0b 100644 --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -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; diff --git a/gcc/ada/styleg.adb b/gcc/ada/styleg.adb index 04634d171a6..6e4a44207e6 100644 --- a/gcc/ada/styleg.adb +++ b/gcc/ada/styleg.adb @@ -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;