Commit fccd42a9 by Arnaud Charlet

[multiple changes]

2011-08-03  Yannick Moy  <moy@adacore.com>

	* sem_ch4.adb (Analyze_Conditional_Expression): only allow boolean
	conditional expression in ALFA.
	* sem_res.adb (Resolve_Conditional_Expression): mark non-boolean
	expressions as not in ALFA.

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

	* a-cofove.adb: Minor reformatting.

2011-08-03  Emmanuel Briot  <briot@adacore.com>

	* make.adb, prj.adb, prj.ads, makeutl.adb, makeutl.ads
	(Insert_Project_Sources, Insert_withed_Sources_For): moved from the
	gprbuild sources.
	These packages are more logically placed in the Queue package, since
	they manipulate the queue. It is also likely that they can be adapted
	for gnatmake, thus sharing more code.
	(Finish_Program, Fail_Program): moved from the gprbuild sources, so
	that we could move the above.

2011-08-03  Emmanuel Briot  <briot@adacore.com>

	* errutil.adb (Finalize): clean up the list of error messages on exit.
	Calling this subprogram multiple times will no longer show duplicate
	error messages on stderr.

2011-08-03  Emmanuel Briot  <briot@adacore.com>

	* g-comlin.adb, g-comlin.ads (Set_Command_Line): ignore the parameter
	Getopt_Switches when we have already define a command line
	configuration.

From-SVN: r177286
parent 5e8c8e44
2011-08-03 Yannick Moy <moy@adacore.com> 2011-08-03 Yannick Moy <moy@adacore.com>
* sem_ch4.adb (Analyze_Conditional_Expression): only allow boolean
conditional expression in ALFA.
* sem_res.adb (Resolve_Conditional_Expression): mark non-boolean
expressions as not in ALFA.
2011-08-03 Robert Dewar <dewar@adacore.com>
* a-cofove.adb: Minor reformatting.
2011-08-03 Emmanuel Briot <briot@adacore.com>
* make.adb, prj.adb, prj.ads, makeutl.adb, makeutl.ads
(Insert_Project_Sources, Insert_withed_Sources_For): moved from the
gprbuild sources.
These packages are more logically placed in the Queue package, since
they manipulate the queue. It is also likely that they can be adapted
for gnatmake, thus sharing more code.
(Finish_Program, Fail_Program): moved from the gprbuild sources, so
that we could move the above.
2011-08-03 Emmanuel Briot <briot@adacore.com>
* errutil.adb (Finalize): clean up the list of error messages on exit.
Calling this subprogram multiple times will no longer show duplicate
error messages on stderr.
2011-08-03 Emmanuel Briot <briot@adacore.com>
* g-comlin.adb, g-comlin.ads (Set_Command_Line): ignore the parameter
Getopt_Switches when we have already define a command line
configuration.
2011-08-03 Yannick Moy <moy@adacore.com>
* sem_ch11.adb (Analyze_Raise_xxx_Error): do not mark such nodes as not * sem_ch11.adb (Analyze_Raise_xxx_Error): do not mark such nodes as not
in ALFA. Instead, they are considered as assertions to prove. in ALFA. Instead, they are considered as assertions to prove.
* sem_ch4.adb (Analyze_Conditional_Expression): do not always mark such * sem_ch4.adb (Analyze_Conditional_Expression): do not always mark such
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1991-2009, Free Software Foundation, Inc. -- -- Copyright (C) 1991-2011, 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- --
...@@ -571,6 +571,10 @@ package body Errutil is ...@@ -571,6 +571,10 @@ package body Errutil is
Total_Errors_Detected := Total_Errors_Detected + Warnings_Detected; Total_Errors_Detected := Total_Errors_Detected + Warnings_Detected;
Warnings_Detected := 0; Warnings_Detected := 0;
end if; end if;
-- Prevent displaying the same messages again in the future
First_Error_Msg := No_Error_Msg;
end Finalize; end Finalize;
---------------- ----------------
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1999-2010, Free Software Foundation, Inc. -- -- Copyright (C) 1999-2011, 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- --
...@@ -19,10 +19,10 @@ ...@@ -19,10 +19,10 @@
-- additional permissions described in the GCC Runtime Library Exception, -- -- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. -- -- version 3.1, as published by the Free Software Foundation. --
-- -- -- --
-- You should have received a copy of the GNU General Public License and -- -- In particular, you can freely distribute your programs built with the --
-- a copy of the GCC Runtime Library Exception along with this program; -- -- GNAT Pro compiler, including any required library run-time units, using --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- any licensing terms of your choosing. See the AdaCore Software License --
-- <http://www.gnu.org/licenses/>. -- -- for full details. --
-- -- -- --
-- GNAT was originally developed by the GNAT team at New York University. -- -- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. -- -- Extensive contributions were provided by Ada Core Technologies Inc. --
...@@ -200,7 +200,8 @@ package body GNAT.Command_Line is ...@@ -200,7 +200,8 @@ package body GNAT.Command_Line is
(Config : Command_Line_Configuration; (Config : Command_Line_Configuration;
Section : String); Section : String);
-- Iterate over all switches defined in Config, for a specific section. -- Iterate over all switches defined in Config, for a specific section.
-- Index is set to the index in Config.Switches -- Index is set to the index in Config.Switches.
-- Stop iterating when Callback returns False.
-------------- --------------
-- Argument -- -- Argument --
...@@ -1238,6 +1239,10 @@ package body GNAT.Command_Line is ...@@ -1238,6 +1239,10 @@ package body GNAT.Command_Line is
Unchecked_Free (Tmp); Unchecked_Free (Tmp);
end if; end if;
if Switch.Switch /= null and then Switch.Switch.all = "*" then
Config.Star_Switch := True;
end if;
Config.Switches (Config.Switches'Last) := Switch; Config.Switches (Config.Switches'Last) := Switch;
end Add; end Add;
...@@ -1592,9 +1597,28 @@ package body GNAT.Command_Line is ...@@ -1592,9 +1597,28 @@ package body GNAT.Command_Line is
loop loop
begin begin
S := Getopt (Switches => "* " & Getopt_Description, if Cmd.Config /= null then
Concatenate => False, -- Do not use Getopt_Description in this case. Otherwise,
Parser => Parser); -- if we have defined a prefix -gnaty, and two switches
-- -gnatya and -gnatyL!, we would have a different behavior
-- depending on the order of switches:
-- -gnatyL1a => -gnatyL with argument "1a"
-- -gnatyaL1 => -gnatya and -gnatyL with argument "1"
-- This is because the call to Getopt below knows nothing
-- about prefixes, and in the first case finds a valid
-- switch with arguments, so returns it without analyzing
-- the argument. In the second case, the switch matches "*",
-- and is then decomposed below.
S := Getopt (Switches => "*",
Concatenate => False,
Parser => Parser);
else
S := Getopt (Switches => "* " & Getopt_Description,
Concatenate => False,
Parser => Parser);
end if;
exit when S = ASCII.NUL; exit when S = ASCII.NUL;
declare declare
...@@ -1761,6 +1785,8 @@ package body GNAT.Command_Line is ...@@ -1761,6 +1785,8 @@ package body GNAT.Command_Line is
function Analyze_Simple_Switch function Analyze_Simple_Switch
(Switch : String; Index : Integer) return Boolean; (Switch : String; Index : Integer) return Boolean;
-- "Switches" is one of the switch definitions passed to the
-- configuration, not one of the switches found on the command line.
--------------------------- ---------------------------
-- Analyze_Simple_Switch -- -- Analyze_Simple_Switch --
...@@ -1772,26 +1798,26 @@ package body GNAT.Command_Line is ...@@ -1772,26 +1798,26 @@ package body GNAT.Command_Line is
pragma Unreferenced (Index); pragma Unreferenced (Index);
Full : constant String := Prefix & Group (Idx .. Group'Last); Full : constant String := Prefix & Group (Idx .. Group'Last);
Sw : constant String := Actual_Switch (Switch); Sw : constant String := Actual_Switch (Switch);
-- Switches definition minus argument definition
Last : Natural; Last : Natural;
Param : Natural; Param : Natural;
begin begin
if Sw'Length >= Prefix'Length if
-- Verify that sw starts with Prefix
-- Verify that sw starts with Prefix Looking_At (Sw, Sw'First, Prefix)
and then Looking_At (Sw, Sw'First, Prefix)
-- Verify that the group starts with sw
-- Verify that the group starts with sw
and then Looking_At (Full, Full'First, Sw) and then Looking_At (Full, Full'First, Sw)
then then
Last := Idx + Sw'Length - Prefix'Length - 1; Last := Idx + Sw'Length - Prefix'Length - 1;
Param := Last + 1; Param := Last + 1;
if Can_Have_Parameter (Switch) then if Can_Have_Parameter (Switch) then
-- Include potential parameter to the recursive call. -- Include potential parameter to the recursive call.
-- Only numbers are allowed. -- Only numbers are allowed.
...@@ -1989,8 +2015,10 @@ package body GNAT.Command_Line is ...@@ -1989,8 +2015,10 @@ package body GNAT.Command_Line is
-- First determine if the switch corresponds to one belonging to the -- First determine if the switch corresponds to one belonging to the
-- configuration. If so, run callback and exit. -- configuration. If so, run callback and exit.
Foreach_In_Config (Config, Section); -- ??? Is this necessary. On simple tests, we seem to have the same
-- results with or without this call.
Foreach_In_Config (Config, Section);
if Found_In_Config then if Found_In_Config then
return; return;
end if; end if;
...@@ -2127,10 +2155,17 @@ package body GNAT.Command_Line is ...@@ -2127,10 +2155,17 @@ package body GNAT.Command_Line is
Param : String; Param : String;
Index : Integer) Index : Integer)
is is
pragma Unreferenced (Index);
Sep : Character; Sep : Character;
begin begin
if Index = -1
and then Cmd.Config /= null
and then not Cmd.Config.Star_Switch
then
raise Invalid_Switch
with "Invalid switch " & Simple;
end if;
if Separator = "" then if Separator = "" then
Sep := ASCII.NUL; Sep := ASCII.NUL;
else else
...@@ -2808,13 +2843,8 @@ package body GNAT.Command_Line is ...@@ -2808,13 +2843,8 @@ package body GNAT.Command_Line is
if Iter.List = null then if Iter.List = null then
Iter.Current := Integer'Last; Iter.Current := Integer'Last;
else else
Iter.Current := Iter.List'First; Iter.Current := Iter.List'First - 1;
Next (Iter);
while Iter.Current <= Iter.List'Last
and then Iter.List (Iter.Current) = null
loop
Iter.Current := Iter.Current + 1;
end loop;
end if; end if;
end Start; end Start;
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- S p e c -- -- S p e c --
-- -- -- --
-- Copyright (C) 1999-2010, AdaCore -- -- Copyright (C) 1999-2011, AdaCore --
-- -- -- --
-- 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- --
...@@ -583,6 +583,10 @@ package GNAT.Command_Line is ...@@ -583,6 +583,10 @@ package GNAT.Command_Line is
-- assumed that the remainder of the switch ("uv") is a set of characters -- assumed that the remainder of the switch ("uv") is a set of characters
-- whose order is irrelevant. In fact, this package will sort them -- whose order is irrelevant. In fact, this package will sort them
-- alphabetically. -- alphabetically.
-- When grouping switches that accept arguments (for instance "-gnatyL!"
-- as the definition, and "-gnatyaL12b" as the command line), only
-- numerical arguments are accepted. The above is equivalent to
-- "-gnatya -gnatyL12 -gnatyb".
procedure Define_Switch procedure Define_Switch
(Config : in out Command_Line_Configuration; (Config : in out Command_Line_Configuration;
...@@ -768,7 +772,9 @@ package GNAT.Command_Line is ...@@ -768,7 +772,9 @@ package GNAT.Command_Line is
Config : Command_Line_Configuration); Config : Command_Line_Configuration);
function Get_Configuration function Get_Configuration
(Cmd : Command_Line) return Command_Line_Configuration; (Cmd : Command_Line) return Command_Line_Configuration;
-- Set or retrieve the configuration used for that command line -- Set or retrieve the configuration used for that command line.
-- The Config must have been initialized first, by calling one of the
-- Define_Switches subprograms.
procedure Set_Command_Line procedure Set_Command_Line
(Cmd : in out Command_Line; (Cmd : in out Command_Line;
...@@ -781,6 +787,8 @@ package GNAT.Command_Line is ...@@ -781,6 +787,8 @@ package GNAT.Command_Line is
-- The parsing of Switches is done through calls to Getopt, by passing -- The parsing of Switches is done through calls to Getopt, by passing
-- Getopt_Description as an argument. (A "*" is automatically prepended so -- Getopt_Description as an argument. (A "*" is automatically prepended so
-- that all switches and command line arguments are accepted). -- that all switches and command line arguments are accepted).
-- If a config was defined via Set_Configuration, the Getopt_Description
-- parameter will be ignored.
-- --
-- To properly handle switches that take parameters, you should document -- To properly handle switches that take parameters, you should document
-- them in Getopt_Description. Otherwise, the switch and its parameter will -- them in Getopt_Description. Otherwise, the switch and its parameter will
...@@ -792,6 +800,12 @@ package GNAT.Command_Line is ...@@ -792,6 +800,12 @@ package GNAT.Command_Line is
-- should be listed in the Sections parameter (as "-bargs -cargs"). -- should be listed in the Sections parameter (as "-bargs -cargs").
-- --
-- This function can be used to reset Cmd by passing an empty string. -- This function can be used to reset Cmd by passing an empty string.
--
-- If an invalid switch is found on the command line (ie wasn't defined in
-- the configuration via Define_Switch), and the configuration wasn't set
-- to accept all switches (by defining "*" as a valid switch), then an
-- exception Invalid_Switch is raised. The exception message indicates the
-- invalid switch.
procedure Add_Switch procedure Add_Switch
(Cmd : in out Command_Line; (Cmd : in out Command_Line;
...@@ -1084,6 +1098,11 @@ private ...@@ -1084,6 +1098,11 @@ private
Sections : GNAT.OS_Lib.Argument_List_Access; Sections : GNAT.OS_Lib.Argument_List_Access;
-- The list of sections -- The list of sections
Star_Switch : Boolean := False;
-- Whether switches not described in this configuration should be
-- returned to the user (True). If False, an exception Invalid_Switch
-- is raised.
Aliases : Alias_Definitions_List; Aliases : Alias_Definitions_List;
Usage : GNAT.OS_Lib.String_Access; Usage : GNAT.OS_Lib.String_Access;
Help : GNAT.OS_Lib.String_Access; Help : GNAT.OS_Lib.String_Access;
......
...@@ -411,6 +411,8 @@ package body Make is ...@@ -411,6 +411,8 @@ package body Make is
-- Delete all temp files created by Gnatmake and call Osint.Fail, with the -- Delete all temp files created by Gnatmake and call Osint.Fail, with the
-- parameter S (see osint.ads). This is called from the Prj hierarchy and -- parameter S (see osint.ads). This is called from the Prj hierarchy and
-- the MLib hierarchy. -- the MLib hierarchy.
-- This subprogram also prints current error messages on stdout (ie
-- finalizes errout)
-------------------------- --------------------------
-- Obsolete Executables -- -- Obsolete Executables --
...@@ -795,15 +797,6 @@ package body Make is ...@@ -795,15 +797,6 @@ package body Make is
-- mappings, when using project file(s). The out parameter File_Index is -- mappings, when using project file(s). The out parameter File_Index is
-- the index to the name of the file in the array The_Mapping_File_Names. -- the index to the name of the file in the array The_Mapping_File_Names.
procedure Delete_Temp_Config_Files;
-- Delete all temporary config files. Must not be called if Debug_Flag_N
-- is False.
procedure Delete_All_Temp_Files;
-- Delete all temp files (config files, mapping files, path files), unless
-- Debug_Flag_N is True (in which case all temp files are left for user
-- examination).
------------------------------------------------- -------------------------------------------------
-- Subprogram declarations moved from the spec -- -- Subprogram declarations moved from the spec --
------------------------------------------------- -------------------------------------------------
...@@ -1267,7 +1260,6 @@ package body Make is ...@@ -1267,7 +1260,6 @@ package body Make is
""" is not a gnatmake switch. Consider moving " & """ is not a gnatmake switch. Consider moving " &
"it to Global_Compilation_Switches.", "it to Global_Compilation_Switches.",
Element.Location); Element.Location);
Errutil.Finalize;
Make_Failed ("*** illegal switch """ & Argv & """"); Make_Failed ("*** illegal switch """ & Argv & """");
end if; end if;
end; end;
...@@ -3719,7 +3711,7 @@ package body Make is ...@@ -3719,7 +3711,7 @@ package body Make is
-- Delete any temporary configuration pragma file -- Delete any temporary configuration pragma file
if not Debug.Debug_Flag_N then if not Debug.Debug_Flag_N then
Delete_Temp_Config_Files; Delete_Temp_Config_Files (Project_Tree);
end if; end if;
end Compile_Sources; end Compile_Sources;
...@@ -3911,53 +3903,6 @@ package body Make is ...@@ -3911,53 +3903,6 @@ package body Make is
Debug_Msg (S, Name_Id (N)); Debug_Msg (S, Name_Id (N));
end Debug_Msg; end Debug_Msg;
---------------------------
-- Delete_All_Temp_Files --
---------------------------
procedure Delete_All_Temp_Files is
begin
if not Debug.Debug_Flag_N then
Delete_Temp_Config_Files;
Prj.Delete_All_Temp_Files (Project_Tree.Shared);
end if;
end Delete_All_Temp_Files;
------------------------------
-- Delete_Temp_Config_Files --
------------------------------
procedure Delete_Temp_Config_Files is
Success : Boolean;
Proj : Project_List;
pragma Warnings (Off, Success);
begin
-- The caller is responsible for ensuring that Debug_Flag_N is False
pragma Assert (not Debug.Debug_Flag_N);
if Main_Project /= No_Project then
Proj := Project_Tree.Projects;
while Proj /= null loop
if Proj.Project.Config_File_Temp then
Delete_Temporary_File
(Project_Tree.Shared, Proj.Project.Config_File_Name);
-- Make sure that we don't have a config file for this project,
-- in case there are several mains. In this case, we will
-- recreate another config file: we cannot reuse the one that
-- we just deleted!
Proj.Project.Config_Checked := False;
Proj.Project.Config_File_Name := No_Path;
Proj.Project.Config_File_Temp := False;
end if;
Proj := Proj.Next;
end loop;
end if;
end Delete_Temp_Config_Files;
------------- -------------
-- Display -- -- Display --
------------- -------------
...@@ -4470,8 +4415,7 @@ package body Make is ...@@ -4470,8 +4415,7 @@ package body Make is
Write_Line (": no sources to compile"); Write_Line (": no sources to compile");
end if; end if;
Delete_All_Temp_Files; Finish_Program (Project_Tree, E_Success);
Exit_Program (E_Success);
end if; end if;
end if; end if;
...@@ -4619,8 +4563,7 @@ package body Make is ...@@ -4619,8 +4563,7 @@ package body Make is
Bind => Bind_Only, Bind => Bind_Only,
Link => Link_Only); Link => Link_Only);
Delete_All_Temp_Files; Finish_Program (Project_Tree, E_Success);
Exit_Program (E_Success);
else else
-- Call Get_Target_Parameters to ensure that VM_Target and -- Call Get_Target_Parameters to ensure that VM_Target and
...@@ -4631,7 +4574,7 @@ package body Make is ...@@ -4631,7 +4574,7 @@ package body Make is
-- Output usage information if no files to compile -- Output usage information if no files to compile
Usage; Usage;
Exit_Program (E_Fatal); Finish_Program (Project_Tree, E_Success);
end if; end if;
end if; end if;
...@@ -4809,7 +4752,6 @@ package body Make is ...@@ -4809,7 +4752,6 @@ package body Make is
"Global_Compilation_Switches. Use Switches instead.", "Global_Compilation_Switches. Use Switches instead.",
Project_Tree.Shared.Arrays.Table Project_Tree.Shared.Arrays.Table
(Default_Switches_Array).Location); (Default_Switches_Array).Location);
Errutil.Finalize;
Make_Failed Make_Failed
("*** illegal combination of Builder attributes"); ("*** illegal combination of Builder attributes");
end if; end if;
...@@ -6505,14 +6447,7 @@ package body Make is ...@@ -6505,14 +6447,7 @@ package body Make is
Report_Compilation_Failed; Report_Compilation_Failed;
end if; end if;
-- Delete the temporary mapping file that was created if we are Finish_Program (Project_Tree, E_Success);
-- using project files.
Delete_All_Temp_Files;
-- Output Namet statistics
Namet.Finalize;
exception exception
when X : others => when X : others =>
...@@ -7292,8 +7227,7 @@ package body Make is ...@@ -7292,8 +7227,7 @@ package body Make is
procedure Make_Failed (S : String) is procedure Make_Failed (S : String) is
begin begin
Delete_All_Temp_Files; Fail_Program (Project_Tree, S);
Osint.Fail (S);
end Make_Failed; end Make_Failed;
-------------------- --------------------
...@@ -7531,8 +7465,7 @@ package body Make is ...@@ -7531,8 +7465,7 @@ package body Make is
procedure Report_Compilation_Failed is procedure Report_Compilation_Failed is
begin begin
Delete_All_Temp_Files; Fail_Program (Project_Tree, "");
Exit_Program (E_Fatal);
end Report_Compilation_Failed; end Report_Compilation_Failed;
------------------------ ------------------------
...@@ -7552,10 +7485,7 @@ package body Make is ...@@ -7552,10 +7485,7 @@ package body Make is
Kill (Running_Compile (J).Pid, SIGINT, 1); Kill (Running_Compile (J).Pid, SIGINT, 1);
end loop; end loop;
Delete_All_Temp_Files; Finish_Program (Project_Tree, E_No_Compile);
OS_Exit (1);
-- ??? OS_Exit (1) is equivalent to Exit_Program (E_No_Compile),
-- shouldn't that be Exit_Program (E_Abort) instead?
end Sigint_Intercepted; end Sigint_Intercepted;
------------------- -------------------
......
...@@ -30,7 +30,8 @@ ...@@ -30,7 +30,8 @@
with ALI; with ALI;
with Namet; use Namet; with Namet; use Namet;
with Opt; with Opt;
with Prj; use Prj; with Osint;
with Prj; use Prj;
with Prj.Tree; with Prj.Tree;
with Types; use Types; with Types; use Types;
...@@ -111,6 +112,13 @@ package Makeutl is ...@@ -111,6 +112,13 @@ package Makeutl is
-- source files are still associated with the same units). Return True -- source files are still associated with the same units). Return True
-- if everything is still valid. -- if everything is still valid.
function Is_Subunit (Source : Source_Id) return Boolean;
-- Return True if source is a subunit
procedure Initialize_Source_Record (Source : Source_Id);
-- Get information either about the source file, the object and
-- dependency file, as well as their timestamps. This includes timestamps.
function Is_External_Assignment function Is_External_Assignment
(Env : Prj.Tree.Environment; (Env : Prj.Tree.Environment;
Argv : String) return Boolean; Argv : String) return Boolean;
...@@ -204,6 +212,24 @@ package Makeutl is ...@@ -204,6 +212,24 @@ package Makeutl is
function Path_Or_File_Name (Path : Path_Name_Type) return String; function Path_Or_File_Name (Path : Path_Name_Type) return String;
-- Returns a file name if -df is used, otherwise return a path name -- Returns a file name if -df is used, otherwise return a path name
-------------------------
-- Program termination --
-------------------------
procedure Fail_Program
(Project_Tree : Project_Tree_Ref;
S : String;
Flush_Messages : Boolean := True);
-- Terminate program with a message and a fatal status code
procedure Finish_Program
(Project_Tree : Project_Tree_Ref;
Exit_Code : Osint.Exit_Code_Type := Osint.E_Success;
S : String := "");
-- Terminate program, with or without a message, setting the status code
-- according to Fatal.
-- This properly removes all temporary files
----------- -----------
-- Mains -- -- Mains --
----------- -----------
...@@ -215,38 +241,62 @@ package Makeutl is ...@@ -215,38 +241,62 @@ package Makeutl is
-- Mains are stored in a table. An index is used to retrieve the mains -- Mains are stored in a table. An index is used to retrieve the mains
-- from the table. -- from the table.
package Mains is type Main_Info is record
File : File_Name_Type; -- Always canonical casing
procedure Add_Main (Name : String); Index : Int := 0;
-- Add one main to the table Location : Source_Ptr := No_Location;
Source : Prj.Source_Id := No_Source;
end record;
No_Main_Info : constant Main_Info := (No_File, 0, No_Location, No_Source);
procedure Set_Index (Index : Int); package Mains is
procedure Add_Main
procedure Set_Location (Location : Source_Ptr); (Name : String;
-- Set the location of the last main added. By default, the location is Index : Int := 0;
-- No_Location. Location : Source_Ptr := No_Location);
-- Add one main to the table.
-- This is in general used to add the main files specified on the
-- command line.
-- Index is used for multi-unit source files, and indicates which unit
-- within the source is concerned.
-- Location is the location within the project file (if a project file
-- is used).
procedure Delete; procedure Delete;
-- Empty the table -- Empty the table
procedure Reset; procedure Reset;
-- Reset the index to the beginning of the table -- Reset the cursor to the beginning of the table
function Next_Main return String;
-- Increase the index and return the next main. If table is exhausted,
-- return an empty string.
function Get_Index return Int; procedure Set_Multi_Unit_Index
(Project_Tree : Project_Tree_Ref := null;
Index : Int := 0);
-- If a single main file was defined, this subprogram indicates which
-- unit inside it is the main (case of a multi-unit source files).
-- Errors are raised if zero or more than one main file was defined,
-- and Index is not 0.
-- This subprogram is used for the handling of the command line switch.
function Get_Location return Source_Ptr; function Next_Main return String;
-- Get the location of the current main function Next_Main return Main_Info;
-- Moves the cursor forward and returns the new current entry.
procedure Update_Main (Name : String); -- Returns No_File_And_Loc if there are no more mains in the table.
-- Update the file name of the current main
function Number_Of_Mains return Natural; function Number_Of_Mains return Natural;
-- Returns the number of mains added with Add_Main since the last call -- Returns the number of mains in the table.
-- to Delete.
procedure Fill_From_Project
(Root_Project : Project_Id;
Project_Tree : Project_Tree_Ref);
-- If no main was already added (presumably from the command line), add
-- the main units from root_project (or in the case of an aggregate
-- project from all the
-- aggregated projects).
--
-- If some main units were already added from the command line, check
-- that they all belong to the root project, and that they are full
-- full paths rather than (partial) base names (e.g. no body suffix was
-- specified).
end Mains; end Mains;
...@@ -308,6 +358,26 @@ package Makeutl is ...@@ -308,6 +358,26 @@ package Makeutl is
-- The second version returns False if the Source was already marked in -- The second version returns False if the Source was already marked in
-- the queue. -- the queue.
procedure Insert_Project_Sources
(Project : Project_Id;
Project_Tree : Project_Tree_Ref;
All_Projects : Boolean;
Unit_Based : Boolean);
-- Insert all the compilable sources of the project in the queue. If
-- All_Project is true, then all sources from imported projects are also
-- inserted.
-- When Unit_Based is True, put in the queue all compilable sources
-- including the unit based (Ada) one. When Unit_Based is False, put the
-- Ada sources only when they are in a library project.
procedure Insert_Withed_Sources_For
(The_ALI : ALI.ALI_Id;
Project_Tree : Project_Tree_Ref;
Excluding_Shared_SALs : Boolean := False);
-- Insert in the queue those sources withed by The_ALI, if there are not
-- already in the queue and Only_Interfaces is False or they are part of
-- the interfaces of their project.
procedure Extract procedure Extract
(Found : out Boolean; (Found : out Boolean;
Source : out Source_Info); Source : out Source_Info);
......
...@@ -144,6 +144,39 @@ package body Prj is ...@@ -144,6 +144,39 @@ package body Prj is
end if; end if;
end Delete_Temporary_File; end Delete_Temporary_File;
------------------------------
-- Delete_Temp_Config_Files --
------------------------------
procedure Delete_Temp_Config_Files (Project_Tree : Project_Tree_Ref) is
Success : Boolean;
Proj : Project_List;
pragma Warnings (Off, Success);
begin
if not Debug.Debug_Flag_N then
if Project_Tree /= null then
Proj := Project_Tree.Projects;
while Proj /= null loop
if Proj.Project.Config_File_Temp then
Delete_Temporary_File
(Project_Tree.Shared, Proj.Project.Config_File_Name);
-- Make sure that we don't have a config file for this
-- project, in case there are several mains. In this case,
-- we will recreate another config file: we cannot reuse the
-- one that we just deleted!
Proj.Project.Config_Checked := False;
Proj.Project.Config_File_Name := No_Path;
Proj.Project.Config_File_Temp := False;
end if;
Proj := Proj.Next;
end loop;
end if;
end if;
end Delete_Temp_Config_Files;
--------------------------- ---------------------------
-- Delete_All_Temp_Files -- -- Delete_All_Temp_Files --
--------------------------- ---------------------------
...@@ -493,7 +526,8 @@ package body Prj is ...@@ -493,7 +526,8 @@ package body Prj is
Project : Project_Id; Project : Project_Id;
In_Imported_Only : Boolean := False; In_Imported_Only : Boolean := False;
In_Extended_Only : Boolean := False; In_Extended_Only : Boolean := False;
Base_Name : File_Name_Type) return Source_Id Base_Name : File_Name_Type;
Index : Int := 0) return Source_Id
is is
Result : Source_Id := No_Source; Result : Source_Id := No_Source;
...@@ -517,7 +551,9 @@ package body Prj is ...@@ -517,7 +551,9 @@ package body Prj is
begin begin
Iterator := For_Each_Source (In_Tree => Tree, Project => Proj); Iterator := For_Each_Source (In_Tree => Tree, Project => Proj);
while Element (Iterator) /= No_Source loop while Element (Iterator) /= No_Source loop
if Element (Iterator).File = Base_Name then if Element (Iterator).File = Base_Name
and then (Index = 0 or else Element (Iterator).Index = Index)
then
Src := Element (Iterator); Src := Element (Iterator);
return; return;
end if; end if;
......
...@@ -1380,11 +1380,13 @@ package Prj is ...@@ -1380,11 +1380,13 @@ package Prj is
Project : Project_Id; Project : Project_Id;
In_Imported_Only : Boolean := False; In_Imported_Only : Boolean := False;
In_Extended_Only : Boolean := False; In_Extended_Only : Boolean := False;
Base_Name : File_Name_Type) return Source_Id; Base_Name : File_Name_Type;
Index : Int := 0) return Source_Id;
-- Find the first source file with the given name either in the whole tree -- Find the first source file with the given name either in the whole tree
-- (if In_Imported_Only is False) or in the projects imported or extended -- (if In_Imported_Only is False) or in the projects imported or extended
-- by Project otherwise. In_Extended_Only implies In_Imported_Only, and -- by Project otherwise. In_Extended_Only implies In_Imported_Only, and
-- will only look in Project and the projects it extends -- will only look in Project and the projects it extends.
-- If Index is specified, this only search for a source with that index.
----------------------- -----------------------
-- Project_Tree_Data -- -- Project_Tree_Data --
...@@ -1647,6 +1649,12 @@ package Prj is ...@@ -1647,6 +1649,12 @@ package Prj is
-- Delete all recorded temporary files. -- Delete all recorded temporary files.
-- Does nothing if Debug.Debug_Flag_N is set -- Does nothing if Debug.Debug_Flag_N is set
procedure Delete_Temp_Config_Files (Project_Tree : Project_Tree_Ref);
-- Delete all temporary config files.
-- Does nothing if Debug.Debug_Flag_N is set or if Project_Tree is null.
-- This initially came from gnatmake
-- ??? Should this be combined with Delete_All_Temp_Files above
procedure Delete_Temporary_File procedure Delete_Temporary_File
(Shared : Shared_Project_Tree_Data_Access := null; (Shared : Shared_Project_Tree_Data_Access := null;
Path : Path_Name_Type); Path : Path_Name_Type);
......
...@@ -1524,15 +1524,21 @@ package body Sem_Ch4 is ...@@ -1524,15 +1524,21 @@ package body Sem_Ch4 is
Else_Expr := Next (Then_Expr); Else_Expr := Next (Then_Expr);
-- In ALFA, conditional expressions are allowed: -- In ALFA, boolean conditional expressions are allowed:
-- * if they have no ELSE part, in which case the expression is -- * if they have no ELSE part, in which case the expression is
-- equivalent to -- equivalent to
-- NOT Condition OR ELSE Then_Expr -- NOT Condition OR ELSE Then_Expr
-- * in pre- and postconditions, where the Condition cannot have side- -- * in pre- and postconditions, where the Condition cannot have side-
-- effects (in ALFA) and thus the expression is equivalent to -- effects (in ALFA) and thus the expression is equivalent to
-- (Condition AND THEN Then_Expr) -- (Condition AND THEN Then_Expr)
-- and (NOT Condition AND THEN Then_Expr) -- and (NOT Condition AND THEN Then_Expr)
-- Non-boolean conditional expressions are marked as not in ALFA during
-- resolution.
if Present (Else_Expr) and then not In_Pre_Post_Expression then if Present (Else_Expr) and then not In_Pre_Post_Expression then
Mark_Non_ALFA_Subprogram; Mark_Non_ALFA_Subprogram;
end if; end if;
......
...@@ -5860,6 +5860,10 @@ package body Sem_Res is ...@@ -5860,6 +5860,10 @@ package body Sem_Res is
Append_To (Expressions (N), Error); Append_To (Expressions (N), Error);
end if; end if;
if Root_Type (Typ) /= Standard_Boolean then
Mark_Non_ALFA_Subprogram;
end if;
Set_Etype (N, Typ); Set_Etype (N, Typ);
Eval_Conditional_Expression (N); Eval_Conditional_Expression (N);
end Resolve_Conditional_Expression; end Resolve_Conditional_Expression;
......
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