Commit 0580d807 by Arnaud Charlet

[multiple changes]

2011-08-02  Robert Dewar  <dewar@adacore.com>

	* a-direct.adb, sinfo.ads, exp_ch9.adb, scng.adb, sem_util.adb,
	sem_util.ads, restrict.ads, par-prag.adb: Minor reformatting and/or
	code reorganization.

2011-08-02  Robert Dewar  <dewar@adacore.com>

	* debug.adb: Debug flag d.P to suppress length comparison optimization
	* exp_ch4.adb (Optimize_Length_Comparison): New routine to optimize
	comparison of Length by comparing First/Last instead.

2011-08-02  Matthew Heaney  <heaney@adacore.com>

	* a-cobove.ads: Code clean up.

From-SVN: r177190
parent b191a125
2011-08-02 Robert Dewar <dewar@adacore.com>
* a-direct.adb, sinfo.ads, exp_ch9.adb, scng.adb, sem_util.adb,
sem_util.ads, restrict.ads, par-prag.adb: Minor reformatting and/or
code reorganization.
2011-08-02 Robert Dewar <dewar@adacore.com>
* debug.adb: Debug flag d.P to suppress length comparison optimization
* exp_ch4.adb (Optimize_Length_Comparison): New routine to optimize
comparison of Length by comparing First/Last instead.
2011-08-02 Matthew Heaney <heaney@adacore.com>
* a-cobove.ads: Code clean up.
2011-08-02 Vincent Celier <celier@adacore.com> 2011-08-02 Vincent Celier <celier@adacore.com>
* adaint.c (file_names_case_sensitive_cache): New static int. * adaint.c (file_names_case_sensitive_cache): New static int.
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 2004-2010, Free Software Foundation, Inc. -- -- Copyright (C) 2004-2011, Free Software Foundation, Inc. --
-- -- -- --
-- This specification is derived from the Ada Reference Manual for use with -- -- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow -- -- GNAT. The copyright notice above, and the license provisions that follow --
...@@ -322,7 +322,7 @@ private ...@@ -322,7 +322,7 @@ private
function "=" (L, R : Elements_Array) return Boolean is abstract; function "=" (L, R : Elements_Array) return Boolean is abstract;
type Vector (Capacity : Count_Type) is tagged record type Vector (Capacity : Count_Type) is tagged record
Elements : Elements_Array (1 .. Capacity); Elements : Elements_Array (1 .. Capacity) := (others => <>);
Last : Extended_Index := No_Index; Last : Extended_Index := No_Index;
Busy : Natural := 0; Busy : Natural := 0;
Lock : Natural := 0; Lock : Natural := 0;
......
...@@ -39,23 +39,23 @@ with Ada.Unchecked_Conversion; ...@@ -39,23 +39,23 @@ with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation; with Ada.Unchecked_Deallocation;
with Ada.Characters.Handling; use Ada.Characters.Handling; with Ada.Characters.Handling; use Ada.Characters.Handling;
with System.CRTL; use System.CRTL; with System.CRTL; use System.CRTL;
with System.OS_Constants; with System.OS_Constants; use System.OS_Constants;
with System.OS_Lib; use System.OS_Lib; with System.OS_Lib; use System.OS_Lib;
with System.Regexp; use System.Regexp; with System.Regexp; use System.Regexp;
with System.File_IO; use System.File_IO; with System.File_IO; use System.File_IO;
with System; with System; use System;
package body Ada.Directories is package body Ada.Directories is
Filename_Max : constant Integer := 1024; Filename_Max : constant Integer := 1024;
-- 1024 is the value of FILENAME_MAX in stdio.h -- 1024 is the value of FILENAME_MAX in stdio.h
type Dir_Type_Value is new System.Address; type Dir_Type_Value is new Address;
-- This is the low-level address directory structure as returned by the C -- This is the low-level address directory structure as returned by the C
-- opendir routine. -- opendir routine.
No_Dir : constant Dir_Type_Value := Dir_Type_Value (System.Null_Address); No_Dir : constant Dir_Type_Value := Dir_Type_Value (Null_Address);
Dir_Separator : constant Character; Dir_Separator : constant Character;
pragma Import (C, Dir_Separator, "__gnat_dir_separator"); pragma Import (C, Dir_Separator, "__gnat_dir_separator");
...@@ -384,7 +384,7 @@ package body Ada.Directories is ...@@ -384,7 +384,7 @@ package body Ada.Directories is
end; end;
end if; end if;
-- The implementation uses System.OS_Lib.Copy_File -- Do actual copy using System.OS_Lib.Copy_File
Copy_File (Source_Name, Target_Name, Success, Mode, Preserve); Copy_File (Source_Name, Target_Name, Success, Mode, Preserve);
...@@ -496,9 +496,7 @@ package body Ada.Directories is ...@@ -496,9 +496,7 @@ package body Ada.Directories is
Path_Len : Natural := Max_Path; Path_Len : Natural := Max_Path;
Buffer : String (1 .. 1 + Max_Path + 1); Buffer : String (1 .. 1 + Max_Path + 1);
procedure Local_Get_Current_Dir procedure Local_Get_Current_Dir (Dir : Address; Length : Address);
(Dir : System.Address;
Length : System.Address);
pragma Import (C, Local_Get_Current_Dir, "__gnat_get_current_dir"); pragma Import (C, Local_Get_Current_Dir, "__gnat_get_current_dir");
begin begin
...@@ -563,7 +561,7 @@ package body Ada.Directories is ...@@ -563,7 +561,7 @@ package body Ada.Directories is
raise Name_Error with "file """ & Name & """ does not exist"; raise Name_Error with "file """ & Name & """ does not exist";
else else
-- The implementation uses System.OS_Lib.Delete_File -- Do actual deletion using System.OS_Lib.Delete_File
Delete_File (Name, Success); Delete_File (Name, Success);
...@@ -602,7 +600,7 @@ package body Ada.Directories is ...@@ -602,7 +600,7 @@ package body Ada.Directories is
File_Name : constant String := Simple_Name (Dir_Ent); File_Name : constant String := Simple_Name (Dir_Ent);
begin begin
if System.OS_Lib.Is_Directory (File_Name) then if OS_Lib.Is_Directory (File_Name) then
if File_Name /= "." and then File_Name /= ".." then if File_Name /= "." and then File_Name /= ".." then
Delete_Tree (File_Name); Delete_Tree (File_Name);
end if; end if;
...@@ -698,7 +696,7 @@ package body Ada.Directories is ...@@ -698,7 +696,7 @@ package body Ada.Directories is
Kind : File_Kind := Ordinary_File; Kind : File_Kind := Ordinary_File;
-- Initialized to avoid a compilation warning -- Initialized to avoid a compilation warning
Filename_Addr : System.Address; Filename_Addr : Address;
Filename_Len : aliased Integer; Filename_Len : aliased Integer;
Buffer : array (0 .. Filename_Max + 12) of Character; Buffer : array (0 .. Filename_Max + 12) of Character;
...@@ -706,26 +704,24 @@ package body Ada.Directories is ...@@ -706,26 +704,24 @@ package body Ada.Directories is
-- field for the filename. -- field for the filename.
function readdir_gnat function readdir_gnat
(Directory : System.Address; (Directory : Address;
Buffer : System.Address; Buffer : Address;
Last : not null access Integer) return System.Address; Last : not null access Integer) return Address;
pragma Import (C, readdir_gnat, "__gnat_readdir"); pragma Import (C, readdir_gnat, "__gnat_readdir");
use System;
begin begin
-- Search.Value.Is_Valid is always True when Fetch_Next_Entry is called -- Search.Value.Is_Valid is always True when Fetch_Next_Entry is called
loop loop
Filename_Addr := Filename_Addr :=
readdir_gnat readdir_gnat
(System.Address (Search.Value.Dir), (Address (Search.Value.Dir),
Buffer'Address, Buffer'Address,
Filename_Len'Access); Filename_Len'Access);
-- If no matching entry is found, set Is_Valid to False -- If no matching entry is found, set Is_Valid to False
if Filename_Addr = System.Null_Address then if Filename_Addr = Null_Address then
Search.Value.Is_Valid := False; Search.Value.Is_Valid := False;
exit; exit;
end if; end if;
...@@ -801,7 +797,7 @@ package body Ada.Directories is ...@@ -801,7 +797,7 @@ package body Ada.Directories is
----------------- -----------------
function File_Exists (Name : String) return Boolean is function File_Exists (Name : String) return Boolean is
function C_File_Exists (A : System.Address) return Integer; function C_File_Exists (A : Address) return Integer;
pragma Import (C, C_File_Exists, "__gnat_file_exists"); pragma Import (C, C_File_Exists, "__gnat_file_exists");
C_Name : String (1 .. Name'Length + 1); C_Name : String (1 .. Name'Length + 1);
...@@ -848,9 +844,11 @@ package body Ada.Directories is ...@@ -848,9 +844,11 @@ package body Ada.Directories is
declare declare
-- We need to resolve links because of A.16(47), since we must not -- We need to resolve links because of A.16(47), since we must not
-- return alternative names for files -- return alternative names for files.
Value : constant String := Normalize_Pathname (Name); Value : constant String := Normalize_Pathname (Name);
subtype Result is String (1 .. Value'Length); subtype Result is String (1 .. Value'Length);
begin begin
return Result (Value); return Result (Value);
end; end;
...@@ -1056,18 +1054,19 @@ package body Ada.Directories is ...@@ -1056,18 +1054,19 @@ package body Ada.Directories is
& """ designates a file that already exists"; & """ designates a file that already exists";
else else
-- The implementation uses System.OS_Lib.Rename_File -- Do actual rename using System.OS_Lib.Rename_File
Rename_File (Old_Name, New_Name, Success); Rename_File (Old_Name, New_Name, Success);
if not Success then if not Success then
-- AI05-0231-1: Name_Error should be raised in case a directory -- AI05-0231-1: Name_Error should be raised in case a directory
-- component of New_Name does not exist (as in New_Name => -- component of New_Name does not exist (as in New_Name =>
-- "/no-such-dir/new-filename"). ENOENT indicates that. ENOENT -- "/no-such-dir/new-filename"). ENOENT indicates that. ENOENT
-- also indicate that the Old_Name does not exist, but we already -- also indicate that the Old_Name does not exist, but we already
-- checked for that above. All other errors are Use_Error. -- checked for that above. All other errors are Use_Error.
if Errno = System.OS_Constants.ENOENT then if Errno = ENOENT then
raise Name_Error with raise Name_Error with
"file """ & Containing_Directory (New_Name) & """ not found"; "file """ & Containing_Directory (New_Name) & """ not found";
...@@ -1154,9 +1153,10 @@ package body Ada.Directories is ...@@ -1154,9 +1153,10 @@ package body Ada.Directories is
Cut_End := Path'Last; Cut_End := Path'Last;
Check_For_Standard_Dirs : declare Check_For_Standard_Dirs : declare
BN : constant String := Path (Cut_Start .. Cut_End); BN : constant String := Path (Cut_Start .. Cut_End);
Has_Drive_Letter : constant Boolean := Has_Drive_Letter : constant Boolean :=
System.OS_Lib.Path_Separator /= ':'; OS_Lib.Path_Separator /= ':';
-- If Path separator is not ':' then we are on a DOS based OS -- If Path separator is not ':' then we are on a DOS based OS
-- where this character is used as a drive letter separator. -- where this character is used as a drive letter separator.
...@@ -1221,7 +1221,7 @@ package body Ada.Directories is ...@@ -1221,7 +1221,7 @@ package body Ada.Directories is
function Size (Name : String) return File_Size is function Size (Name : String) return File_Size is
C_Name : String (1 .. Name'Length + 1); C_Name : String (1 .. Name'Length + 1);
function C_Size (Name : System.Address) return Long_Integer; function C_Size (Name : Address) return Long_Integer;
pragma Import (C, C_Size, "__gnat_named_file_length"); pragma Import (C, C_Size, "__gnat_named_file_length");
begin begin
......
...@@ -133,7 +133,7 @@ package body Debug is ...@@ -133,7 +133,7 @@ package body Debug is
-- d.M -- d.M
-- d.N -- d.N
-- d.O Dump internal SCO tables -- d.O Dump internal SCO tables
-- d.P -- d.P Previous (non-optimized) handling of length comparisons
-- d.Q -- d.Q
-- d.R -- d.R
-- d.S Force Optimize_Alignment (Space) -- d.S Force Optimize_Alignment (Space)
...@@ -597,6 +597,11 @@ package body Debug is ...@@ -597,6 +597,11 @@ package body Debug is
-- the ALI file, the internal SCO tables (SCO_Table/SCO_Unit_Table) -- the ALI file, the internal SCO tables (SCO_Table/SCO_Unit_Table)
-- are dumped for debugging purposes. -- are dumped for debugging purposes.
-- d.P Previous non-optimized handling of length comparisons. Setting this
-- flag inhibits the effect of Optimize_Length_Comparison in Exp_Ch4.
-- This is there in case we find a situation where the optimization
-- malfunctions, to provide a work around.
-- d.S Force Optimize_Alignment (Space) mode as the default -- d.S Force Optimize_Alignment (Space) mode as the default
-- d.T Force Optimize_Alignment (Time) mode as the default -- d.T Force Optimize_Alignment (Time) mode as the default
......
...@@ -11516,7 +11516,7 @@ package body Exp_Ch9 is ...@@ -11516,7 +11516,7 @@ package body Exp_Ch9 is
end if; end if;
-- If the type of the dispatching object is an access type then return -- If the type of the dispatching object is an access type then return
-- an explicit dereference -- an explicit dereference.
if Is_Access_Type (Etype (Object)) then if Is_Access_Type (Etype (Object)) then
Object := Make_Explicit_Dereference (Sloc (N), Object); Object := Make_Explicit_Dereference (Sloc (N), Object);
......
...@@ -89,13 +89,23 @@ function Prag (Pragma_Node : Node_Id; Semi : Source_Ptr) return Node_Id is ...@@ -89,13 +89,23 @@ function Prag (Pragma_Node : Node_Id; Semi : Source_Ptr) return Node_Id is
procedure Process_Restrictions_Or_Restriction_Warnings; procedure Process_Restrictions_Or_Restriction_Warnings;
-- Common processing for Restrictions and Restriction_Warnings pragmas. -- Common processing for Restrictions and Restriction_Warnings pragmas.
-- This routine processes the cases of No_Obsolescent_Features and SPARK, -- For the most part, restrictions need not be processed at parse time,
-- which are the only restriction that have syntactic effects. In the case -- since they only affect semantic processing. This routine handles the
-- of SPARK, it controls whether the scanner generates a token -- exceptions as follows
-- Tok_SPARK_Hide for HIDE directives formatted as Ada comments. No general --
-- error checking is done, since this will be done in Sem_Prag. The other -- No_Obsolescent_Features must be processed at parse time, since there
-- case processed is pragma Restrictions No_Dependence, since otherwise -- are some obsolescent features (e.g. character replacements) which are
-- this is done too late. -- handled at parse time.
--
-- SPARK must be processed at parse time, since this restriction controls
-- whether the scanner recognizes a spark HIDE directive formatted as an
-- Ada comment (and generates a Tok_SPARK_Hide token for the directive).
--
-- No_Dependence must be processed at parse time, since otherwise it gets
-- handled too late.
--
-- Note that we don't need to do full error checking for badly formed cases
-- of restrictions, since these will be caught during semantic analysis.
---------- ----------
-- Arg1 -- -- Arg1 --
...@@ -232,10 +242,12 @@ function Prag (Pragma_Node : Node_Id; Semi : Source_Ptr) return Node_Id is ...@@ -232,10 +242,12 @@ function Prag (Pragma_Node : Node_Id; Semi : Source_Ptr) return Node_Id is
Set_Restriction (No_Obsolescent_Features, Pragma_Node); Set_Restriction (No_Obsolescent_Features, Pragma_Node);
Restriction_Warnings (No_Obsolescent_Features) := Restriction_Warnings (No_Obsolescent_Features) :=
Prag_Id = Pragma_Restriction_Warnings; Prag_Id = Pragma_Restriction_Warnings;
when SPARK => when SPARK =>
Set_Restriction (SPARK, Pragma_Node); Set_Restriction (SPARK, Pragma_Node);
Restriction_Warnings (SPARK) := Restriction_Warnings (SPARK) :=
Prag_Id = Pragma_Restriction_Warnings; Prag_Id = Pragma_Restriction_Warnings;
when others => when others =>
null; null;
end case; end case;
......
...@@ -178,9 +178,9 @@ package Restrict is ...@@ -178,9 +178,9 @@ package Restrict is
-- SPARK Restriction Control -- -- SPARK Restriction Control --
------------------------------- -------------------------------
-- SPARK HIDE directives allow turning off SPARK restriction for a -- SPARK HIDE directives allow the effect of the SPARK restriction to be
-- specified region of code, and the following tables are the data -- turned off for a specified region of code, and the following tables are
-- structures used to keep track of these regions. -- the data structures used to keep track of these regions.
-- The table contains pairs of source locations, the first being the start -- The table contains pairs of source locations, the first being the start
-- location for hidden region, and the second being the end location. -- location for hidden region, and the second being the end location.
......
...@@ -1764,8 +1764,8 @@ package body Scng is ...@@ -1764,8 +1764,8 @@ package body Scng is
return; return;
end if; end if;
-- Generate a token Tok_SPARK_Hide for a SPARK HIDE directive -- If the SPARK restriction is set for this unit, then generate
-- only if the SPARK restriction is set for this unit. -- a token Tok_SPARK_Hide for a SPARK HIDE directive.
if Restriction_Check_Required (SPARK) if Restriction_Check_Required (SPARK)
and then Source (Start_Of_Comment) = '#' and then Source (Start_Of_Comment) = '#'
......
...@@ -2335,6 +2335,7 @@ package body Sem_Util is ...@@ -2335,6 +2335,7 @@ package body Sem_Util is
procedure Mark_Non_ALFA_Subprogram_Unconditional is procedure Mark_Non_ALFA_Subprogram_Unconditional is
Cur_Subp : constant Entity_Id := Current_Subprogram; Cur_Subp : constant Entity_Id := Current_Subprogram;
begin begin
if Present (Cur_Subp) if Present (Cur_Subp)
and then (Is_Subprogram (Cur_Subp) and then (Is_Subprogram (Cur_Subp)
...@@ -2344,6 +2345,9 @@ package body Sem_Util is ...@@ -2344,6 +2345,9 @@ package body Sem_Util is
-- then mark the subprogram as not in ALFA. Otherwise, mark the -- then mark the subprogram as not in ALFA. Otherwise, mark the
-- subprogram body as not in ALFA. -- subprogram body as not in ALFA.
-- This comment just says what is done, but not why ??? and it
-- just repeats what is in the spec ???
if In_Pre_Post_Expression then if In_Pre_Post_Expression then
Set_Is_In_ALFA (Cur_Subp, False); Set_Is_In_ALFA (Cur_Subp, False);
else else
......
...@@ -279,10 +279,14 @@ package Sem_Util is ...@@ -279,10 +279,14 @@ package Sem_Util is
procedure Mark_Non_ALFA_Subprogram; procedure Mark_Non_ALFA_Subprogram;
-- If Current_Subprogram is not Empty, mark either its specification or its -- If Current_Subprogram is not Empty, mark either its specification or its
-- body as not being in ALFA. If called during the analysis of a -- body as not being in ALFA. If this procedure is called during the
-- precondition or postcondition, as indicated by the flag -- analysis of a precondition or postcondition, as indicated by the flag
-- In_Pre_Post_Expression, mark the specification as not being in ALFA. -- In_Pre_Post_Expression, mark the specification as not being in ALFA.
-- Otherwise, mark the body as not being in ALFA. -- Otherwise, mark the body as not being in ALFA.
--
-- I would really like to see more comments on this peculiar processing
-- for precondition/postcondition, the comment above says what is done
-- but not why???
function Defining_Entity (N : Node_Id) return Entity_Id; function Defining_Entity (N : Node_Id) return Entity_Id;
-- Given a declaration N, returns the associated defining entity. If the -- Given a declaration N, returns the associated defining entity. If the
......
...@@ -1116,7 +1116,7 @@ package Sinfo is ...@@ -1116,7 +1116,7 @@ package Sinfo is
-- this is required, see Exp_Ch11.Remove_Handler_Entries. -- this is required, see Exp_Ch11.Remove_Handler_Entries.
-- Has_Dynamic_Length_Check (Flag10-Sem) -- Has_Dynamic_Length_Check (Flag10-Sem)
-- This flag is present on all expression nodes. It is set to indicate -- This flag is present in all expression nodes. It is set to indicate
-- that one of the routines in unit Checks has generated a length check -- that one of the routines in unit Checks has generated a length check
-- action which has been inserted at the flagged node. This is used to -- action which has been inserted at the flagged node. This is used to
-- avoid the generation of duplicate checks. -- avoid the generation of duplicate checks.
...@@ -1126,7 +1126,8 @@ package Sinfo is ...@@ -1126,7 +1126,8 @@ package Sinfo is
-- expression nodes. It is set to indicate that one of the routines in -- expression nodes. It is set to indicate that one of the routines in
-- unit Checks has generated a range check action which has been inserted -- unit Checks has generated a range check action which has been inserted
-- at the flagged node. This is used to avoid the generation of duplicate -- at the flagged node. This is used to avoid the generation of duplicate
-- checks. -- checks. Why does this occur on N_Subtype_Declaration nodes, what does
-- it mean in that context???
-- Has_Local_Raise (Flag8-Sem) -- Has_Local_Raise (Flag8-Sem)
-- Present in exception handler nodes. Set if the handler can be entered -- Present in exception handler nodes. Set if the handler can be entered
......
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