Commit 38ef8ebe by Arnaud Charlet

[multiple changes]

2010-10-12  Javier Miranda  <miranda@adacore.com>

	* sem_ch6.adb (New_Overloaded_Entity): Add missing decoration of
	attribute Overridden_Operation in predefined dispatching primitives. 

2010-10-12  Emmanuel Briot  <briot@adacore.com>

	* g-comlin.adb, g-comlin.ads (Add_Switch): Raise an exception when a
	command line configuration exists and we specify an invalid section.

From-SVN: r165368
parent 3c971dcc
2010-10-12 Javier Miranda <miranda@adacore.com>
* sem_ch6.adb (New_Overloaded_Entity): Add missing decoration of
attribute Overridden_Operation in predefined dispatching primitives.
2010-10-12 Emmanuel Briot <briot@adacore.com>
* g-comlin.adb, g-comlin.ads (Add_Switch): Raise an exception when a
command line configuration exists and we specify an invalid section.
2010-10-12 Robert Dewar <dewar@adacore.com> 2010-10-12 Robert Dewar <dewar@adacore.com>
* sem_ch6.adb (Process_PPCs): Fix error in inheriting Pre'Class when no * sem_ch6.adb (Process_PPCs): Fix error in inheriting Pre'Class when no
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
-- -- -- --
-- B o d y -- -- B o d y --
-- -- -- --
-- Copyright (C) 1999-2009, Free Software Foundation, Inc. -- -- Copyright (C) 1999-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- --
...@@ -1755,7 +1755,21 @@ package body GNAT.Command_Line is ...@@ -1755,7 +1755,21 @@ package body GNAT.Command_Line is
-- Start of processing for Add_Switch -- Start of processing for Add_Switch
Section_Valid : Boolean := False;
begin begin
if Section /= "" and then Cmd.Config /= null then
for S in Cmd.Config.Sections'Range loop
if Section = Cmd.Config.Sections (S).all then
Section_Valid := True;
exit;
end if;
end loop;
if not Section_Valid then
raise Invalid_Section;
end if;
end if;
Success := False; Success := False;
Add_Simple_Switches (Cmd, Switch, Parameter); Add_Simple_Switches (Cmd, Switch, Parameter);
Free (Cmd.Coalesce); Free (Cmd.Coalesce);
...@@ -2252,7 +2266,7 @@ package body GNAT.Command_Line is ...@@ -2252,7 +2266,7 @@ package body GNAT.Command_Line is
procedure Start procedure Start
(Cmd : in out Command_Line; (Cmd : in out Command_Line;
Iter : in out Command_Line_Iterator; Iter : in out Command_Line_Iterator;
Expanded : Boolean) Expanded : Boolean := False)
is is
begin begin
if Cmd.Expanded = null then if Cmd.Expanded = null then
......
...@@ -33,8 +33,9 @@ ...@@ -33,8 +33,9 @@
-- High level package for command line parsing and manipulation -- High level package for command line parsing and manipulation
-- Parsing the command line --------------------------------------
-- ======================== -- Simple parsing of the command line
--------------------------------------
-- This package provides an interface for parsing command line arguments, -- This package provides an interface for parsing command line arguments,
-- when they are either read from Ada.Command_Line or read from a string list. -- when they are either read from Ada.Command_Line or read from a string list.
...@@ -81,6 +82,10 @@ ...@@ -81,6 +82,10 @@
-- when Invalid_Parameter => Put_Line ("No parameter for " & Full_Switch); -- when Invalid_Parameter => Put_Line ("No parameter for " & Full_Switch);
-- end; -- end;
-------------
-- Sections
-------------
-- A more complicated example would involve the use of sections for the -- A more complicated example would involve the use of sections for the
-- switches, as for instance in gnatmake. The same command line is used to -- switches, as for instance in gnatmake. The same command line is used to
-- provide switches for several tools. Each tool recognizes its switches by -- provide switches for several tools. Each tool recognizes its switches by
...@@ -106,6 +111,10 @@ ...@@ -106,6 +111,10 @@
-- end loop; -- end loop;
-- end; -- end;
------------------------------
-- Parsing a list of strings
------------------------------
-- The examples above show how to parse the command line when the arguments -- The examples above show how to parse the command line when the arguments
-- are read directly from Ada.Command_Line. However, these arguments can also -- are read directly from Ada.Command_Line. However, these arguments can also
-- be read from a list of strings. This can be useful in several contexts, -- be read from a list of strings. This can be useful in several contexts,
...@@ -132,9 +141,10 @@ ...@@ -132,9 +141,10 @@
-- end loop; -- end loop;
-- Free (Parser); -- Free (Parser);
-- end; -- end;
--
----------------------------------------------
-- Creating and manipulating the command line -- Creating and manipulating the command line
-- =========================================== ----------------------------------------------
-- This package provides mechanisms to create and modify command lines by -- This package provides mechanisms to create and modify command lines by
-- adding or removing arguments from them. The resulting command line is kept -- adding or removing arguments from them. The resulting command line is kept
...@@ -204,13 +214,14 @@ ...@@ -204,13 +214,14 @@
-- This is done by passing an extra argument to Add_Switch, as in: -- This is done by passing an extra argument to Add_Switch, as in:
-- Add_Switch (Cmd, "-foo", "arg1"); -- Add_Switch (Cmd, "-foo", Parameter => "arg1");
-- This ensures that "arg1" will always be treated as the argument to -foo, -- This ensures that "arg1" will always be treated as the argument to -foo,
-- and will not be grouped with other parts of the command line. -- and will not be grouped with other parts of the command line.
---------------------------------------------------
-- Parsing the command line with grouped arguments -- Parsing the command line with grouped arguments
-- =============================================== ---------------------------------------------------
-- The command line construction facility can also be used in conjunction with -- The command line construction facility can also be used in conjunction with
-- Getopt to interpret a command line. For example when implementing the tool -- Getopt to interpret a command line. For example when implementing the tool
...@@ -230,8 +241,10 @@ ...@@ -230,8 +241,10 @@
-- Start (Cmd, Iter, Expanded => True); -- Start (Cmd, Iter, Expanded => True);
-- while Has_More (Iter) loop -- while Has_More (Iter) loop
-- if Current_Switch (Iter) = "-gnatwu" then .. -- if Current_Switch (Iter) = "-gnatwu" then
-- elsif Current_Switch (Iter) = "-gnatwv" then ... -- ...
-- elsif Current_Switch (Iter) = "-gnatwv" then
-- ...
-- end if; -- end if;
-- Next (Iter); -- Next (Iter);
-- end loop; -- end loop;
...@@ -444,6 +457,24 @@ package GNAT.Command_Line is ...@@ -444,6 +457,24 @@ package GNAT.Command_Line is
-- the parameter were concatenated. A space is returned if the switch and -- the parameter were concatenated. A space is returned if the switch and
-- its argument were in two separate arguments. -- its argument were in two separate arguments.
Invalid_Section : exception;
-- Raised when an invalid section is selected by Goto_Section
Invalid_Switch : exception;
-- Raised when an invalid switch is detected in the command line
Invalid_Parameter : exception;
-- Raised when a parameter is missing, or an attempt is made to obtain a
-- parameter for a switch that does not allow a parameter
-----------------------------------------
-- Expansion of command line arguments --
-----------------------------------------
-- These subprograms take care of of expanding globbing patterns on the
-- command line. On Unix, such expansion is done by the shell before your
-- application is called. But on Windows you must do this expansion
-- yourself.
type Expansion_Iterator is limited private; type Expansion_Iterator is limited private;
-- Type used during expansion of file names -- Type used during expansion of file names
...@@ -475,19 +506,16 @@ package GNAT.Command_Line is ...@@ -475,19 +506,16 @@ package GNAT.Command_Line is
-- If Expansion is called again after an empty string has been returned, -- If Expansion is called again after an empty string has been returned,
-- then the exception GNAT.Directory_Operations.Directory_Error is raised. -- then the exception GNAT.Directory_Operations.Directory_Error is raised.
Invalid_Section : exception;
-- Raised when an invalid section is selected by Goto_Section
Invalid_Switch : exception;
-- Raised when an invalid switch is detected in the command line
Invalid_Parameter : exception;
-- Raised when a parameter is missing, or an attempt is made to obtain a
-- parameter for a switch that does not allow a parameter
----------------- -----------------
-- Configuring -- -- Configuring --
----------------- -----------------
-- The following subprograms are used to manipulate a command line
-- represented as a string (for instance "-g -O2"), as well as parsing
-- the switches from such a string. They provide high-level configurations
-- to define aliases (a switch is equivalent to one or more other switches)
-- or grouping of switches ("-gnatyac" is equivalent to "-gnatya" and
-- "-gnatyc").
-- See the top of this file for examples on how to use these subprograms
type Command_Line_Configuration is private; type Command_Line_Configuration is private;
...@@ -499,9 +527,6 @@ package GNAT.Command_Line is ...@@ -499,9 +527,6 @@ package GNAT.Command_Line is
-- be expanded as Expanded. For instance, for the GNAT compiler switches, -- be expanded as Expanded. For instance, for the GNAT compiler switches,
-- we would define "-gnatwa" as an alias for "-gnatwcfijkmopruvz", ie some -- we would define "-gnatwa" as an alias for "-gnatwcfijkmopruvz", ie some
-- default warnings to be activated. -- default warnings to be activated.
--
-- Likewise, in some context you could define "--verbose" as an alias for
-- ("-v", "--full"), ie two switches.
procedure Define_Prefix procedure Define_Prefix
(Config : in out Command_Line_Configuration; (Config : in out Command_Line_Configuration;
...@@ -537,20 +562,25 @@ package GNAT.Command_Line is ...@@ -537,20 +562,25 @@ package GNAT.Command_Line is
procedure Free (Config : in out Command_Line_Configuration); procedure Free (Config : in out Command_Line_Configuration);
-- Free the memory used by Config -- Free the memory used by Config
------------- ------------------------------
-- Editing -- -- Generating command lines --
------------- ------------------------------
-- Once the command line configuration has been created, you can build your
-- own command line. This will be done in general because you need to spawn
-- external tools from your application.
-- Although it could be done by concatenating strings, the following
-- subprograms will properly take care of grouping switches when possible,
-- so as to keep the command line as short as possible. They also provide a
-- way to remove a switch from an existing command line.
type Command_Line is private; type Command_Line is private;
procedure Set_Configuration procedure Set_Configuration
(Cmd : in out Command_Line; (Cmd : in out Command_Line;
Config : Command_Line_Configuration); Config : Command_Line_Configuration);
-- Set the configuration for this command line
function Get_Configuration function Get_Configuration
(Cmd : Command_Line) return Command_Line_Configuration; (Cmd : Command_Line) return Command_Line_Configuration;
-- Return the configuration used for that command line -- Set or retrieve the configuration used for that command line
procedure Set_Command_Line procedure Set_Command_Line
(Cmd : in out Command_Line; (Cmd : in out Command_Line;
...@@ -608,7 +638,10 @@ package GNAT.Command_Line is ...@@ -608,7 +638,10 @@ package GNAT.Command_Line is
-- If the switch is part of a section, then it should be specified so that -- If the switch is part of a section, then it should be specified so that
-- the switch is correctly placed in the command line, and the section -- the switch is correctly placed in the command line, and the section
-- added if not already present. For example, to add the -g switch into the -- added if not already present. For example, to add the -g switch into the
-- -cargs section, you need to pass (Cmd, "-g", Section => "-cargs"). -- -cargs section, you need to call (Cmd, "-g", Section => "-cargs").
--
-- Invalid_Section is raised if Section was not defined in the
-- configuration of the command line.
-- --
-- Add_Before allows insertion of the switch at the beginning of the -- Add_Before allows insertion of the switch at the beginning of the
-- command line. -- command line.
...@@ -672,13 +705,15 @@ package GNAT.Command_Line is ...@@ -672,13 +705,15 @@ package GNAT.Command_Line is
--------------- ---------------
-- Iteration -- -- Iteration --
--------------- ---------------
-- When a command line was created with the above, you can then iterate
-- over its contents using the following iterator.
type Command_Line_Iterator is private; type Command_Line_Iterator is private;
procedure Start procedure Start
(Cmd : in out Command_Line; (Cmd : in out Command_Line;
Iter : in out Command_Line_Iterator; Iter : in out Command_Line_Iterator;
Expanded : Boolean); Expanded : Boolean := False);
-- Start iterating over the command line arguments. If Expanded is true, -- Start iterating over the command line arguments. If Expanded is true,
-- then the arguments are not grouped and no alias is used. For instance, -- then the arguments are not grouped and no alias is used. For instance,
-- "-gnatwv" and "-gnatwu" would be returned instead of "-gnatwuv". -- "-gnatwv" and "-gnatwu" would be returned instead of "-gnatwuv".
......
...@@ -8103,12 +8103,13 @@ package body Sem_Ch6 is ...@@ -8103,12 +8103,13 @@ package body Sem_Ch6 is
Check_Overriding_Indicator (S, E, Is_Primitive => True); Check_Overriding_Indicator (S, E, Is_Primitive => True);
-- If S is a user-defined subprogram or a null procedure -- If S is a user-defined subprogram or a null procedure
-- expanded to override an inherited null procedure, then -- expanded to override an inherited null procedure, or a
-- indicate that E overrides the operation from which S -- predefined dispatching primitive then indicate that E
-- is inherited. It seems odd that Overridden_Operation -- overrides the operation from which S is inherited. It
-- isn't set in all cases where Is_Overriding_Operation -- seems odd that Overridden_Operation isn't set in all
-- is true, but doing so causes infinite loops in the -- cases where Is_Overriding_Operation is true, but doing
-- compiler for implicit overriding subprograms. ??? -- so causes infinite loops in the compiler for implicit
-- overriding subprograms. ???
if Comes_From_Source (S) if Comes_From_Source (S)
or else or else
...@@ -8117,6 +8118,10 @@ package body Sem_Ch6 is ...@@ -8117,6 +8118,10 @@ package body Sem_Ch6 is
Nkind (Parent (S)) = N_Procedure_Specification Nkind (Parent (S)) = N_Procedure_Specification
and then and then
Null_Present (Parent (S))) Null_Present (Parent (S)))
or else
(Present (Alias (E))
and then
Is_Predefined_Dispatching_Operation (Alias (E)))
then then
if Present (Alias (E)) then if Present (Alias (E)) then
Set_Overridden_Operation (S, Alias (E)); Set_Overridden_Operation (S, Alias (E));
......
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