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>
* gcc-interface/decl.c (gnat_to_gnu_entity) <case E_Procedure>: Use
......
......@@ -6,7 +6,7 @@
-- --
-- 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 --
-- terms of the GNU General Public License as published by the Free Soft- --
......@@ -1295,9 +1295,9 @@ package body ALI is
else
Skip_Space;
No_Deps.Append ((Id, Get_Name));
Skip_Eol;
end if;
Skip_Eol;
C := Getc;
end loop;
......
......@@ -1176,7 +1176,7 @@ package body GNAT.Perfect_Hash_Generators is
procedure Initialize
(Seed : Natural;
K_To_V : Float := Default_K_To_V;
Optim : Optimization := CPU_Time;
Optim : Optimization := Memory_Space;
Tries : Positive := Default_Tries)
is
begin
......@@ -1596,39 +1596,41 @@ package body GNAT.Perfect_Hash_Generators is
New_Line (File);
if Opt = CPU_Time then
Put_Int_Matrix
(File,
Array_Img ("T1", Type_Img (NV),
Range_Img (0, T1_Len - 1),
Range_Img (0, T2_Len - 1, Type_Img (256))),
T1, T1_Len, T2_Len);
else
Put_Int_Matrix
(File,
Array_Img ("T1", Type_Img (NV),
Range_Img (0, T1_Len - 1)),
T1, T1_Len, 0);
end if;
case Opt is
when CPU_Time =>
Put_Int_Matrix
(File,
Array_Img ("T1", Type_Img (NV),
Range_Img (0, T1_Len - 1),
Range_Img (0, T2_Len - 1, Type_Img (256))),
T1, T1_Len, T2_Len);
when Memory_Space =>
Put_Int_Matrix
(File,
Array_Img ("T1", Type_Img (NV),
Range_Img (0, T1_Len - 1)),
T1, T1_Len, 0);
end case;
New_Line (File);
if Opt = CPU_Time then
Put_Int_Matrix
(File,
Array_Img ("T2", Type_Img (NV),
Range_Img (0, T1_Len - 1),
Range_Img (0, T2_Len - 1, Type_Img (256))),
T2, T1_Len, T2_Len);
else
Put_Int_Matrix
(File,
Array_Img ("T2", Type_Img (NV),
Range_Img (0, T1_Len - 1)),
T2, T1_Len, 0);
end if;
case Opt is
when CPU_Time =>
Put_Int_Matrix
(File,
Array_Img ("T2", Type_Img (NV),
Range_Img (0, T1_Len - 1),
Range_Img (0, T2_Len - 1, Type_Img (256))),
T2, T1_Len, T2_Len);
when Memory_Space =>
Put_Int_Matrix
(File,
Array_Img ("T2", Type_Img (NV),
Range_Img (0, T1_Len - 1)),
T2, T1_Len, 0);
end case;
New_Line (File);
......@@ -1650,11 +1652,12 @@ package body GNAT.Perfect_Hash_Generators is
Put (File, " J : ");
if Opt = CPU_Time then
Put (File, Type_Img (256));
else
Put (File, "Natural");
end if;
case Opt is
when CPU_Time =>
Put (File, Type_Img (256));
when Memory_Space =>
Put (File, "Natural");
end case;
Put (File, ";");
New_Line (File);
......@@ -1667,11 +1670,12 @@ package body GNAT.Perfect_Hash_Generators is
New_Line (File);
Put (File, " J := ");
if Opt = CPU_Time then
Put (File, "C");
else
Put (File, "Character'Pos");
end if;
case Opt is
when CPU_Time =>
Put (File, "C");
when Memory_Space =>
Put (File, "Character'Pos");
end case;
Put (File, " (S (P (K) + F));");
New_Line (File);
......@@ -2490,20 +2494,21 @@ package body GNAT.Perfect_Hash_Generators is
R : Natural;
begin
if Opt = CPU_Time then
for J in 0 .. T1_Len - 1 loop
exit when Word (J + 1) = ASCII.NUL;
R := Get_Table (Table, J, Get_Used_Char (Word (J + 1)));
S := (S + R) mod NV;
end loop;
case Opt is
when CPU_Time =>
for J in 0 .. T1_Len - 1 loop
exit when Word (J + 1) = ASCII.NUL;
R := Get_Table (Table, J, Get_Used_Char (Word (J + 1)));
S := (S + R) mod NV;
end loop;
else
for J in 0 .. T1_Len - 1 loop
exit when Word (J + 1) = ASCII.NUL;
R := Get_Table (Table, J, 0);
S := (S + R * Character'Pos (Word (J + 1))) mod NV;
end loop;
end if;
when Memory_Space =>
for J in 0 .. T1_Len - 1 loop
exit when Word (J + 1) = ASCII.NUL;
R := Get_Table (Table, J, 0);
S := (S + R * Character'Pos (Word (J + 1))) mod NV;
end loop;
end case;
return S;
end Sum;
......
......@@ -86,8 +86,9 @@ package GNAT.Perfect_Hash_Generators is
-- number of tries.
type Optimization is (Memory_Space, CPU_Time);
Default_Optimization : constant Optimization := CPU_Time;
-- Optimize either the memory space or the execution time
-- Optimize either the memory space or the execution time. Note: in
-- practice, the optimization mode has little effect on speed. The tables
-- are somewhat smaller with Memory_Space.
Verbose : Boolean := False;
-- Output the status of the algorithm. For instance, the tables, the random
......@@ -97,7 +98,7 @@ package GNAT.Perfect_Hash_Generators is
procedure Initialize
(Seed : Natural;
K_To_V : Float := Default_K_To_V;
Optim : Optimization := CPU_Time;
Optim : Optimization := Memory_Space;
Tries : Positive := Default_Tries);
-- Initialize the generator and its internal structures. Set the ratio of
-- vertices over keys in the random graphs. This value has to be greater
......
......@@ -1630,7 +1630,7 @@ private
Error_On_Unknown_Language => True,
Require_Obj_Dirs => Warning,
Allow_Invalid_External => Error,
Missing_Source_Files => Warning);
Missing_Source_Files => Error);
Gnatmake_Flags : constant Processing_Flags :=
(Report_Error => null,
......
......@@ -1589,7 +1589,7 @@ package body Sem is
null;
when N_Subprogram_Body =>
when N_Subprogram_Body =>
-- A subprogram body must be the main unit
......@@ -1597,14 +1597,17 @@ package body Sem is
or else CU = Cunit (Main_Unit));
null;
-- All other cases cannot happen
when N_Function_Instantiation |
N_Procedure_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;
-- All other cases cannot happen
when N_Subunit =>
pragma Assert (False, "subunit");
null;
......
......@@ -8748,11 +8748,16 @@ package body Sem_Ch12 is
-- 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
-- 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)
and then not Body_Optional
then
if Serious_Errors_Detected = 0 then
if CodePeer_Mode then
null;
elsif Serious_Errors_Detected = 0 then
Error_Msg_NE
("cannot find body of generic package &", Inst_Node, Gen_Unit);
......@@ -10451,7 +10456,9 @@ package body Sem_Ch12 is
loop
Mark_Context
(Inst_Decl,
Unit_Declaration_Node (Generic_Parent (Parent (Scop))));
Unit_Declaration_Node
(Generic_Parent
(Specification (Unit_Declaration_Node (Scop)))));
Scop := Scope (Scop);
end loop;
......@@ -10857,11 +10864,20 @@ package body Sem_Ch12 is
Get_Body_Name (Get_Unit_Name (Unit (Comp_Unit)));
begin
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;
-- In CodePeer mode, the missing body may make the
-- analysis incomplete, but we do not treat it as fatal.
if CodePeer_Mode then
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 if;
end if;
......
......@@ -63,6 +63,7 @@ with Ttypes; use Ttypes;
with Uname; use Uname;
with GNAT.HTable; use GNAT.HTable;
package body Sem_Util is
----------------------------------------
......@@ -94,19 +95,20 @@ package body Sem_Util is
subtype NCT_Header_Num is Int range 0 .. 511;
-- 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
-- indicates whether the corresponding formal is out or in out.
-- Each top-level call (procedure call, condition, assignment)
-- examines all the actuals for a possible order dependence.
-- The table is reset after each such check.
-- Each actual in a call is entered into the table below. A flag indicates
-- whether the corresponding formal is OUT or IN OUT. Each top-level call
-- (procedure call, condition, assignment) examines all the actuals for a
-- possible order dependence. The table is reset after each such check.
type Actual_Name is record
Act : Node_Id;
Act : Node_Id;
Is_Writable : Boolean;
-- Comments needed???
end record;
package Actuals_In_Call is new Table.Table (
......@@ -117,65 +119,6 @@ package body Sem_Util is
Table_Increment => 10,
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 --
-----------------------
......@@ -1226,6 +1169,48 @@ package body Sem_Util is
end if;
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 --
------------------------------------------
......@@ -10583,6 +10568,32 @@ package body Sem_Util is
end if;
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 --
------------------------
......
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