Commit 7c4b480f by Arnaud Charlet

[multiple changes]

2010-06-23  Thomas Quinot  <quinot@adacore.com>

	* sem_util.adb, sem_util.ads: Minor reformatting.

2010-06-23  Vincent Celier  <celier@adacore.com>

	* prj.ads (Gprclean_Flags.Missing_Source_Files): Set to Error to keep
	the previous behavior of gprclean when there are missing files.

2010-06-23  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch12.adb (Load_Body_Of_Generic): In CodePeer mode, a missing
	generic body is not a fatal error.
	(Mark_Context): Handle properly names of child units.
	* sem.adb (Walk_Library_Items.Do_Action): Remove assertion on
	instantiations.

2010-06-23  Vincent Celier  <celier@adacore.com>

	* ali.adb (Scan_ALI): When ignoring R lines, do not skip the next
	non-empty line.

2010-06-23  Bob Duff  <duff@adacore.com>

	* g-pehage.ads, g-pehage.adb: Switch default optimization mode to
	Memory_Space, because CPU_Time doesn't seem to provide any significant
	speed advantage in practice. Cleanup: Get rid of constant
	Default_Optimization; doesn't seem to add anything. Use case
	statements instead of if statements; seems cleaner.

From-SVN: r161259
parent bb511fbd
2010-06-23 Thomas Quinot <quinot@adacore.com>
* sem_util.adb, sem_util.ads: Minor reformatting.
2010-06-23 Vincent Celier <celier@adacore.com>
* prj.ads (Gprclean_Flags.Missing_Source_Files): Set to Error to keep
the previous behavior of gprclean when there are missing files.
2010-06-23 Ed Schonberg <schonberg@adacore.com>
* sem_ch12.adb (Load_Body_Of_Generic): In CodePeer mode, a missing
generic body is not a fatal error.
(Mark_Context): Handle properly names of child units.
* sem.adb (Walk_Library_Items.Do_Action): Remove assertion on
instantiations.
2010-06-23 Vincent Celier <celier@adacore.com>
* ali.adb (Scan_ALI): When ignoring R lines, do not skip the next
non-empty line.
2010-06-23 Bob Duff <duff@adacore.com>
* g-pehage.ads, g-pehage.adb: Switch default optimization mode to
Memory_Space, because CPU_Time doesn't seem to provide any significant
speed advantage in practice. Cleanup: Get rid of constant
Default_Optimization; doesn't seem to add anything. Use case
statements instead of if statements; seems cleaner.
2010-06-23 Olivier Hainque <hainque@adacore.com> 2010-06-23 Olivier Hainque <hainque@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_entity) <case E_Procedure>: Use * gcc-interface/decl.c (gnat_to_gnu_entity) <case E_Procedure>: Use
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1992-2009, Free Software Foundation, Inc. -- -- Copyright (C) 1992-2010, 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- --
...@@ -1295,9 +1295,9 @@ package body ALI is ...@@ -1295,9 +1295,9 @@ package body ALI is
else else
Skip_Space; Skip_Space;
No_Deps.Append ((Id, Get_Name)); No_Deps.Append ((Id, Get_Name));
Skip_Eol;
end if; end if;
Skip_Eol;
C := Getc; C := Getc;
end loop; end loop;
......
...@@ -1176,7 +1176,7 @@ package body GNAT.Perfect_Hash_Generators is ...@@ -1176,7 +1176,7 @@ package body GNAT.Perfect_Hash_Generators is
procedure Initialize procedure Initialize
(Seed : Natural; (Seed : Natural;
K_To_V : Float := Default_K_To_V; K_To_V : Float := Default_K_To_V;
Optim : Optimization := CPU_Time; Optim : Optimization := Memory_Space;
Tries : Positive := Default_Tries) Tries : Positive := Default_Tries)
is is
begin begin
...@@ -1596,39 +1596,41 @@ package body GNAT.Perfect_Hash_Generators is ...@@ -1596,39 +1596,41 @@ package body GNAT.Perfect_Hash_Generators is
New_Line (File); New_Line (File);
if Opt = CPU_Time then case Opt is
Put_Int_Matrix when CPU_Time =>
(File, Put_Int_Matrix
Array_Img ("T1", Type_Img (NV), (File,
Range_Img (0, T1_Len - 1), Array_Img ("T1", Type_Img (NV),
Range_Img (0, T2_Len - 1, Type_Img (256))), Range_Img (0, T1_Len - 1),
T1, T1_Len, T2_Len); Range_Img (0, T2_Len - 1, Type_Img (256))),
T1, T1_Len, T2_Len);
else
Put_Int_Matrix when Memory_Space =>
(File, Put_Int_Matrix
Array_Img ("T1", Type_Img (NV), (File,
Range_Img (0, T1_Len - 1)), Array_Img ("T1", Type_Img (NV),
T1, T1_Len, 0); Range_Img (0, T1_Len - 1)),
end if; T1, T1_Len, 0);
end case;
New_Line (File); New_Line (File);
if Opt = CPU_Time then case Opt is
Put_Int_Matrix when CPU_Time =>
(File, Put_Int_Matrix
Array_Img ("T2", Type_Img (NV), (File,
Range_Img (0, T1_Len - 1), Array_Img ("T2", Type_Img (NV),
Range_Img (0, T2_Len - 1, Type_Img (256))), Range_Img (0, T1_Len - 1),
T2, T1_Len, T2_Len); Range_Img (0, T2_Len - 1, Type_Img (256))),
T2, T1_Len, T2_Len);
else
Put_Int_Matrix when Memory_Space =>
(File, Put_Int_Matrix
Array_Img ("T2", Type_Img (NV), (File,
Range_Img (0, T1_Len - 1)), Array_Img ("T2", Type_Img (NV),
T2, T1_Len, 0); Range_Img (0, T1_Len - 1)),
end if; T2, T1_Len, 0);
end case;
New_Line (File); New_Line (File);
...@@ -1650,11 +1652,12 @@ package body GNAT.Perfect_Hash_Generators is ...@@ -1650,11 +1652,12 @@ package body GNAT.Perfect_Hash_Generators is
Put (File, " J : "); Put (File, " J : ");
if Opt = CPU_Time then case Opt is
Put (File, Type_Img (256)); when CPU_Time =>
else Put (File, Type_Img (256));
Put (File, "Natural"); when Memory_Space =>
end if; Put (File, "Natural");
end case;
Put (File, ";"); Put (File, ";");
New_Line (File); New_Line (File);
...@@ -1667,11 +1670,12 @@ package body GNAT.Perfect_Hash_Generators is ...@@ -1667,11 +1670,12 @@ package body GNAT.Perfect_Hash_Generators is
New_Line (File); New_Line (File);
Put (File, " J := "); Put (File, " J := ");
if Opt = CPU_Time then case Opt is
Put (File, "C"); when CPU_Time =>
else Put (File, "C");
Put (File, "Character'Pos"); when Memory_Space =>
end if; Put (File, "Character'Pos");
end case;
Put (File, " (S (P (K) + F));"); Put (File, " (S (P (K) + F));");
New_Line (File); New_Line (File);
...@@ -2490,20 +2494,21 @@ package body GNAT.Perfect_Hash_Generators is ...@@ -2490,20 +2494,21 @@ package body GNAT.Perfect_Hash_Generators is
R : Natural; R : Natural;
begin begin
if Opt = CPU_Time then case Opt is
for J in 0 .. T1_Len - 1 loop when CPU_Time =>
exit when Word (J + 1) = ASCII.NUL; for J in 0 .. T1_Len - 1 loop
R := Get_Table (Table, J, Get_Used_Char (Word (J + 1))); exit when Word (J + 1) = ASCII.NUL;
S := (S + R) mod NV; R := Get_Table (Table, J, Get_Used_Char (Word (J + 1)));
end loop; S := (S + R) mod NV;
end loop;
else when Memory_Space =>
for J in 0 .. T1_Len - 1 loop for J in 0 .. T1_Len - 1 loop
exit when Word (J + 1) = ASCII.NUL; exit when Word (J + 1) = ASCII.NUL;
R := Get_Table (Table, J, 0); R := Get_Table (Table, J, 0);
S := (S + R * Character'Pos (Word (J + 1))) mod NV; S := (S + R * Character'Pos (Word (J + 1))) mod NV;
end loop; end loop;
end if; end case;
return S; return S;
end Sum; end Sum;
......
...@@ -86,8 +86,9 @@ package GNAT.Perfect_Hash_Generators is ...@@ -86,8 +86,9 @@ package GNAT.Perfect_Hash_Generators is
-- number of tries. -- number of tries.
type Optimization is (Memory_Space, CPU_Time); type Optimization is (Memory_Space, CPU_Time);
Default_Optimization : constant Optimization := CPU_Time; -- Optimize either the memory space or the execution time. Note: in
-- Optimize either the memory space or the execution time -- practice, the optimization mode has little effect on speed. The tables
-- are somewhat smaller with Memory_Space.
Verbose : Boolean := False; Verbose : Boolean := False;
-- Output the status of the algorithm. For instance, the tables, the random -- Output the status of the algorithm. For instance, the tables, the random
...@@ -97,7 +98,7 @@ package GNAT.Perfect_Hash_Generators is ...@@ -97,7 +98,7 @@ package GNAT.Perfect_Hash_Generators is
procedure Initialize procedure Initialize
(Seed : Natural; (Seed : Natural;
K_To_V : Float := Default_K_To_V; K_To_V : Float := Default_K_To_V;
Optim : Optimization := CPU_Time; Optim : Optimization := Memory_Space;
Tries : Positive := Default_Tries); Tries : Positive := Default_Tries);
-- Initialize the generator and its internal structures. Set the ratio of -- Initialize the generator and its internal structures. Set the ratio of
-- vertices over keys in the random graphs. This value has to be greater -- vertices over keys in the random graphs. This value has to be greater
......
...@@ -1630,7 +1630,7 @@ private ...@@ -1630,7 +1630,7 @@ private
Error_On_Unknown_Language => True, Error_On_Unknown_Language => True,
Require_Obj_Dirs => Warning, Require_Obj_Dirs => Warning,
Allow_Invalid_External => Error, Allow_Invalid_External => Error,
Missing_Source_Files => Warning); Missing_Source_Files => Error);
Gnatmake_Flags : constant Processing_Flags := Gnatmake_Flags : constant Processing_Flags :=
(Report_Error => null, (Report_Error => null,
......
...@@ -1589,7 +1589,7 @@ package body Sem is ...@@ -1589,7 +1589,7 @@ package body Sem is
null; null;
when N_Subprogram_Body => when N_Subprogram_Body =>
-- A subprogram body must be the main unit -- A subprogram body must be the main unit
...@@ -1597,14 +1597,17 @@ package body Sem is ...@@ -1597,14 +1597,17 @@ package body Sem is
or else CU = Cunit (Main_Unit)); or else CU = Cunit (Main_Unit));
null; null;
-- All other cases cannot happen
when N_Function_Instantiation | when N_Function_Instantiation |
N_Procedure_Instantiation | N_Procedure_Instantiation |
N_Package_Instantiation => N_Package_Instantiation =>
pragma Assert (False, "instantiation");
-- Can only happen if some generic body (needed for gnat2scil
-- traversal, but not by GNAT) is not available, ignore.
null; null;
-- All other cases cannot happen
when N_Subunit => when N_Subunit =>
pragma Assert (False, "subunit"); pragma Assert (False, "subunit");
null; null;
......
...@@ -8748,11 +8748,16 @@ package body Sem_Ch12 is ...@@ -8748,11 +8748,16 @@ package body Sem_Ch12 is
-- If we have no body, and the unit requires a body, then complain. This -- If we have no body, and the unit requires a body, then complain. This
-- complaint is suppressed if we have detected other errors (since a -- complaint is suppressed if we have detected other errors (since a
-- common reason for missing the body is that it had errors). -- common reason for missing the body is that it had errors).
-- In CodePeer mode, a warning has been emitted already, no need for
-- further messages.
elsif Unit_Requires_Body (Gen_Unit) elsif Unit_Requires_Body (Gen_Unit)
and then not Body_Optional and then not Body_Optional
then then
if Serious_Errors_Detected = 0 then if CodePeer_Mode then
null;
elsif Serious_Errors_Detected = 0 then
Error_Msg_NE Error_Msg_NE
("cannot find body of generic package &", Inst_Node, Gen_Unit); ("cannot find body of generic package &", Inst_Node, Gen_Unit);
...@@ -10451,7 +10456,9 @@ package body Sem_Ch12 is ...@@ -10451,7 +10456,9 @@ package body Sem_Ch12 is
loop loop
Mark_Context Mark_Context
(Inst_Decl, (Inst_Decl,
Unit_Declaration_Node (Generic_Parent (Parent (Scop)))); Unit_Declaration_Node
(Generic_Parent
(Specification (Unit_Declaration_Node (Scop)))));
Scop := Scope (Scop); Scop := Scope (Scop);
end loop; end loop;
...@@ -10857,11 +10864,20 @@ package body Sem_Ch12 is ...@@ -10857,11 +10864,20 @@ package body Sem_Ch12 is
Get_Body_Name (Get_Unit_Name (Unit (Comp_Unit))); Get_Body_Name (Get_Unit_Name (Unit (Comp_Unit)));
begin begin
Error_Msg_Unit_1 := Bname; -- In CodePeer mode, the missing body may make the
Error_Msg_N ("this instantiation requires$!", N); -- analysis incomplete, but we do not treat it as fatal.
Error_Msg_File_1 := Get_File_Name (Bname, Subunit => False);
Error_Msg_N ("\but file{ was not found!", N); if CodePeer_Mode then
raise Unrecoverable_Error; return;
else
Error_Msg_Unit_1 := Bname;
Error_Msg_N ("this instantiation requires$!", N);
Error_Msg_File_1
:= Get_File_Name (Bname, Subunit => False);
Error_Msg_N ("\but file{ was not found!", N);
raise Unrecoverable_Error;
end if;
end; end;
end if; end if;
end if; end if;
......
...@@ -63,6 +63,7 @@ with Ttypes; use Ttypes; ...@@ -63,6 +63,7 @@ with Ttypes; use Ttypes;
with Uname; use Uname; with Uname; use Uname;
with GNAT.HTable; use GNAT.HTable; with GNAT.HTable; use GNAT.HTable;
package body Sem_Util is package body Sem_Util is
---------------------------------------- ----------------------------------------
...@@ -94,19 +95,20 @@ package body Sem_Util is ...@@ -94,19 +95,20 @@ package body Sem_Util is
subtype NCT_Header_Num is Int range 0 .. 511; subtype NCT_Header_Num is Int range 0 .. 511;
-- Defines range of headers in hash tables (512 headers) -- Defines range of headers in hash tables (512 headers)
----------------------------------- ----------------------------------
-- Order dependence : AI05-0144 -- -- Order Dependence (AI05-0144) --
----------------------------------- ----------------------------------
-- Each actual in a call is entered into the table below. A flag -- Each actual in a call is entered into the table below. A flag indicates
-- indicates whether the corresponding formal is out or in out. -- whether the corresponding formal is OUT or IN OUT. Each top-level call
-- Each top-level call (procedure call, condition, assignment) -- (procedure call, condition, assignment) examines all the actuals for a
-- examines all the actuals for a possible order dependence. -- possible order dependence. The table is reset after each such check.
-- The table is reset after each such check.
type Actual_Name is record type Actual_Name is record
Act : Node_Id; Act : Node_Id;
Is_Writable : Boolean; Is_Writable : Boolean;
-- Comments needed???
end record; end record;
package Actuals_In_Call is new Table.Table ( package Actuals_In_Call is new Table.Table (
...@@ -117,65 +119,6 @@ package body Sem_Util is ...@@ -117,65 +119,6 @@ package body Sem_Util is
Table_Increment => 10, Table_Increment => 10,
Table_Name => "Actuals"); Table_Name => "Actuals");
procedure Save_Actual (N : Node_Id; Writable : Boolean := False) is
begin
if Is_Entity_Name (N)
or else Nkind_In (N,
N_Indexed_Component, N_Selected_Component, N_Slice)
or else (Nkind (N) = N_Attribute_Reference
and then Attribute_Name (N) = Name_Access)
then
-- We are only interested in in out parameters of inner calls.
if not Writable
or else Nkind (Parent (N)) = N_Function_Call
or else Nkind (Parent (N)) in N_Op
then
Actuals_In_Call.Increment_Last;
Actuals_In_Call.Table (Actuals_In_Call.Last) := (N, Writable);
end if;
end if;
end Save_Actual;
procedure Check_Order_Dependence is
Act1, Act2 : Node_Id;
begin
for J in 0 .. Actuals_In_Call.Last loop
if Actuals_In_Call.Table (J).Is_Writable then
Act1 := Actuals_In_Call.Table (J).Act;
if Nkind (Act1) = N_Attribute_Reference then
Act1 := Prefix (Act1);
end if;
for K in 0 .. Actuals_In_Call.Last loop
if K /= J then
Act2 := Actuals_In_Call.Table (K).Act;
if Nkind (Act2) = N_Attribute_Reference then
Act2 := Prefix (Act2);
end if;
if Actuals_In_Call.Table (K).Is_Writable
and then K < J
then
-- already checked
null;
elsif Denotes_Same_Object (Act1, Act2)
and then False
then
Error_Msg_N ("?,mighty suspicious!!!", Act1);
end if;
end if;
end loop;
end if;
end loop;
Actuals_In_Call.Set_Last (0);
end Check_Order_Dependence;
----------------------- -----------------------
-- Local Subprograms -- -- Local Subprograms --
----------------------- -----------------------
...@@ -1226,6 +1169,48 @@ package body Sem_Util is ...@@ -1226,6 +1169,48 @@ package body Sem_Util is
end if; end if;
end Check_Nested_Access; end Check_Nested_Access;
----------------------------
-- Check_Order_Dependence --
----------------------------
procedure Check_Order_Dependence is
Act1, Act2 : Node_Id;
begin
for J in 0 .. Actuals_In_Call.Last loop
if Actuals_In_Call.Table (J).Is_Writable then
Act1 := Actuals_In_Call.Table (J).Act;
if Nkind (Act1) = N_Attribute_Reference then
Act1 := Prefix (Act1);
end if;
for K in 0 .. Actuals_In_Call.Last loop
if K /= J then
Act2 := Actuals_In_Call.Table (K).Act;
if Nkind (Act2) = N_Attribute_Reference then
Act2 := Prefix (Act2);
end if;
if Actuals_In_Call.Table (K).Is_Writable
and then K < J
then
-- Already checked
null;
elsif Denotes_Same_Object (Act1, Act2)
and then False
then
Error_Msg_N ("?,mighty suspicious!!!", Act1);
end if;
end if;
end loop;
end if;
end loop;
Actuals_In_Call.Set_Last (0);
end Check_Order_Dependence;
------------------------------------------ ------------------------------------------
-- Check_Potentially_Blocking_Operation -- -- Check_Potentially_Blocking_Operation --
------------------------------------------ ------------------------------------------
...@@ -10583,6 +10568,32 @@ package body Sem_Util is ...@@ -10583,6 +10568,32 @@ package body Sem_Util is
end if; end if;
end Same_Value; end Same_Value;
-----------------
-- Save_Actual --
-----------------
procedure Save_Actual (N : Node_Id; Writable : Boolean := False) is
begin
if Is_Entity_Name (N)
or else
Nkind_In (N, N_Indexed_Component, N_Selected_Component, N_Slice)
or else
(Nkind (N) = N_Attribute_Reference
and then Attribute_Name (N) = Name_Access)
then
-- We are only interested in IN OUT parameters of inner calls
if not Writable
or else Nkind (Parent (N)) = N_Function_Call
or else Nkind (Parent (N)) in N_Op
then
Actuals_In_Call.Increment_Last;
Actuals_In_Call.Table (Actuals_In_Call.Last) := (N, Writable);
end if;
end if;
end Save_Actual;
------------------------ ------------------------
-- Scope_Is_Transient -- -- Scope_Is_Transient --
------------------------ ------------------------
......
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