Commit 1804faa4 by Arnaud Charlet

[multiple changes]

2017-05-02  Ed Schonberg  <schonberg@adacore.com>

	* exp_ch3.adb (Build_Initialization_Call): Generate a null
	statement if the initialization call is a null procedure, as
	can happen with a controlled type with no explicit Initialize
	procedure, or an array of such.
	* exp_ch7.adb (Process_Object_Declaration): For a type with
	controlled components that has a trivial Initialize procedure,
	insert declaration for finalization counter after object
	declaration itself.
	(Make_Deep_Array_Body, Build_Initialize_statements): Do not create
	finalization block and attendant declarations if component has
	a trivial Initialize procedure.
	(Make_Init_Call): Do not generate a call if controlled type has
	a trivial Initialize procedure.

2017-05-02  Eric Botcazou  <ebotcazou@adacore.com>

	* g-forstr.ads (Data): Move Format component last.
	* g-forstr.adb ("+"): Adjust for above change.
	* g-rewdat.ads (Buffer): Move Buffer, Current, Pattern and Value last.
	* g-sechas.ads (Context): Move Key last.
	* g-socket.ads (Service_Entry_Type): Move Aliases last.
	* s-fileio.adb (Temp_File_Record): Move Name last.
	* s-regexp.adb (Regexp_Value): Move Case_Sensitive last.
	* xr_tabls.ads (Project_File): Move Src_Dir and Obj_Dir last.

2017-05-02  Jerome Lambourg  <lambourg@adacore.com>

	* bindusg.adb, bindgen.adb, gnatbind.adb, opt.ads: Remove the -nognarl
	switch introduced recently. finally not needed.

2017-05-02  Hristian Kirtchev  <kirtchev@adacore.com>

	* sem_ch6.adb (Analyze_Null_Procedure): Set the
	Corresponding_Body link for a null procedure declaration.

From-SVN: r247475
parent 62d40a7a
2017-05-02 Ed Schonberg <schonberg@adacore.com>
* exp_ch3.adb (Build_Initialization_Call): Generate a null
statement if the initialization call is a null procedure, as
can happen with a controlled type with no explicit Initialize
procedure, or an array of such.
* exp_ch7.adb (Process_Object_Declaration): For a type with
controlled components that has a trivial Initialize procedure,
insert declaration for finalization counter after object
declaration itself.
(Make_Deep_Array_Body, Build_Initialize_statements): Do not create
finalization block and attendant declarations if component has
a trivial Initialize procedure.
(Make_Init_Call): Do not generate a call if controlled type has
a trivial Initialize procedure.
2017-05-02 Eric Botcazou <ebotcazou@adacore.com>
* g-forstr.ads (Data): Move Format component last.
* g-forstr.adb ("+"): Adjust for above change.
* g-rewdat.ads (Buffer): Move Buffer, Current, Pattern and Value last.
* g-sechas.ads (Context): Move Key last.
* g-socket.ads (Service_Entry_Type): Move Aliases last.
* s-fileio.adb (Temp_File_Record): Move Name last.
* s-regexp.adb (Regexp_Value): Move Case_Sensitive last.
* xr_tabls.ads (Project_File): Move Src_Dir and Obj_Dir last.
2017-05-02 Jerome Lambourg <lambourg@adacore.com>
* bindusg.adb, bindgen.adb, gnatbind.adb, opt.ads: Remove the -nognarl
switch introduced recently. finally not needed.
2017-05-02 Hristian Kirtchev <kirtchev@adacore.com>
* sem_ch6.adb (Analyze_Null_Procedure): Set the
Corresponding_Body link for a null procedure declaration.
2017-05-02 Eric Botcazou <ebotcazou@adacore.com> 2017-05-02 Eric Botcazou <ebotcazou@adacore.com>
* atree.h (Flag290): Add missing terminating parenthesis. * atree.h (Flag290): Add missing terminating parenthesis.
......
...@@ -2853,9 +2853,7 @@ package body Bindgen is ...@@ -2853,9 +2853,7 @@ package body Bindgen is
-- used: System.OS_Interface should always be used by any tasking -- used: System.OS_Interface should always be used by any tasking
-- application. -- application.
if not Opt.No_Libgnarl then Check_Package (With_GNARL, "system.os_interface%s");
Check_Package (With_GNARL, "system.os_interface%s");
end if;
-- Ditto for the use of restricted tasking -- Ditto for the use of restricted tasking
......
...@@ -178,11 +178,6 @@ package body Bindusg is ...@@ -178,11 +178,6 @@ package body Bindusg is
Write_Line Write_Line
(" -n No Ada main program (foreign main routine)"); (" -n No Ada main program (foreign main routine)");
-- Line for -nognarl
Write_Line
(" -nognarl Don't use libgnarl when writing linker instructions");
-- Line for -nostdinc -- Line for -nostdinc
Write_Line Write_Line
......
...@@ -1431,6 +1431,15 @@ package body Exp_Ch3 is ...@@ -1431,6 +1431,15 @@ package body Exp_Ch3 is
if Is_Null_Init_Proc (Proc) and then not Init_Or_Norm_Scalars then if Is_Null_Init_Proc (Proc) and then not Init_Or_Norm_Scalars then
return Empty_List; return Empty_List;
-- Nothing to do for an array of controlled components that have only
-- the inherited Initialize primitive. This is a useful optimization
-- for CodePeer.
elsif Is_Trivial_Subprogram (Proc)
and then Is_Array_Type (Full_Init_Type)
then
return New_List (Make_Null_Statement (Loc));
end if; end if;
-- Use the [underlying] full view when dealing with a private type. This -- Use the [underlying] full view when dealing with a private type. This
......
...@@ -2945,6 +2945,14 @@ package body Exp_Ch7 is ...@@ -2945,6 +2945,14 @@ package body Exp_Ch7 is
Find_Last_Init (Count_Ins, Body_Ins); Find_Last_Init (Count_Ins, Body_Ins);
end if; end if;
-- If the Initialize function is null or trivial, the call will have
-- been replaced with a null statement, in which case place counter
-- declaration after object declaration itself.
if No (Count_Ins) then
Count_Ins := Decl;
end if;
Insert_After (Count_Ins, Inc_Decl); Insert_After (Count_Ins, Inc_Decl);
Analyze (Inc_Decl); Analyze (Inc_Decl);
...@@ -6144,7 +6152,12 @@ package body Exp_Ch7 is ...@@ -6144,7 +6152,12 @@ package body Exp_Ch7 is
Init_Call := Build_Initialization_Call; Init_Call := Build_Initialization_Call;
if Present (Init_Call) then -- Only create finalization block if there is a non-trivial
-- call to initialization.
if Present (Init_Call)
and then Nkind (Init_Call) /= N_Null_Statement
then
Init_Loop := Init_Loop :=
Make_Block_Statement (Loc, Make_Block_Statement (Loc,
Handled_Statement_Sequence => Handled_Statement_Sequence =>
...@@ -6351,6 +6364,15 @@ package body Exp_Ch7 is ...@@ -6351,6 +6364,15 @@ package body Exp_Ch7 is
Handled_Statement_Sequence => Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc, Statements => Stmts))); Make_Handled_Sequence_Of_Statements (Loc, Statements => Stmts)));
-- If there are no calls to component initialization, indicate that
-- the procedure is trivial, so prevent calls to it.
if Is_Empty_List (Stmts)
or else Nkind (First (Stmts)) = N_Null_Statement
then
Set_Is_Trivial_Subprogram (Proc_Id);
end if;
return Proc_Id; return Proc_Id;
end Make_Deep_Proc; end Make_Deep_Proc;
...@@ -8180,6 +8202,18 @@ package body Exp_Ch7 is ...@@ -8180,6 +8202,18 @@ package body Exp_Ch7 is
Check_Visibly_Controlled (Initialize_Case, Typ, Proc, Ref); Check_Visibly_Controlled (Initialize_Case, Typ, Proc, Ref);
end if; end if;
-- If initialization procedure for an array of controlled objects is
-- trivial, do not generate a useless call to it.
if (Is_Array_Type (Utyp) and then Is_Trivial_Subprogram (Proc))
or else
(not Comes_From_Source (Proc)
and then Present (Alias (Proc))
and then Is_Trivial_Subprogram (Alias (Proc)))
then
return Make_Null_Statement (Loc);
end if;
-- The object reference may need another conversion depending on the -- The object reference may need another conversion depending on the
-- type of the formal and that of the actual. -- type of the formal and that of the actual.
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 2014-2016, Free Software Foundation, Inc. -- -- Copyright (C) 2014-2017, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -130,8 +130,8 @@ package body GNAT.Formatted_String is ...@@ -130,8 +130,8 @@ package body GNAT.Formatted_String is
begin begin
return Formatted_String' return Formatted_String'
(Finalization.Controlled with (Finalization.Controlled with
D => new Data'(Format'Length, 1, Format, 1, D => new Data'(Format'Length, 1, 1,
Null_Unbounded_String, 0, 0, (0, 0))); Null_Unbounded_String, 0, 0, (0, 0), Format));
end "+"; end "+";
--------- ---------
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2014-2016, Free Software Foundation, Inc. -- -- Copyright (C) 2014-2017, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -287,12 +287,12 @@ private ...@@ -287,12 +287,12 @@ private
type Data (Size : Natural) is record type Data (Size : Natural) is record
Ref_Count : Natural := 1; Ref_Count : Natural := 1;
Format : String (1 .. Size); -- the format string
Index : Positive := 1; -- format index for next value Index : Positive := 1; -- format index for next value
Result : Unbounded_String; -- current value Result : Unbounded_String; -- current value
Current : Natural; -- the current format number Current : Natural; -- the current format number
Stored_Value : Natural := 0; -- number of stored values in Stack Stored_Value : Natural := 0; -- number of stored values in Stack
Stack : I_Vars; Stack : I_Vars;
Format : String (1 .. Size); -- the format string
end record; end record;
type Data_Access is access Data; type Data_Access is access Data;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2014, Free Software Foundation, Inc. -- -- Copyright (C) 2014-2017, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -128,6 +128,12 @@ private ...@@ -128,6 +128,12 @@ private
type Buffer type Buffer
(Size, Size_Pattern, Size_Value : Stream_Element_Offset) is (Size, Size_Pattern, Size_Value : Stream_Element_Offset) is
limited record limited record
Pos_C : Stream_Element_Offset; -- last valid element in Current
Pos_B : Stream_Element_Offset; -- last valid element in Buffer
Next : Buffer_Ref;
-- A link to another rewriter if any
Buffer : Stream_Element_Array (1 .. Size); Buffer : Stream_Element_Array (1 .. Size);
-- Fully prepared/rewritten data waiting to be output -- Fully prepared/rewritten data waiting to be output
...@@ -141,12 +147,6 @@ private ...@@ -141,12 +147,6 @@ private
Value : Stream_Element_Array (1 .. Size_Value); Value : Stream_Element_Array (1 .. Size_Value);
-- The value the pattern is replaced by -- The value the pattern is replaced by
Pos_C : Stream_Element_Offset; -- last valid element in Current
Pos_B : Stream_Element_Offset; -- last valid element in Buffer
Next : Buffer_Ref;
-- A link to another rewriter if any
end record; end record;
end GNAT.Rewrite_Data; end GNAT.Rewrite_Data;
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2009-2016, Free Software Foundation, Inc. -- -- Copyright (C) 2009-2017, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -208,14 +208,14 @@ package GNAT.Secure_Hashes is ...@@ -208,14 +208,14 @@ package GNAT.Secure_Hashes is
-- KL is 0 for a normal hash context, > 0 for HMAC -- KL is 0 for a normal hash context, > 0 for HMAC
type Context (KL : Key_Length := 0) is record type Context (KL : Key_Length := 0) is record
Key : Stream_Element_Array (1 .. KL);
-- HMAC key
H_State : Hash_State.State (0 .. State_Words - 1) := Initial_State; H_State : Hash_State.State (0 .. State_Words - 1) := Initial_State;
-- Function-specific state -- Function-specific state
M_State : Message_State (Block_Length); M_State : Message_State (Block_Length);
-- Function-independent state (block buffer) -- Function-independent state (block buffer)
Key : Stream_Element_Array (1 .. KL);
-- HMAC key
end record; end record;
Initial_Context : constant Context (KL => 0) := (others => <>); Initial_Context : constant Context (KL => 0) := (others => <>);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2001-2016, AdaCore -- -- Copyright (C) 2001-2017, AdaCore --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -1268,9 +1268,9 @@ private ...@@ -1268,9 +1268,9 @@ private
type Service_Entry_Type (Aliases_Length : Natural) is record type Service_Entry_Type (Aliases_Length : Natural) is record
Official : Name_Type; Official : Name_Type;
Aliases : Name_Array (1 .. Aliases_Length);
Port : Port_Type; Port : Port_Type;
Protocol : Name_Type; Protocol : Name_Type;
Aliases : Name_Array (1 .. Aliases_Length);
end record; end record;
type Request_Flag_Type is mod 2 ** 8; type Request_Flag_Type is mod 2 ** 8;
......
...@@ -447,9 +447,6 @@ procedure Gnatbind is ...@@ -447,9 +447,6 @@ procedure Gnatbind is
elsif Argv (2 .. Argv'Last) = "nostdinc" then elsif Argv (2 .. Argv'Last) = "nostdinc" then
Opt.No_Stdinc := True; Opt.No_Stdinc := True;
elsif Argv (2 .. Argv'Last) = "nognarl" then
Opt.No_Libgnarl := True;
-- -static -- -static
elsif Argv (2 .. Argv'Last) = "static" then elsif Argv (2 .. Argv'Last) = "static" then
......
...@@ -1147,10 +1147,6 @@ package Opt is ...@@ -1147,10 +1147,6 @@ package Opt is
-- GNATMAKE, GNATBIND, GNATFIND, GNATXREF -- GNATMAKE, GNATBIND, GNATFIND, GNATXREF
-- Set to True if no default library search dirs added to search list. -- Set to True if no default library search dirs added to search list.
No_Libgnarl : Boolean := False;
-- GNATBIND
-- Set to True if libgnarl is not available in the runtime.
No_Strict_Aliasing : Boolean := False; No_Strict_Aliasing : Boolean := False;
-- GNAT -- GNAT
-- Set True if pragma No_Strict_Aliasing with no parameters encountered. -- Set True if pragma No_Strict_Aliasing with no parameters encountered.
......
...@@ -63,8 +63,8 @@ package body System.File_IO is ...@@ -63,8 +63,8 @@ package body System.File_IO is
type Temp_File_Record is record type Temp_File_Record is record
File : AFCB_Ptr; File : AFCB_Ptr;
Name : String (1 .. max_path_len + 1);
Next : aliased Temp_File_Record_Ptr; Next : aliased Temp_File_Record_Ptr;
Name : String (1 .. max_path_len + 1);
end record; end record;
-- One of these is allocated for each temporary file created -- One of these is allocated for each temporary file created
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1999-2016, AdaCore -- -- Copyright (C) 1999-2017, AdaCore --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -68,9 +68,9 @@ package body System.Regexp is ...@@ -68,9 +68,9 @@ package body System.Regexp is
Num_States : State_Index) is Num_States : State_Index) is
record record
Map : Mapping; Map : Mapping;
Case_Sensitive : Boolean;
States : Regexp_Array (1 .. Num_States, 0 .. Alphabet_Size); States : Regexp_Array (1 .. Num_States, 0 .. Alphabet_Size);
Is_Final : Boolean_Array (1 .. Num_States); Is_Final : Boolean_Array (1 .. Num_States);
Case_Sensitive : Boolean;
end record; end record;
-- Deterministic finite-state machine -- Deterministic finite-state machine
......
...@@ -1450,6 +1450,12 @@ package body Sem_Ch6 is ...@@ -1450,6 +1450,12 @@ package body Sem_Ch6 is
Is_Completion := False; Is_Completion := False;
-- Link the body to the null procedure spec
if Nkind (N) = N_Subprogram_Declaration then
Set_Corresponding_Body (N, Defining_Entity (Null_Body));
end if;
-- Null procedures are always inlined, but generic formal subprograms -- Null procedures are always inlined, but generic formal subprograms
-- which appear as such in the internal instance of formal packages, -- which appear as such in the internal instance of formal packages,
-- need no completion and are not marked Inline. -- need no completion and are not marked Inline.
...@@ -1457,7 +1463,6 @@ package body Sem_Ch6 is ...@@ -1457,7 +1463,6 @@ package body Sem_Ch6 is
if Expander_Active if Expander_Active
and then Nkind (N) /= N_Formal_Concrete_Subprogram_Declaration and then Nkind (N) /= N_Formal_Concrete_Subprogram_Declaration
then then
Set_Corresponding_Body (N, Defining_Entity (Null_Body));
Set_Body_To_Inline (N, Null_Body); Set_Body_To_Inline (N, Null_Body);
Set_Is_Inlined (Designator); Set_Is_Inlined (Designator);
end if; end if;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1998-2014, Free Software Foundation, Inc. -- -- Copyright (C) 1998-2017, Free Software Foundation, Inc. --
-- -- -- --
-- GNAT is free software; you can redistribute it and/or modify it under -- -- 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- -- -- terms of the GNU General Public License as published by the Free Soft- --
...@@ -292,12 +292,11 @@ package Xr_Tabls is ...@@ -292,12 +292,11 @@ package Xr_Tabls is
private private
type Project_File (Src_Dir_Length, Obj_Dir_Length : Natural) is record type Project_File (Src_Dir_Length, Obj_Dir_Length : Natural) is record
Src_Dir : String (1 .. Src_Dir_Length); Src_Dir_Index : Integer;
Src_Dir_Index : Integer;
Obj_Dir : String (1 .. Obj_Dir_Length);
Obj_Dir_Index : Integer; Obj_Dir_Index : Integer;
Last_Obj_Dir_Start : Natural; Last_Obj_Dir_Start : Natural;
Src_Dir : String (1 .. Src_Dir_Length);
Obj_Dir : String (1 .. Obj_Dir_Length);
end record; end record;
type Project_File_Ptr is access all Project_File; type Project_File_Ptr is access all Project_File;
...@@ -364,7 +363,6 @@ private ...@@ -364,7 +363,6 @@ private
type Declaration_Record (Symbol_Length : Natural) is record type Declaration_Record (Symbol_Length : Natural) is record
Key : Cst_String_Access; Key : Cst_String_Access;
Symbol : String (1 .. Symbol_Length);
Decl : Reference; Decl : Reference;
Is_Parameter : Boolean := False; -- True if entity is subprog param Is_Parameter : Boolean := False; -- True if entity is subprog param
Decl_Type : Character; Decl_Type : Character;
...@@ -374,6 +372,7 @@ private ...@@ -374,6 +372,7 @@ private
Match : Boolean := False; Match : Boolean := False;
Par_Symbol : Declaration_Reference := null; Par_Symbol : Declaration_Reference := null;
Next : Declaration_Reference := null; Next : Declaration_Reference := null;
Symbol : String (1 .. Symbol_Length);
end record; end record;
-- The lists of referenced (Body_Ref, Ref_Ref and Modif_Ref) are -- The lists of referenced (Body_Ref, Ref_Ref and Modif_Ref) are
-- kept unsorted until the results needs to be printed. This saves -- kept unsorted until the results needs to be printed. This saves
......
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