Commit 3ec54569 by Pierre-Marie de Rodat

[multiple changes]

2017-11-09  Pascal Obry  <obry@adacore.com>

	* libgnarl/s-taprop__mingw.adb: On Windows, initialize the thead handle
	only for foreign threads.  We initialize the thread handle only if not
	yet initialized. This happens in Enter_Task for foreign threads only.
	But for native threads (Ada tasking) we do want to keep the real
	handle (from Create_Task) to be able to free the corresponding
	resources in Finalize_TCB (CloseHandle).

2017-11-09  Yannick Moy  <moy@adacore.com>

	* sem_attr.adb (Analyze_Attribute): Default initialize P_Type,
	P_Base_Type.
	(Error_Attr_P): Fix name in pragma No_Return.
	(Unexpected_Argument): Add pragma No_Return.
	(Placement_Error): Add pragma No_Return.

2017-11-09  Javier Miranda  <miranda@adacore.com>

	* exp_disp.adb (Elab_Flag_Needed): Elaboration flag not needed when the
	dispatch table is statically built.
	(Make_DT): Declare constant the Interface_Table object associated with
	an statically built dispatch table. For this purpose the Offset_To_Top
	value of each interface is computed using the dummy object.
	* exp_ch3.adb (Build_Init_Procedure): Do not generate code initializing
	the Offset_To_Top field of secondary dispatch tables when the dispatch
	table is statically built.
	(Initialize_Tag): Do not generate calls to Register_Interface_Offset
	when the dispatch table is statically built.
	* doc/gnat_rm/standard_and_implementation_defined_restrictions.rst:
	Document the new GNAT restriction Static_Dispatch_Tables.
	* gnat_rm.texi: Regenerate.

2017-11-09  Hristian Kirtchev  <kirtchev@adacore.com>

	* sem_aggr.adb (Resolve_Delta_Record_Aggregate): Reorder declarations
	to avoid a dormant bug.

2017-11-09  Jerome Lambourg  <lambourg@adacore.com>

	* init.c: Define missing __gnat_alternate_stack for QNX. Set it to 0,
	as such capability is not available on the OS.
	* link.c: Make sure linker options for QNX are correct.
	* libgnarl/s-osinte__qnx.ads: Add some missing bindings to pthread.
	* libgnarl/s-taprop__qnx.adb: New, derived from s-taprop__posix.adb. This brings
	in particular a workaround with locks priority ceiling where a higher
	priority task is allowed to lock a lower ceiling priority lock. This
	also fixes the scheduling of FIFO tasks when the priority of a task is
	lowered.
	* libgnat/system-qnx-aarch64.ads: Fix priority ranges.

2017-11-09  Yannick Moy  <moy@adacore.com>

	* erroutc.adb (Output_Error_Msgs): Justify CodePeer false positive
	message.
	* gnatbind.adb (Scan_Bind_Arg): Simplify test to remove always true
	condition.
	* namet.adb (Copy_One_Character): Add assumption for static analysis,
	as knowledge that Hex(2) is in the range 0..255 is too complex for
	CodePeer.
	(Finalize): Add assumption for static analysis, as the fact that there
	are symbols in the table depends on a global invariant at this point in
	the program.
	* set_targ.adb (Check_Spaces): Justify CodePeer false positive message.
	* stylesw.adb (Save_Style_Check_Options): Rewrite to avoid test always
	true.

From-SVN: r254573
parent 6214b83b
2017-11-09 Pascal Obry <obry@adacore.com>
* libgnarl/s-taprop__mingw.adb: On Windows, initialize the thead handle
only for foreign threads. We initialize the thread handle only if not
yet initialized. This happens in Enter_Task for foreign threads only.
But for native threads (Ada tasking) we do want to keep the real
handle (from Create_Task) to be able to free the corresponding
resources in Finalize_TCB (CloseHandle).
2017-11-09 Yannick Moy <moy@adacore.com>
* sem_attr.adb (Analyze_Attribute): Default initialize P_Type,
P_Base_Type.
(Error_Attr_P): Fix name in pragma No_Return.
(Unexpected_Argument): Add pragma No_Return.
(Placement_Error): Add pragma No_Return.
2017-11-09 Javier Miranda <miranda@adacore.com>
* exp_disp.adb (Elab_Flag_Needed): Elaboration flag not needed when the
dispatch table is statically built.
(Make_DT): Declare constant the Interface_Table object associated with
an statically built dispatch table. For this purpose the Offset_To_Top
value of each interface is computed using the dummy object.
* exp_ch3.adb (Build_Init_Procedure): Do not generate code initializing
the Offset_To_Top field of secondary dispatch tables when the dispatch
table is statically built.
(Initialize_Tag): Do not generate calls to Register_Interface_Offset
when the dispatch table is statically built.
* doc/gnat_rm/standard_and_implementation_defined_restrictions.rst:
Document the new GNAT restriction Static_Dispatch_Tables.
* gnat_rm.texi: Regenerate.
2017-11-09 Hristian Kirtchev <kirtchev@adacore.com>
* sem_aggr.adb (Resolve_Delta_Record_Aggregate): Reorder declarations
to avoid a dormant bug.
2017-11-09 Jerome Lambourg <lambourg@adacore.com>
* init.c: Define missing __gnat_alternate_stack for QNX. Set it to 0,
as such capability is not available on the OS.
* link.c: Make sure linker options for QNX are correct.
* libgnarl/s-osinte__qnx.ads: Add some missing bindings to pthread.
* libgnarl/s-taprop__qnx.adb: New, derived from s-taprop__posix.adb. This brings
in particular a workaround with locks priority ceiling where a higher
priority task is allowed to lock a lower ceiling priority lock. This
also fixes the scheduling of FIFO tasks when the priority of a task is
lowered.
* libgnat/system-qnx-aarch64.ads: Fix priority ranges.
2017-11-09 Yannick Moy <moy@adacore.com>
* erroutc.adb (Output_Error_Msgs): Justify CodePeer false positive
message.
* gnatbind.adb (Scan_Bind_Arg): Simplify test to remove always true
condition.
* namet.adb (Copy_One_Character): Add assumption for static analysis,
as knowledge that Hex(2) is in the range 0..255 is too complex for
CodePeer.
(Finalize): Add assumption for static analysis, as the fact that there
are symbols in the table depends on a global invariant at this point in
the program.
* set_targ.adb (Check_Spaces): Justify CodePeer false positive message.
* stylesw.adb (Save_Style_Check_Options): Rewrite to avoid test always
true.
2017-11-09 Javier Miranda <miranda@adacore.com>
* libgnat/s-rident.ads (Static_Dispatch_Tables): New restriction name.
......
......@@ -988,6 +988,13 @@ appear, and that no wide or wide wide string or character literals
appear in the program (that is literals representing characters not in
type ``Character``).
Static_Dispatch_Tables
----------------------
.. index:: Static_Dispatch_Tables
[GNAT] This restriction ensures at compile time that all the artifacts
associated with dispatch tables can be placed in read-only memory.
SPARK_05
--------
.. index:: SPARK_05
......
......@@ -512,6 +512,9 @@ package body Erroutc is
-- so now we output a tab to match up with the text.
if Src (P) = ASCII.HT then
pragma Annotate
(CodePeer, False_Positive, "validity check",
"Src(P) is initialized at this point");
Write_Char (ASCII.HT);
P := P + 1;
......
......@@ -2544,6 +2544,7 @@ package body Exp_Ch3 is
and then Has_Interfaces (Rec_Type)
then
declare
Elab_List : List_Id := New_List;
Elab_Sec_DT_Stmts_List : constant List_Id := New_List;
begin
......@@ -2555,24 +2556,30 @@ package body Exp_Ch3 is
Fixed_Comps => True,
Variable_Comps => False);
Append_To (Elab_Sec_DT_Stmts_List,
Make_Assignment_Statement (Loc,
Name =>
New_Occurrence_Of
(Access_Disp_Table_Elab_Flag (Rec_Type), Loc),
Expression =>
New_Occurrence_Of (Standard_False, Loc)));
Prepend_List_To (Body_Stmts, New_List (
Elab_List := New_List (
Make_If_Statement (Loc,
Condition => New_Occurrence_Of (Set_Tag, Loc),
Then_Statements => Init_Tags_List),
Then_Statements => Init_Tags_List));
if Elab_Flag_Needed (Rec_Type) then
Append_To (Elab_Sec_DT_Stmts_List,
Make_Assignment_Statement (Loc,
Name =>
New_Occurrence_Of
(Access_Disp_Table_Elab_Flag (Rec_Type),
Loc),
Expression =>
New_Occurrence_Of (Standard_False, Loc)));
Append_To (Elab_List,
Make_If_Statement (Loc,
Condition =>
New_Occurrence_Of
(Access_Disp_Table_Elab_Flag (Rec_Type), Loc),
Then_Statements => Elab_Sec_DT_Stmts_List));
end if;
Make_If_Statement (Loc,
Condition =>
New_Occurrence_Of
(Access_Disp_Table_Elab_Flag (Rec_Type), Loc),
Then_Statements => Elab_Sec_DT_Stmts_List)));
Prepend_List_To (Body_Stmts, Elab_List);
end;
else
Prepend_To (Body_Stmts,
......@@ -8588,7 +8595,9 @@ package body Exp_Ch3 is
-- Offset_Value => n,
-- Offset_Func => null);
if RTE_Available (RE_Register_Interface_Offset) then
if not Building_Static_Secondary_DT (Typ)
and then RTE_Available (RE_Register_Interface_Offset)
then
Append_To (Stmts_List,
Make_Procedure_Call_Statement (Loc,
Name =>
......
......@@ -677,7 +677,8 @@ package body Exp_Disp is
begin
return Ada_Version >= Ada_2005
and then not Is_Interface (Typ)
and then Has_Interfaces (Typ);
and then Has_Interfaces (Typ)
and then not Building_Static_DT (Typ);
end Elab_Flag_Needed;
-----------------------------
......@@ -5513,11 +5514,23 @@ package body Exp_Disp is
else
declare
TSD_Ifaces_List : constant List_Id := New_List;
Elmt : Elmt_Id;
Sec_DT_Tag : Node_Id;
TSD_Ifaces_List : constant List_Id := New_List;
Elmt : Elmt_Id;
Ifaces_List : Elist_Id;
Ifaces_Comp_List : Elist_Id;
Ifaces_Tag_List : Elist_Id;
Offset_To_Top : Node_Id;
Sec_DT_Tag : Node_Id;
begin
-- Collect interfaces information if we need to compute the
-- offset to the top using the dummy object.
if Present (Dummy_Object) then
Collect_Interfaces_Info (Typ,
Ifaces_List, Ifaces_Comp_List, Ifaces_Tag_List);
end if;
AI := First_Elmt (Typ_Ifaces);
while Present (AI) loop
if Is_Ancestor (Node (AI), Typ, Use_Full_View => True) then
......@@ -5552,6 +5565,46 @@ package body Exp_Disp is
Loc);
end if;
-- For static dispatch tables compute Offset_To_Top using
-- the dummy object.
if Present (Dummy_Object) then
declare
Iface : constant Node_Id := Node (AI);
Iface_Comp : Node_Id := Empty;
Iface_Comp_Elmt : Elmt_Id;
Iface_Elmt : Elmt_Id;
begin
Iface_Elmt := First_Elmt (Ifaces_List);
Iface_Comp_Elmt := First_Elmt (Ifaces_Comp_List);
while Present (Iface_Elmt) loop
if Node (Iface_Elmt) = Iface then
Iface_Comp := Node (Iface_Comp_Elmt);
exit;
end if;
Next_Elmt (Iface_Elmt);
Next_Elmt (Iface_Comp_Elmt);
end loop;
pragma Assert (Present (Iface_Comp));
Offset_To_Top :=
Make_Op_Minus (Loc,
Make_Attribute_Reference (Loc,
Prefix =>
Make_Selected_Component (Loc,
Prefix =>
New_Occurrence_Of (Dummy_Object, Loc),
Selector_Name =>
New_Occurrence_Of (Iface_Comp, Loc)),
Attribute_Name => Name_Position));
end;
else
Offset_To_Top := Make_Integer_Literal (Loc, 0);
end if;
Append_To (TSD_Ifaces_List,
Make_Aggregate (Loc,
Expressions => New_List (
......@@ -5569,7 +5622,7 @@ package body Exp_Disp is
-- Offset_To_Top_Value
Make_Integer_Literal (Loc, 0),
Offset_To_Top,
-- Offset_To_Top_Func
......@@ -5589,17 +5642,15 @@ package body Exp_Disp is
Set_Is_Statically_Allocated (ITable,
Is_Library_Level_Tagged_Type (Typ));
-- The table of interfaces is not constant; its slots are
-- filled at run time by the IP routine using attribute
-- 'Position to know the location of the tag components
-- (and this attribute cannot be safely used before the
-- object is initialized).
-- The table of interfaces is constant if we are building a
-- static dispatch table; otherwise is not constant because
-- its slots are filled at run time by the IP routine.
Append_To (Result,
Make_Object_Declaration (Loc,
Defining_Identifier => ITable,
Aliased_Present => True,
Constant_Present => False,
Constant_Present => Present (Dummy_Object),
Object_Definition =>
Make_Subtype_Indication (Loc,
Subtype_Mark =>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -330,9 +330,7 @@ procedure Gnatbind is
then
Output_File_Name_Seen := True;
if Argv'Length = 0
or else (Argv'Length >= 1 and then Argv (1) = '-')
then
if Argv'Length = 0 or else Argv (1) = '-' then
Fail ("output File_Name missing after -o");
else
......
......@@ -2568,6 +2568,10 @@ __gnat_error_handler (int sig, siginfo_t *si, void *ucontext)
(__sigtramphandler_t *)&__gnat_map_signal);
}
/* This must be in keeping with System.OS_Interface.Alternate_Stack_Size. */
/* sigaltstack is currently not supported by QNX7 */
char __gnat_alternate_stack[0];
void
__gnat_install_handler (void)
{
......
......@@ -796,7 +796,17 @@ package body System.Task_Primitives.Operations is
raise Invalid_CPU_Number;
end if;
Self_ID.Common.LL.Thread := GetCurrentThread;
-- Initialize the thread here only if not set. This is done for a
-- foreign task but is not needed when a real thread-id is already
-- set in Create_Task. Note that we do want to keep the real thread-id
-- as it is the only way to free the associated resource. Another way
-- to say this is that a pseudo thread-id from a foreign thread won't
-- allow for freeing resources.
if Self_ID.Common.LL.Thread = Null_Thread_Id then
Self_ID.Common.LL.Thread := GetCurrentThread;
end if;
Self_ID.Common.LL.Thread_Id := GetCurrentThreadId;
Get_Stack_Bounds
......
......@@ -95,20 +95,22 @@ package System is
-- Priority-related Declarations (RM D.1)
-- System priority is Ada priority + 1, so lies in the range 1 .. 63.
--
-- If the scheduling policy is SCHED_FIFO or SCHED_RR the runtime makes use
-- of the entire range provided by the system.
--
-- If the scheduling policy is SCHED_OTHER the only valid system priority
-- is 1 and other values are simply ignored.
Max_Priority : constant Positive := 62;
Max_Interrupt_Priority : constant Positive := 63;
Max_Priority : constant Positive := 61;
Max_Interrupt_Priority : constant Positive := 62;
subtype Any_Priority is Integer range 0 .. 63;
subtype Priority is Any_Priority range 0 .. 62;
subtype Interrupt_Priority is Any_Priority range 63 .. 63;
subtype Any_Priority is Integer range 0 .. 62;
subtype Priority is Any_Priority range 0 .. 61;
subtype Interrupt_Priority is Any_Priority range 62 .. 62;
Default_Priority : constant Priority := 31;
Default_Priority : constant Priority := 30;
private
......
......@@ -105,6 +105,7 @@ const char *__gnat_default_libgcc_subdir = "lib";
#elif defined (__FreeBSD__) || defined (__DragonFly__) \
|| defined (__NetBSD__) || defined (__OpenBSD__)
|| defined (__QNX__)
const char *__gnat_object_file_option = "-Wl,@";
const char *__gnat_run_path_option = "-Wl,-rpath,";
char __gnat_shared_libgnat_default = STATIC;
......
......@@ -258,7 +258,13 @@ package body Namet is
-- simply use their normal representation.
else
Insert_Character (Character'Val (Hex (2)));
declare
W2 : constant Word := Hex (2);
begin
pragma Assume (W2 <= 255);
-- Add assumption to facilitate static analysis
Insert_Character (Character'Val (W2));
end;
end if;
-- WW (wide wide character insertion)
......@@ -753,6 +759,9 @@ package body Namet is
Write_Eol;
Write_Str ("Average number of probes for lookup = ");
pragma Assume (Nsyms /= 0);
-- Add assumption to facilitate static analysis. Here Nsyms cannot be
-- zero because many symbols are added to the table by default.
Probes := Probes / Nsyms;
Write_Int (Probes / 200);
Write_Char ('.');
......
......@@ -2877,7 +2877,14 @@ package body Sem_Aggr is
-- Resolve_Delta_Record_Aggregate --
------------------------------------
procedure Resolve_Delta_Record_Aggregate (N : Node_Id; Typ : Entity_Id) is
procedure Resolve_Delta_Record_Aggregate (N : Node_Id; Typ : Entity_Id) is
-- Variables used to verify that discriminant-dependent components
-- appear in the same variant.
Comp_Ref : Entity_Id;
Variant : Node_Id;
procedure Check_Variant (Id : Entity_Id);
-- If a given component of the delta aggregate appears in a variant
-- part, verify that it is within the same variant as that of previous
......@@ -2900,17 +2907,13 @@ package body Sem_Aggr is
procedure Check_Variant (Id : Entity_Id) is
Comp : Entity_Id;
Comp_Ref : Entity_Id;
Comp_Variant : Node_Id;
Variant : Node_Id;
begin
if not Has_Discriminants (Typ) then
return;
end if;
Variant := Empty;
Comp := First_Entity (Typ);
while Present (Comp) loop
exit when Chars (Comp) = Chars (Id);
......@@ -3027,6 +3030,8 @@ package body Sem_Aggr is
-- Start of processing for Resolve_Delta_Record_Aggregate
begin
Variant := Empty;
Assoc := First (Deltas);
while Present (Assoc) loop
Choice := First (Choice_List (Assoc));
......
......@@ -231,10 +231,10 @@ package body Sem_Attr is
E1 : Node_Id;
E2 : Node_Id;
P_Type : Entity_Id;
P_Type : Entity_Id := Empty;
-- Type of prefix after analysis
P_Base_Type : Entity_Id;
P_Base_Type : Entity_Id := Empty;
-- Base type of prefix after analysis
-----------------------
......@@ -419,7 +419,7 @@ package body Sem_Attr is
-- required error messages.
procedure Error_Attr_P (Msg : String);
pragma No_Return (Error_Attr);
pragma No_Return (Error_Attr_P);
-- Like Error_Attr, but error is posted at the start of the prefix
procedure Legal_Formal_Attribute;
......@@ -446,7 +446,9 @@ package body Sem_Attr is
-- node in the aspect case).
procedure Unexpected_Argument (En : Node_Id);
-- Signal unexpected attribute argument (En is the argument)
pragma No_Return (Unexpected_Argument);
-- Signal unexpected attribute argument (En is the argument), and then
-- raises Bad_Attribute to avoid any further semantic processing.
procedure Validate_Non_Static_Attribute_Function_Call;
-- Called when processing an attribute that is a function call to a
......@@ -1108,8 +1110,10 @@ package body Sem_Attr is
-- node Nod is within enclosing node Encl_Nod.
procedure Placement_Error;
pragma No_Return (Placement_Error);
-- Emit a general error when the attributes does not appear in a
-- postcondition-like aspect or pragma.
-- postcondition-like aspect or pragma, and then raises Bad_Attribute
-- to avoid any further semantic processing.
------------------------------
-- Check_Placement_In_Check --
......
......@@ -604,6 +604,10 @@ package body Set_Targ is
procedure Check_Spaces is
begin
if N > Buflen or else Buffer (N) /= ' ' then
pragma Annotate
(CodePeer, False_Positive, "condition predetermined",
"N may be less than Buflen when calling Check_Spaces");
FailN ("missing space for");
end if;
......
......@@ -161,7 +161,8 @@ package body Stylesw is
if Style_Check_Comments then
if Style_Check_Comments_Spacing = 2 then
Add ('c', Style_Check_Comments);
elsif Style_Check_Comments_Spacing = 1 then
else
pragma Assert (Style_Check_Comments_Spacing = 1);
Add ('C', Style_Check_Comments);
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