Commit 1d57c04f by Arnaud Charlet

[multiple changes]

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

	* sem_ch13.adb (Check_Constant_Address_Clauses): Do not check legality
	of address clauses if if Ignore_Rep_Clauses is active.
	* freeze.adb (Check_Address_Clause): If Ignore_Rep_Clauses is active,
	remove address clause from tree so that it does not reach the backend.

2010-06-23  Arnaud Charlet  <charlet@adacore.com>

	* exp_attr.adb (Expand_N_Attribute_Reference [Attribute_Valid]): Do not
	expand 'Valid from user code in CodePeer mode, will be handled by the
	back-end directly.

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

	* g-comlin.ads: Minor comment improvements.

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

	* sem_res.adb (Uses_SS): The expression that initializes a controlled
	component of a record type may be a user-defined operator that is
	rewritten as a function call.

From-SVN: r161271
parent b91fccb3
2010-06-23 Ed Schonberg <schonberg@adacore.com>
* sem_ch13.adb (Check_Constant_Address_Clauses): Do not check legality
of address clauses if if Ignore_Rep_Clauses is active.
* freeze.adb (Check_Address_Clause): If Ignore_Rep_Clauses is active,
remove address clause from tree so that it does not reach the backend.
2010-06-23 Arnaud Charlet <charlet@adacore.com>
* exp_attr.adb (Expand_N_Attribute_Reference [Attribute_Valid]): Do not
expand 'Valid from user code in CodePeer mode, will be handled by the
back-end directly.
2010-06-23 Bob Duff <duff@adacore.com>
* g-comlin.ads: Minor comment improvements.
2010-06-23 Ed Schonberg <schonberg@adacore.com>
* sem_res.adb (Uses_SS): The expression that initializes a controlled
component of a record type may be a user-defined operator that is
rewritten as a function call.
2010-06-23 Bob Duff <duff@adacore.com> 2010-06-23 Bob Duff <duff@adacore.com>
* g-comlin.ads, sem_ch13.adb: Minor comment fix. * g-comlin.ads, sem_ch13.adb: Minor comment fix.
......
...@@ -4733,6 +4733,13 @@ package body Exp_Attr is ...@@ -4733,6 +4733,13 @@ package body Exp_Attr is
-- Start of processing for Attribute_Valid -- Start of processing for Attribute_Valid
begin begin
-- Do not expand sourced code 'Valid reference in CodePeer mode,
-- will be handled by the back-end directly.
if CodePeer_Mode and then Comes_From_Source (N) then
return;
end if;
-- Turn off validity checks. We do not want any implicit validity -- Turn off validity checks. We do not want any implicit validity
-- checks to intefere with the explicit check from the attribute -- checks to intefere with the explicit check from the attribute
......
...@@ -591,7 +591,36 @@ package body Freeze is ...@@ -591,7 +591,36 @@ package body Freeze is
end if; end if;
end if; end if;
if not Error_Posted (Expr) -- If Rep_Clauses are to be ignored, remove address clause from
-- list attached to entity, because it may be illegal for gigi,
-- for example by breaking order of elaboration..
if Ignore_Rep_Clauses then
declare
Rep : Node_Id;
begin
Rep := First_Rep_Item (E);
if Rep = Addr then
Set_First_Rep_Item (E, Next_Rep_Item (Addr));
else
while Present (Rep)
and then Next_Rep_Item (Rep) /= Addr
loop
Rep := Next_Rep_Item (Rep);
end loop;
end if;
if Present (Rep) then
Set_Next_Rep_Item (Rep, Next_Rep_Item (Addr));
end if;
end;
Rewrite (Addr, Make_Null_Statement (Sloc (E)));
elsif not Error_Posted (Expr)
and then not Needs_Finalization (Typ) and then not Needs_Finalization (Typ)
then then
Warn_Overlay (Expr, Typ, Name (Addr)); Warn_Overlay (Expr, Typ, Name (Addr));
......
...@@ -106,12 +106,12 @@ ...@@ -106,12 +106,12 @@
-- end loop; -- end loop;
-- end; -- end;
-- The example above have shown how to parse the command line when the -- The examples above show how to parse the command line when the arguments
-- arguments are read directly from Ada.Command_Line. However, these arguments -- are read directly from Ada.Command_Line. However, these arguments can also
-- can also be read from a list of strings. This can be useful in several -- be read from a list of strings. This can be useful in several contexts,
-- contexts, either because your system does not support Ada.Command_Line, or -- either because your system does not support Ada.Command_Line, or because
-- because you are manipulating other tools and creating their command line by -- you are manipulating other tools and creating their command lines by hand,
-- hand, or for any other reason. -- or for any other reason.
-- To create the list of strings, it is recommended to use -- To create the list of strings, it is recommended to use
-- GNAT.OS_Lib.Argument_String_To_List. -- GNAT.OS_Lib.Argument_String_To_List.
...@@ -140,10 +140,10 @@ ...@@ -140,10 +140,10 @@
-- adding or removing arguments from them. The resulting command line is kept -- adding or removing arguments from them. The resulting command line is kept
-- as short as possible by coalescing arguments whenever possible. -- as short as possible by coalescing arguments whenever possible.
-- Complex command lines can thus be constructed, for example from an GUI -- Complex command lines can thus be constructed, for example from a GUI
-- (although this package does not by itself depend upon any specific GUI -- (although this package does not by itself depend upon any specific GUI
-- toolkit). For instance, if you are configuring the command line to use -- toolkit). For instance, if you are configuring the command line to use when
-- when spawning a tool with the following characteristics: -- spawning a tool with the following characteristics:
-- * Specifying -gnatwa is the same as specifying -gnatwu -gnatwv, but -- * Specifying -gnatwa is the same as specifying -gnatwu -gnatwv, but
-- shorter and more readable -- shorter and more readable
...@@ -298,7 +298,7 @@ package GNAT.Command_Line is ...@@ -298,7 +298,7 @@ package GNAT.Command_Line is
-- as a switch (returned by getopt), otherwise it will be considered -- as a switch (returned by getopt), otherwise it will be considered
-- as a normal argument (returned by Get_Argument). -- as a normal argument (returned by Get_Argument).
-- --
-- If SECTION_DELIMITERS is set, then every following subprogram -- If Section_Delimiters is set, then every following subprogram
-- (Getopt and Get_Argument) will only operate within a section, which -- (Getopt and Get_Argument) will only operate within a section, which
-- is delimited by any of these delimiters or the end of the command line. -- is delimited by any of these delimiters or the end of the command line.
-- --
...@@ -306,9 +306,9 @@ package GNAT.Command_Line is ...@@ -306,9 +306,9 @@ package GNAT.Command_Line is
-- Initialize_Option_Scan (Section_Delimiters => "largs bargs cargs"); -- Initialize_Option_Scan (Section_Delimiters => "largs bargs cargs");
-- --
-- Arguments on command line : my_application -c -bargs -d -e -largs -f -- Arguments on command line : my_application -c -bargs -d -e -largs -f
-- This line is made of three section, the first one is the default one -- This line contains three sections, the first one is the default one
-- and includes only the '-c' switch, the second one is between -bargs -- and includes only the '-c' switch, the second one is between -bargs
-- and -largs and includes '-d -e' and the last one includes '-f' -- and -largs and includes '-d -e' and the last one includes '-f'.
procedure Free (Parser : in out Opt_Parser); procedure Free (Parser : in out Opt_Parser);
-- Free the memory used by the parser. Calling this is not mandatory for -- Free the memory used by the parser. Calling this is not mandatory for
...@@ -320,13 +320,15 @@ package GNAT.Command_Line is ...@@ -320,13 +320,15 @@ package GNAT.Command_Line is
-- Change the current section. The next Getopt or Get_Argument will start -- Change the current section. The next Getopt or Get_Argument will start
-- looking at the beginning of the section. An empty name ("") refers to -- looking at the beginning of the section. An empty name ("") refers to
-- the first section between the program name and the first section -- the first section between the program name and the first section
-- delimiter. If the section does not exist, then Invalid_Section is -- delimiter. If the section does not exist in Section_Delimiters, then
-- raised. -- Invalid_Section is raised. If the section does not appear on the command
-- line, then it is treated as an empty section.
function Full_Switch function Full_Switch
(Parser : Opt_Parser := Command_Line_Parser) return String; (Parser : Opt_Parser := Command_Line_Parser) return String;
-- Returns the full name of the last switch found (Getopt only returns -- Returns the full name of the last switch found (Getopt only returns the
-- the first character) -- first character). Does not include the Switch_Char ('-' by default),
-- unless the "*" option of Getopt is used (see below).
function Getopt function Getopt
(Switches : String; (Switches : String;
...@@ -336,13 +338,13 @@ package GNAT.Command_Line is ...@@ -336,13 +338,13 @@ package GNAT.Command_Line is
-- switch character followed by a character within Switches, casing being -- switch character followed by a character within Switches, casing being
-- significant). The result returned is the first character of the switch -- significant). The result returned is the first character of the switch
-- that is located. If there are no more switches in the current section, -- that is located. If there are no more switches in the current section,
-- returns ASCII.NUL. If Concatenate is True (by default), the switches -- returns ASCII.NUL. If Concatenate is True (the default), the switches do
-- does not need to be separated by spaces (they can be concatenated if -- not need to be separated by spaces (they can be concatenated if they do
-- they do not require an argument, e.g. -ab is the same as two separate -- not require an argument, e.g. -ab is the same as two separate arguments
-- arguments -a -b). -- -a -b).
-- --
-- Switches is a string of all the possible switches, separated by a -- Switches is a string of all the possible switches, separated by
-- space. A switch can be followed by one of the following characters: -- spaces. A switch can be followed by one of the following characters:
-- --
-- ':' The switch requires a parameter. There can optionally be a space -- ':' The switch requires a parameter. There can optionally be a space
-- on the command line between the switch and its parameter. -- on the command line between the switch and its parameter.
...@@ -389,14 +391,14 @@ package GNAT.Command_Line is ...@@ -389,14 +391,14 @@ package GNAT.Command_Line is
-- Example -- Example
-- Getopt ("* a b") -- Getopt ("* a b")
-- If the command line is '-a -c toto.o -b', Getopt will return -- If the command line is '-a -c toto.o -b', Getopt will return
-- successively 'a', '*', '*' and 'b'. When '*' is returned, -- successively 'a', '*', '*' and 'b', with Full_Switch returning
-- Full_Switch returns the corresponding item on the command line. -- "a", "-c", "toto.o", and "b".
-- --
-- When Getopt encounters an invalid switch, it raises the exception -- When Getopt encounters an invalid switch, it raises the exception
-- Invalid_Switch and sets Full_Switch to return the invalid switch. -- Invalid_Switch and sets Full_Switch to return the invalid switch.
-- When Getopt cannot find the parameter associated with a switch, it -- When Getopt cannot find the parameter associated with a switch, it
-- raises Invalid_Parameter, and sets Full_Switch to return the invalid -- raises Invalid_Parameter, and sets Full_Switch to return the invalid
-- switch character. -- switch.
-- --
-- Note: in case of ambiguity, e.g. switches a ab abc, then the longest -- Note: in case of ambiguity, e.g. switches a ab abc, then the longest
-- matching switch is returned. -- matching switch is returned.
...@@ -416,33 +418,31 @@ package GNAT.Command_Line is ...@@ -416,33 +418,31 @@ package GNAT.Command_Line is
function Get_Argument function Get_Argument
(Do_Expansion : Boolean := False; (Do_Expansion : Boolean := False;
Parser : Opt_Parser := Command_Line_Parser) return String; Parser : Opt_Parser := Command_Line_Parser) return String;
-- Returns the next element on the command line which is not a switch. -- Returns the next element on the command line that is not a switch. This
-- This function should not be called before Getopt has returned -- function should not be called before Getopt has returned ASCII.NUL.
-- ASCII.NUL.
-- --
-- If Expansion is True, then the parameter on the command line will be -- If Do_Expansion is True, then the parameter on the command line will
-- considered as a filename with wild cards, and will be expanded. The -- be considered as a filename with wild cards, and will be expanded. The
-- matching file names will be returned one at a time. When there are no -- matching file names will be returned one at a time. This is useful in
-- more arguments on the command line, this function returns an empty -- non-Unix systems for obtaining normal expansion of wild card references.
-- string. This is useful in non-Unix systems for obtaining normal -- When there are no more arguments on the command line, this function
-- expansion of wild card references. -- returns an empty string.
function Parameter function Parameter
(Parser : Opt_Parser := Command_Line_Parser) return String; (Parser : Opt_Parser := Command_Line_Parser) return String;
-- Returns the parameter associated with the last switch returned by -- Returns parameter associated with the last switch returned by Getopt.
-- Getopt. If no parameter was associated with the last switch, or no -- If no parameter was associated with the last switch, or no previous call
-- previous call has been made to Get_Argument, raises Invalid_Parameter. -- has been made to Get_Argument, raises Invalid_Parameter. If the last
-- If the last switch was associated with an optional argument and this -- switch was associated with an optional argument and this argument was
-- argument was not found on the command line, Parameter returns an empty -- not found on the command line, Parameter returns an empty string.
-- string.
function Separator function Separator
(Parser : Opt_Parser := Command_Line_Parser) return Character; (Parser : Opt_Parser := Command_Line_Parser) return Character;
-- The separator that was between the switch and its parameter. This is -- The separator that was between the switch and its parameter. This is
-- of little use in general, only if you want to know exactly what was on -- useful if you want to know exactly what was on the command line. This
-- the command line. This is in general a single character, set to -- is in general a single character, set to ASCII.NUL if the switch and
-- ASCII.NUL if the switch and the parameter were concatenated. A space is -- the parameter were concatenated. A space is returned if the switch and
-- returned if the switch and its argument were in two separate arguments. -- its argument were in two separate arguments.
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
...@@ -462,16 +462,15 @@ package GNAT.Command_Line is ...@@ -462,16 +462,15 @@ package GNAT.Command_Line is
-- Subdirectories of Directory will also be searched, up to one -- Subdirectories of Directory will also be searched, up to one
-- hundred levels deep. -- hundred levels deep.
-- --
-- When Start_Expansion has been called, function Expansion should be -- When Start_Expansion has been called, function Expansion should
-- called repeatedly until it returns an empty string, before -- be called repeatedly until it returns an empty string, before
-- Start_Expansion can be called again with the same Expansion_Iterator -- Start_Expansion can be called again with the same Expansion_Iterator
-- variable. -- variable.
function Expansion (Iterator : Expansion_Iterator) return String; function Expansion (Iterator : Expansion_Iterator) return String;
-- Returns the next file in the directory matching the parameters given -- Returns the next file in the directory matching the parameters given
-- to Start_Expansion and updates Iterator to point to the next entry. -- to Start_Expansion and updates Iterator to point to the next entry.
-- Returns an empty string when there is no more file in the directory -- Returns an empty string when there are no more files.
-- and its subdirectories.
-- --
-- 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.
...@@ -508,31 +507,31 @@ package GNAT.Command_Line is ...@@ -508,31 +507,31 @@ package GNAT.Command_Line is
(Config : in out Command_Line_Configuration; (Config : in out Command_Line_Configuration;
Prefix : String); Prefix : String);
-- Indicates that all switches starting with the given prefix should be -- Indicates that all switches starting with the given prefix should be
-- grouped. For instance, for the GNAT compiler we would define "-gnatw" -- grouped. For instance, for the GNAT compiler we would define "-gnatw" as
-- as a prefix, so that "-gnatwu -gnatwv" can be grouped into "-gnatwuv" -- a prefix, so that "-gnatwu -gnatwv" can be grouped into "-gnatwuv" It is
-- It is assume that the remaining of the switch ("uv") is a set of -- assumed that the remainder of the switch ("uv") is a set of characters
-- characters whose order is irrelevant. In fact, this package will sort -- whose order is irrelevant. In fact, this package will sort them
-- them alphabetically. -- alphabetically.
procedure Define_Switch procedure Define_Switch
(Config : in out Command_Line_Configuration; (Config : in out Command_Line_Configuration;
Switch : String); Switch : String);
-- Indicates a new switch. The format of this switch follows the getopt -- Indicates a new switch. The format of this switch follows the getopt
-- format (trailing ':', '?', etc for defining a switch with parameters). -- format (trailing ':', '?', etc for defining a switch with parameters).
-- The switches defined in the command_line_configuration object are used -- The switches defined in the Command_Line_Configuration object are used
-- when ungrouping switches with more that one character after the prefix. -- when ungrouping switches with more that one character after the prefix.
procedure Define_Section procedure Define_Section
(Config : in out Command_Line_Configuration; (Config : in out Command_Line_Configuration;
Section : String); Section : String);
-- Indicates a new switch section. Every switch belonging to the same -- Indicates a new switch section. All switches belonging to the same
-- section are ordered together, preceded by the section. They are placed -- section are ordered together, preceded by the section. They are placed
-- at the end of the command line (as in 'gnatmake somefile.adb -cargs -g') -- at the end of the command line (as in "gnatmake somefile.adb -cargs -g")
function Get_Switches function Get_Switches
(Config : Command_Line_Configuration; (Config : Command_Line_Configuration;
Switch_Char : Character) return String; Switch_Char : Character) return String;
-- Get the switches list as expected by getopt. This list is built using -- Get the switches list as expected by Getopt. This list is built using
-- all switches defined previously via Define_Switch above. -- all switches defined previously via Define_Switch above.
procedure Free (Config : in out Command_Line_Configuration); procedure Free (Config : in out Command_Line_Configuration);
...@@ -562,7 +561,7 @@ package GNAT.Command_Line is ...@@ -562,7 +561,7 @@ package GNAT.Command_Line is
-- version with Switches. -- version with Switches.
-- --
-- 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).
-- --
-- To properly handle switches that take parameters, you should document -- To properly handle switches that take parameters, you should document
...@@ -571,8 +570,8 @@ package GNAT.Command_Line is ...@@ -571,8 +570,8 @@ package GNAT.Command_Line is
-- Command_Line_Iterator (which might be fine depending on your -- Command_Line_Iterator (which might be fine depending on your
-- application). -- application).
-- --
-- If the command line has sections (such as -bargs -largs -cargs), then -- If the command line has sections (such as -bargs -cargs), then they
-- they 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.
...@@ -600,16 +599,16 @@ package GNAT.Command_Line is ...@@ -600,16 +599,16 @@ package GNAT.Command_Line is
-- to pass "--check=full" to Remove_Switch as well. -- to pass "--check=full" to Remove_Switch as well.
-- --
-- A Switch with a parameter will never be grouped with another switch to -- A Switch with a parameter will never be grouped with another switch to
-- avoid ambiguities as to who the parameter applies to. -- avoid ambiguities as to what the parameter applies to.
-- --
-- Separator is the character that goes between the switches and its -- Separator is the character that goes between the switches and its
-- parameter on the command line. If it is set to ASCII.NUL, then no -- parameter on the command line. If it is set to ASCII.NUL, then no
-- separator is applied, and they are concatenated -- separator is applied, and they are concatenated.
-- --
-- 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 call (Cmd, "-g", Section => "-cargs") -- -cargs section, you need to pass (Cmd, "-g", Section => "-cargs").
-- --
-- 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.
...@@ -667,6 +666,9 @@ package GNAT.Command_Line is ...@@ -667,6 +666,9 @@ package GNAT.Command_Line is
-- Remove a switch with a specific parameter. If Parameter is the empty -- Remove a switch with a specific parameter. If Parameter is the empty
-- string, then only a switch with no parameter will be removed. -- string, then only a switch with no parameter will be removed.
procedure Free (Cmd : in out Command_Line);
-- Free the memory used by Cmd
--------------- ---------------
-- Iteration -- -- Iteration --
--------------- ---------------
...@@ -703,9 +705,6 @@ package GNAT.Command_Line is ...@@ -703,9 +705,6 @@ package GNAT.Command_Line is
procedure Next (Iter : in out Command_Line_Iterator); procedure Next (Iter : in out Command_Line_Iterator);
-- Move to the next switch -- Move to the next switch
procedure Free (Cmd : in out Command_Line);
-- Free the memory used by Cmd
private private
Max_Depth : constant := 100; Max_Depth : constant := 100;
......
...@@ -3138,7 +3138,14 @@ package body Sem_Ch13 is ...@@ -3138,7 +3138,14 @@ package body Sem_Ch13 is
-- Start of processing for Check_Constant_Address_Clause -- Start of processing for Check_Constant_Address_Clause
begin begin
Check_Expr_Constants (Expr); -- If rep_clauses are to be ignored, no need for legality checks. In
-- particular, no need to pester user about rep clauses that violate
-- the rule on constant addresses, given that these clauses will be
-- removed by Freeze before they reach the back end.
if not Ignore_Rep_Clauses then
Check_Expr_Constants (Expr);
end if;
end Check_Constant_Address_Clause; end Check_Constant_Address_Clause;
---------------------------------------- ----------------------------------------
......
...@@ -906,10 +906,12 @@ package body Sem_Res is ...@@ -906,10 +906,12 @@ package body Sem_Res is
Expr := Original_Node (Expression (Parent (Comp))); Expr := Original_Node (Expression (Parent (Comp)));
-- Return True if the expression is a call to a function -- Return True if the expression is a call to a function
-- (including an attribute function such as Image) with -- (including an attribute function such as Image, or a
-- a result that requires a transient scope. -- user-defined operator) with a result that requires a
-- transient scope.
if (Nkind (Expr) = N_Function_Call if (Nkind (Expr) = N_Function_Call
or else Nkind (Expr) in N_Op
or else (Nkind (Expr) = N_Attribute_Reference or else (Nkind (Expr) = N_Attribute_Reference
and then Present (Expressions (Expr)))) and then Present (Expressions (Expr))))
and then Requires_Transient_Scope (Etype (Expr)) and then Requires_Transient_Scope (Etype (Expr))
......
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