Commit 67a90476 by Arnaud Charlet

[multiple changes]

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
parent 6ee07c61
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> 2013-07-05 Robert Dewar <dewar@adacore.com>
* gnat_rm.texi: Update doc on missing pragmas. * gnat_rm.texi: Update doc on missing pragmas.
......
...@@ -78,112 +78,145 @@ package Ada.Containers.Formal_Doubly_Linked_Lists is ...@@ -78,112 +78,145 @@ package Ada.Containers.Formal_Doubly_Linked_Lists is
procedure Clear (Container : in out List); 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 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 procedure Replace_Element
(Container : in out List; (Container : in out List;
Position : Cursor; 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 procedure Insert
(Container : in out List; (Container : in out List;
Before : Cursor; Before : Cursor;
New_Item : Element_Type; 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 procedure Insert
(Container : in out List; (Container : in out List;
Before : Cursor; Before : Cursor;
New_Item : Element_Type; New_Item : Element_Type;
Position : out 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 Insert procedure Insert
(Container : in out List; (Container : in out List;
Before : Cursor; Before : Cursor;
Position : out 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 procedure Prepend
(Container : in out List; (Container : in out List;
New_Item : Element_Type; New_Item : Element_Type;
Count : Count_Type := 1); Count : Count_Type := 1)
with Pre => Length (Container) + Count <= Container.Capacity;
procedure Append procedure Append
(Container : in out List; (Container : in out List;
New_Item : Element_Type; New_Item : Element_Type;
Count : Count_Type := 1); Count : Count_Type := 1)
with Pre => Length (Container) + Count <= Container.Capacity;
procedure Delete procedure Delete
(Container : in out List; (Container : in out List;
Position : in out Cursor; Position : in out Cursor;
Count : Count_Type := 1); Count : Count_Type := 1)
with Pre => Has_Element (Container, Position);
procedure Delete_First procedure Delete_First
(Container : in out List; (Container : in out List;
Count : Count_Type := 1); Count : Count_Type := 1)
with Pre => not Is_Empty (Container);
procedure Delete_Last procedure Delete_Last
(Container : in out List; (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 Reverse_Elements (Container : in out List);
procedure Swap procedure Swap
(Container : in out List; (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 procedure Swap_Links
(Container : in out List; (Container : in out List;
I, J : Cursor); I, J : Cursor)
with Pre => Has_Element (Container, I) and then Has_Element (Container, J);
procedure Splice procedure Splice
(Target : in out List; (Target : in out List;
Before : Cursor; 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 procedure Splice
(Target : in out List; (Target : in out List;
Before : Cursor; Before : Cursor;
Source : in out List; 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 procedure Splice
(Container : in out List; (Container : in out List;
Before : Cursor; 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 (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 (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 function Find
(Container : List; (Container : List;
Item : Element_Type; 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 function Reverse_Find
(Container : List; (Container : List;
Item : Element_Type; 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 function Contains
(Container : List; (Container : List;
...@@ -208,8 +241,10 @@ package Ada.Containers.Formal_Doubly_Linked_Lists is ...@@ -208,8 +241,10 @@ package Ada.Containers.Formal_Doubly_Linked_Lists is
-- they are structurally equal (function "=" returns True) and that they -- they are structurally equal (function "=" returns True) and that they
-- have the same set of cursors. -- have the same set of cursors.
function Left (Container : List; Position : Cursor) return List; function Left (Container : List; Position : Cursor) return List
function Right (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 -- Left returns a container containing all elements preceding Position
-- (excluded) in Container. Right returns a container containing all -- (excluded) in Container. Right returns a container containing all
-- elements following Position (included) in Container. These two new -- elements following Position (included) in Container. These two new
......
...@@ -6065,7 +6065,8 @@ the examples in the Ada Reference Manual. Full line comments must be ...@@ -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 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 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 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^ @item ^a^ATTRIBUTE^
@emph{Check attribute casing.} @emph{Check attribute casing.}
...@@ -1079,6 +1079,9 @@ package body Lib.Xref is ...@@ -1079,6 +1079,9 @@ package body Lib.Xref is
Next_Entity (Formal); Next_Entity (Formal);
end loop; end loop;
elsif Ekind (E) in Access_Subprogram_Kind then
Formal := First_Formal (Designated_Type (E));
else else
Formal := First_Formal (E); Formal := First_Formal (E);
end if; end if;
......
...@@ -718,7 +718,7 @@ package Lib.Xref is ...@@ -718,7 +718,7 @@ package Lib.Xref is
procedure Generate_Reference_To_Formals (E : Entity_Id); procedure Generate_Reference_To_Formals (E : Entity_Id);
-- Add a reference to the definition of each formal on the line for -- 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); procedure Generate_Reference_To_Generic_Formals (E : Entity_Id);
-- Add a reference to the definition of each generic formal on the line -- Add a reference to the definition of each generic formal on the line
......
...@@ -1283,6 +1283,8 @@ package body Sem_Ch3 is ...@@ -1283,6 +1283,8 @@ package body Sem_Ch3 is
Init_Size_Align (T_Name); Init_Size_Align (T_Name);
Set_Directly_Designated_Type (T_Name, Desig_Type); Set_Directly_Designated_Type (T_Name, Desig_Type);
Generate_Reference_To_Formals (T_Name);
-- Ada 2005 (AI-231): Propagate the null-excluding attribute -- Ada 2005 (AI-231): Propagate the null-excluding attribute
Set_Can_Never_Be_Null (T_Name, Null_Exclusion_Present (T_Def)); Set_Can_Never_Be_Null (T_Name, Null_Exclusion_Present (T_Def));
......
...@@ -2081,7 +2081,7 @@ package body Sem_Ch8 is ...@@ -2081,7 +2081,7 @@ package body Sem_Ch8 is
else else
Error_Msg_NE Error_Msg_NE
("type& must be frozen before this point", ("type& must be frozen before this point",
Instantiation_Node, Etype (F)); Instantiation_Node, Etype (F));
end if; end if;
end if; end if;
......
...@@ -351,7 +351,9 @@ package body Styleg is ...@@ -351,7 +351,9 @@ package body Styleg is
-- 6. In addition, the comment must be properly indented if comment -- 6. In addition, the comment must be properly indented if comment
-- indentation checking is active (Style_Check_Indentation non-zero). -- indentation checking is active (Style_Check_Indentation non-zero).
-- Either the start column must be a multiple of this indentation, -- 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 procedure Check_Comment is
S : Source_Ptr; S : Source_Ptr;
...@@ -369,6 +371,12 @@ package body Styleg is ...@@ -369,6 +371,12 @@ package body Styleg is
-- matches that of the next non-blank line in the source, then True is -- matches that of the next non-blank line in the source, then True is
-- returned, otherwise False. -- 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 -- -- Is_Box_Comment --
-------------------- --------------------
...@@ -429,6 +437,39 @@ package body Styleg is ...@@ -429,6 +437,39 @@ package body Styleg is
return Get_Column_Number (Scan_Ptr) = Get_Column_Number (P); return Get_Column_Number (Scan_Ptr) = Get_Column_Number (P);
end Same_Column_As_Next_Non_Blank_Line; 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 -- Start of processing for Check_Comment
begin begin
...@@ -466,7 +507,9 @@ package body Styleg is ...@@ -466,7 +507,9 @@ package body Styleg is
if Style_Check_Indentation /= 0 then if Style_Check_Indentation /= 0 then
if Start_Column rem 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 Error_Msg_S -- CODEFIX
("(style) bad column"); ("(style) bad column");
end if; end if;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment