diff options
author | Robert Dewar <dewar@adacore.com> | 2007-08-14 10:37:26 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2007-08-14 10:37:26 +0200 |
commit | d766cee3c3df3a0a6f5893f7f262dc10d150c85e (patch) | |
tree | 7c3895b13822ab5f7e3c1e9da39c7366611502b5 /gcc/ada/exp_ch2.adb | |
parent | 939c12d26a67c4e4d42d106d31c8f821b68cb1fb (diff) | |
download | gcc-d766cee3c3df3a0a6f5893f7f262dc10d150c85e.zip gcc-d766cee3c3df3a0a6f5893f7f262dc10d150c85e.tar.gz gcc-d766cee3c3df3a0a6f5893f7f262dc10d150c85e.tar.bz2 |
a-stzsup.adb, [...]: Fix warnings for range tests optimized out.
2007-08-14 Robert Dewar <dewar@adacore.com>
Gary Dismukes <dismukes@adacore.com>
Ed Schonberg <schonberg@adacore.com>
Thomas Quinot <quinot@adacore.com>
* a-stzsup.adb, nlists.adb, lib-util.adb, treepr.adb,
a-stwisu.adb, a-strsup.adb: Fix warnings for range
tests optimized out.
* exp_ch4.adb (Expand_N_In): Add warnings for range tests optimized out.
(Get_Allocator_Final_List): For the case of an anonymous access type
that has a specified Associated_Final_Chain, do not go up to the
enclosing scope.
(Expand_N_Type_Conversion): Test for the case of renamings of access
parameters when deciding whether to apply a run-time accessibility
check.
(Convert_Aggr_In_Allocator): Use Insert_Actions to place expanded
aggregate code before allocator, and ahead of declaration for
temporary, to prevent access before elaboration when the allocator is
an actual for an access parameter.
(Expand_N_Type_Conversion): On an access type conversion involving an
access parameter, do not apply an accessibility check when the
operand's original node was an attribute other than 'Access. We now
create access conversions for the expansion of 'Unchecked_Access and
'Unrestricted_Access in certain cases and clearly accessibility should
not be checked for those.
* exp_ch6.ads, exp_ch6.adb (Add_Call_By_Copy_Code): For an actual that
includes a type conversion of a packed component that has been expanded,
recover the original expression for the object, and use this expression
in the post-call assignment statement, so that the assignment is made
to the object and not to a back-end temporary.
(Freeze_Subprogram): In case of primitives of tagged types not defined
at the library level force generation of code to register the primitive
in the dispatch table. In addition some code reorganization has been
done to leave the implementation clear.
(Expand_Call): When expanding an inherited implicit conversion,
preserve the type of the inherited function after the intrinsic
operation has been expanded.
* exp_ch2.ads, exp_ch2.adb
(Expand_Entry_Parameter.In_Assignment_Context): An implicit dereference
of an entry formal appearing in an assignment statement does not assign
to the formal.
(Expand_Current_Value): Instead of calling a routine to determine
whether the prefix of an attribute reference should be optimized or
not, prevent the optimization of such prefixes all together.
* lib-xref.adb (Generate_Reference.Is_On_LHS): An indexed or selected
component whose prefix is known to be of an access type is an implicit
dereference and does not assign to the prefix.
From-SVN: r127411
Diffstat (limited to 'gcc/ada/exp_ch2.adb')
-rw-r--r-- | gcc/ada/exp_ch2.adb | 57 |
1 files changed, 47 insertions, 10 deletions
diff --git a/gcc/ada/exp_ch2.adb b/gcc/ada/exp_ch2.adb index f486d02..223b51b 100644 --- a/gcc/ada/exp_ch2.adb +++ b/gcc/ada/exp_ch2.adb @@ -32,15 +32,16 @@ with Exp_Smem; use Exp_Smem; with Exp_Tss; use Exp_Tss; with Exp_Util; use Exp_Util; with Exp_VFpt; use Exp_VFpt; +with Namet; use Namet; with Nmake; use Nmake; with Opt; use Opt; with Sem; use Sem; -with Sem_Attr; use Sem_Attr; with Sem_Eval; use Sem_Eval; with Sem_Res; use Sem_Res; with Sem_Util; use Sem_Util; with Sem_Warn; use Sem_Warn; with Sinfo; use Sinfo; +with Snames; use Snames; with Tbuild; use Tbuild; with Uintp; use Uintp; @@ -90,13 +91,13 @@ package body Exp_Ch2 is procedure Expand_Entry_Parameter (N : Node_Id); -- A reference to an entry parameter is modified to be a reference to the -- corresponding component of the entry parameter record that is passed by - -- the runtime to the accept body procedure + -- the runtime to the accept body procedure. procedure Expand_Formal (N : Node_Id); -- A reference to a formal parameter of a protected subprogram is expanded -- into the corresponding formal of the unprotected procedure used to -- represent the operation within the protected object. In other cases - -- Expand_Formal is a noop. + -- Expand_Formal is a no-op. procedure Expand_Protected_Private (N : Node_Id); -- A reference to a private component of a protected type is expanded to a @@ -156,11 +157,18 @@ package body Exp_Ch2 is and then Nkind (Parent (N)) /= N_Pragma_Argument_Association - -- Same for attribute references that require a simple name prefix + -- Do not replace the prefixes of attribute references, since this + -- causes trouble with cases like 4'Size. Also for Name_Asm_Input and + -- Name_Asm_Output, don't do replacement anywhere, since we can have + -- lvalue references in the arguments. and then not (Nkind (Parent (N)) = N_Attribute_Reference - and then Requires_Simple_Name_Prefix ( - Attribute_Name (Parent (N)))) + and then + (Attribute_Name (Parent (N)) = Name_Asm_Input + or else + Attribute_Name (Parent (N)) = Name_Asm_Output + or else + Prefix (Parent (N)) = N)) then -- Case of Current_Value is a compile time known value @@ -421,6 +429,11 @@ package body Exp_Ch2 is function In_Assignment_Context (N : Node_Id) return Boolean is begin + -- Case of use in a call + + -- ??? passing a formal as actual for a mode IN formal is + -- considered as an assignment? + if Nkind (Parent (N)) = N_Procedure_Call_Statement or else Nkind (Parent (N)) = N_Entry_Call_Statement or else @@ -429,15 +442,25 @@ package body Exp_Ch2 is then return True; + -- Case of a parameter association: climb up to enclosing call + elsif Nkind (Parent (N)) = N_Parameter_Association then return In_Assignment_Context (Parent (N)); + -- Case of a selected component, indexed component or slice prefix: + -- climb up the tree, unless the prefix is of an access type (in + -- which case there is an implicit dereference, and the formal itself + -- is not being assigned to). + elsif (Nkind (Parent (N)) = N_Selected_Component or else Nkind (Parent (N)) = N_Indexed_Component or else Nkind (Parent (N)) = N_Slice) + and then N = Prefix (Parent (N)) + and then not Is_Access_Type (Etype (N)) and then In_Assignment_Context (Parent (N)) then return True; + else return False; end if; @@ -670,6 +693,8 @@ package body Exp_Ch2 is -- through an address clause is rewritten as dereference as well. function Param_Entity (N : Node_Id) return Entity_Id is + Renamed_Obj : Node_Id; + begin -- Simple reference case @@ -677,10 +702,22 @@ package body Exp_Ch2 is if Is_Formal (Entity (N)) then return Entity (N); - elsif Nkind (Parent (Entity (N))) = N_Object_Renaming_Declaration - and then Nkind (Parent (Parent (Entity (N)))) = N_Accept_Statement - then - return Entity (N); + -- Handle renamings of formal parameters and formals of tasks that + -- are rewritten as renamings. + + elsif Nkind (Parent (Entity (N))) = N_Object_Renaming_Declaration then + Renamed_Obj := Get_Referenced_Object (Renamed_Object (Entity (N))); + + if Is_Entity_Name (Renamed_Obj) + and then Is_Formal (Entity (Renamed_Obj)) + then + return Entity (Renamed_Obj); + + elsif + Nkind (Parent (Parent (Entity (N)))) = N_Accept_Statement + then + return Entity (N); + end if; end if; else |