Commit 8e983d80 by Arnaud Charlet

[multiple changes]

2012-10-01  Thomas Quinot  <quinot@adacore.com>

	* gnatcmd.adb, make.adb (Scan_Make_Arg, Inspect_Switches): Recognize
	and reject an invalid parameter passed to -vP.

2012-10-01  Yannick Moy  <moy@adacore.com>

	* sem_warn.adb (Check_Infinite_Loop_Warning/Test_Ref): Improve
	the detection of modifications to the loop variable by noting
	that, if the type of variable is elementary and the condition
	does not contain a function call, then the condition cannot be
	modified by side-effects from a procedure call.

2012-10-01  Robert Dewar  <dewar@adacore.com>

	* checks.adb: Add comments.

2012-10-01  Javier Miranda  <miranda@adacore.com>

	* exp_ch3.adb (Expand_N_Object_Declaration): Improve condition catching
	never-ending recursion. The previous condition erroneously disabled
	silently the expansion of the class-wide interface object
	initialization in cases not involving the recursion.

From-SVN: r191892
parent 7246b890
2012-10-01 Thomas Quinot <quinot@adacore.com> 2012-10-01 Thomas Quinot <quinot@adacore.com>
* gnatcmd.adb, make.adb (Scan_Make_Arg, Inspect_Switches): Recognize
and reject an invalid parameter passed to -vP.
2012-10-01 Yannick Moy <moy@adacore.com>
* sem_warn.adb (Check_Infinite_Loop_Warning/Test_Ref): Improve
the detection of modifications to the loop variable by noting
that, if the type of variable is elementary and the condition
does not contain a function call, then the condition cannot be
modified by side-effects from a procedure call.
2012-10-01 Robert Dewar <dewar@adacore.com>
* checks.adb: Add comments.
2012-10-01 Javier Miranda <miranda@adacore.com>
* exp_ch3.adb (Expand_N_Object_Declaration): Improve condition catching
never-ending recursion. The previous condition erroneously disabled
silently the expansion of the class-wide interface object
initialization in cases not involving the recursion.
2012-10-01 Thomas Quinot <quinot@adacore.com>
* make.adb: Minor documentation fix: error messages are sent to * make.adb: Minor documentation fix: error messages are sent to
stderr, not stdout. stderr, not stdout.
......
...@@ -1791,6 +1791,8 @@ package body Checks is ...@@ -1791,6 +1791,8 @@ package body Checks is
-- Do not generate the checks in Ada 83, 95 or 05 mode because they -- Do not generate the checks in Ada 83, 95 or 05 mode because they
-- require an Ada 2012 construct. -- require an Ada 2012 construct.
-- Why??? these pragmas and attributes are available in all ada modes
if Ada_Version_Explicit < Ada_2012 then if Ada_Version_Explicit < Ada_2012 then
return; return;
end if; end if;
...@@ -1932,9 +1934,11 @@ package body Checks is ...@@ -1932,9 +1934,11 @@ package body Checks is
-- Extract the subprogram specification and declaration nodes -- Extract the subprogram specification and declaration nodes
Subp_Spec := Parent (Subp); Subp_Spec := Parent (Subp);
if Nkind (Subp_Spec) = N_Defining_Program_Unit_Name then if Nkind (Subp_Spec) = N_Defining_Program_Unit_Name then
Subp_Spec := Parent (Subp_Spec); Subp_Spec := Parent (Subp_Spec);
end if; end if;
Subp_Decl := Parent (Subp_Spec); Subp_Decl := Parent (Subp_Spec);
-- Do not generate checks in Ada 83 or 95 because the pragmas involved -- Do not generate checks in Ada 83 or 95 because the pragmas involved
...@@ -1961,6 +1965,9 @@ package body Checks is ...@@ -1961,6 +1965,9 @@ package body Checks is
-- through the its contract and recover the pre and post conditions (if -- through the its contract and recover the pre and post conditions (if
-- available). -- available).
-- So what??? you can have multiple such pragmas, this is unnecessary
-- complexity being added for no purpose???
if Present (Contract (Subp)) then if Present (Contract (Subp)) then
declare declare
Nam : Name_Id; Nam : Name_Id;
...@@ -2080,6 +2087,9 @@ package body Checks is ...@@ -2080,6 +2087,9 @@ package body Checks is
-- Do not process subprograms where pre and post conditions do not make -- Do not process subprograms where pre and post conditions do not make
-- sense. -- sense.
-- More detail here of why these specific conditions are needed???
-- And remember to document them ???
if not Comes_From_Source (Subp) if not Comes_From_Source (Subp)
or else Is_Imported (Subp) or else Is_Imported (Subp)
or else Is_Intrinsic_Subprogram (Subp) or else Is_Intrinsic_Subprogram (Subp)
...@@ -2127,6 +2137,7 @@ package body Checks is ...@@ -2127,6 +2137,7 @@ package body Checks is
procedure Apply_Predicate_Check (N : Node_Id; Typ : Entity_Id) is procedure Apply_Predicate_Check (N : Node_Id; Typ : Entity_Id) is
S : Entity_Id; S : Entity_Id;
begin begin
if Present (Predicate_Function (Typ)) then if Present (Predicate_Function (Typ)) then
...@@ -2134,17 +2145,12 @@ package body Checks is ...@@ -2134,17 +2145,12 @@ package body Checks is
-- subprograms, such as TSS functions. -- subprograms, such as TSS functions.
S := Current_Scope; S := Current_Scope;
while Present (S) while Present (S) and then not Is_Subprogram (S) loop
and then not Is_Subprogram (S)
loop
S := Scope (S); S := Scope (S);
end loop; end loop;
if Present (S) if Present (S) and then Get_TSS_Name (S) /= TSS_Null then
and then Get_TSS_Name (S) /= TSS_Null
then
return; return;
else else
Insert_Action (N, Insert_Action (N,
Make_Predicate_Check (Typ, Duplicate_Subexpr (N))); Make_Predicate_Check (Typ, Duplicate_Subexpr (N)));
......
...@@ -4910,8 +4910,15 @@ package body Exp_Ch3 is ...@@ -4910,8 +4910,15 @@ package body Exp_Ch3 is
-- Expr's type, both types share the same dispatch table and there is -- Expr's type, both types share the same dispatch table and there is
-- no need to displace the pointer. -- no need to displace the pointer.
elsif Comes_From_Source (N) elsif Is_Interface (Typ)
and then Is_Interface (Typ)
-- Avoid never-ending recursion because if Equivalent_Type is set
-- then we've done it already and must not do it again!
and then not
(Nkind (Object_Definition (N)) = N_Identifier
and then
Present (Equivalent_Type (Entity (Object_Definition (N)))))
then then
pragma Assert (Is_Class_Wide_Type (Typ)); pragma Assert (Is_Class_Wide_Type (Typ));
......
...@@ -1769,19 +1769,27 @@ begin ...@@ -1769,19 +1769,27 @@ begin
-- -vPx Specify verbosity while parsing project files -- -vPx Specify verbosity while parsing project files
elsif Argv'Length = 4 elsif Argv (Argv'First + 1 .. Argv'First + 2) = "vP" then
and then Argv (Argv'First + 1 .. Argv'First + 2) = "vP" if Argv'Length = 4
then and then Argv (Argv'Last) in '0' .. '2'
case Argv (Argv'Last) is then
when '0' => case Argv (Argv'Last) is
Current_Verbosity := Prj.Default; when '0' =>
when '1' => Current_Verbosity := Prj.Default;
Current_Verbosity := Prj.Medium; when '1' =>
when '2' => Current_Verbosity := Prj.Medium;
Current_Verbosity := Prj.High; when '2' =>
when others => Current_Verbosity := Prj.High;
Fail ("Invalid switch: " & Argv.all); when others =>
end case;
-- Cannot happen
raise Program_Error;
end case;
else
Fail ("invalid verbosity level: "
& Argv (Argv'First + 3 .. Argv'Last));
end if;
Remove_Switch (Arg_Num); Remove_Switch (Arg_Num);
......
...@@ -7825,11 +7825,12 @@ package body Make is ...@@ -7825,11 +7825,12 @@ package body Make is
-- -vPx (verbosity of the parsing of the project files) -- -vPx (verbosity of the parsing of the project files)
elsif Argv'Last = 4 elsif Argv (2 .. 3) = "vP" then
and then Argv (2 .. 3) = "vP" if Argv'Last /= 4 or else Argv (4) not in '0' .. '2' then
and then Argv (4) in '0' .. '2' Make_Failed
then ("invalid verbosity level " & Argv (4 .. Argv'Last));
if And_Save then
elsif And_Save then
case Argv (4) is case Argv (4) is
when '0' => when '0' =>
Current_Verbosity := Prj.Default; Current_Verbosity := Prj.Default;
......
...@@ -472,32 +472,41 @@ package body Sem_Warn is ...@@ -472,32 +472,41 @@ package body Sem_Warn is
return Abandon; return Abandon;
end if; end if;
-- If we appear in the context of a procedure call, then also -- If the condition contains a function call, we consider it may
-- abandon, since there may be issues of non-visible side -- be modified by side-effects from a procedure call. Otherwise,
-- effects going on in the call. -- we consider the condition may not be modified, although that
-- might happen if Variable is itself a by-reference parameter,
-- and the procedure called modifies the global object referred to
-- by Variable, but we actually prefer to issue a warning in this
-- odd case. Note that the case where the procedure called has
-- visibility over Variable is treated in another case below.
if Function_Call_Found then
declare
P : Node_Id;
declare begin
P : Node_Id; P := N;
loop
P := Parent (P);
exit when P = Loop_Statement;
begin -- Abandon if at procedure call, or something strange is
P := N; -- going on (perhaps a node with no parent that should
loop -- have one but does not?) As always, for a warning we
P := Parent (P); -- prefer to just abandon the warning than get into the
exit when P = Loop_Statement; -- business of complaining about the tree structure here!
-- Abandon if at procedure call, or something strange is if No (P)
-- going on (perhaps a node with no parent that should or else Nkind (P) = N_Procedure_Call_Statement
-- have one but does not?) As always, for a warning we then
-- prefer to just abandon the warning than get into the return Abandon;
-- business of complaining about the tree structure here! end if;
end loop;
if No (P) or else Nkind (P) = N_Procedure_Call_Statement then end;
return Abandon; end if;
end if;
end loop;
end;
-- Reference to variable renaming variable in question -- Reference to variable renaming variable in question
elsif Is_Entity_Name (N) elsif Is_Entity_Name (N)
and then Present (Entity (N)) and then Present (Entity (N))
...@@ -509,7 +518,7 @@ package body Sem_Warn is ...@@ -509,7 +518,7 @@ package body Sem_Warn is
then then
return Abandon; return Abandon;
-- Call to subprogram -- Call to subprogram
elsif Nkind (N) in N_Subprogram_Call then elsif Nkind (N) in N_Subprogram_Call then
......
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