This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Tested on i686-linux, committed on trunk When an aliased object is used as the prefix in a call using Object.Operation notation, and the corresponding formal is an access parameter, the code for passing the actual's accessibility level mistakenly passes the level of its type rather than the level of the named object. This can lead to dangling references when the formal is converted or assigned within the subprogram and the actual object is declared at a deeper level than the target type. The wrong level is used because the aliased object name is rewritten as an Access attribute, but the original node is used in determining the level. We now check for this as a special case and ensure that the attribute name is used to determine the level rather than the original object name. gnat.dg/aliased_prefix_accessibility.adb must execute quietly. Also, in Parameters of a scalar type are passed by value, and when inlining a call where the actual for an in-parameter is a literal, a reference to the formal can be replaced with the value of the actual. However, if the formal is the prefix of an Address or Access attribute, the resulting block is not semantically legal. In that case we must create a local variable to capture the value of the actual, and use the entity in the block. This is semantically correct, given that the actual is an expression, and that using its address in the body cannot mean more than the address of the location that holds the expression. When generating validity checks for parameters (-gnatVi) set there was already circuitry to handle the case of a packed array (unsetting the analyzed bit to force a reanalyze in the validity check context), but this was insufficient for the case where the packed array reference appeared as a prefix of a selected or indexed component in this context. This patch corrects that oversight, resetting analyzed bits on all prefixes of selected or indexed components. gnat.dg/valid1.adb should compile and execute silently. 2007-06-06 Gary Dismukes <dismukes@adacore.com> Ed Schonberg <schonberg@adacore.com> * exp_ch6.ads, exp_ch6.adb (Expand_Call): When adding an extra accessibility actual, check for the case of an aliased object that has been rewritten as an Access attribute, and assign Prev to Prev_Orig so we fall into processing for the attribute rather than the name of the object. (Expand_Inline_Call): If an actual is a literal, and the corresponding formal has its address taken in the body, create a temporary to capture value. If the return type is a limited interface, do not treat the return value as Controlled. (Is_In_Place_Function): If the return type is a limited interface, treat as returning in place. The actual returned object may not always be limited, but the caller has to assume that it is returned in place. (Add_Final_List_Actual_To_Build_In_Place_Call): If the call is the context of an allocator, use the correct finalization chain (that is, the chain belonging to the access type, rather than the chain belonging to the current scope). (Add_Alloc_Form_Actual_To_Build_In_Place_Call): Test for a tagged result type rather than a controlling result as a precondition for adding an allocation form actual to a build-in-place call. (Add_Final_List_Actual_To_Build_In_Place_Call): Ditto. (Freeze_Subprogram): Code cleanup. Remove all the code that register the primitive in the dispatch tables. This work is now done by Make_DT when the type is frozen. (Register_Predefined_DT_Entry): Removed. (Add_Return): If end label is not present, use sloc of last statement for generated return statement in procedure, for better gdb behavior on expanded code. (Add_Access_Actual_To_Build_In_Place_Call): Set parent fields of the object address nodes to ensure proper processing by routines like Insert_After*. (Expand_Call): Fix generation of validity check for parameter (Add_Alloc_Form_Actual_To_Build_In_Place_Call): Return without passing the allocation form parameter if the result subtype is constrained, except when the function has a controlling result. (Add_Final_List_Actual_To_Build_In_Place_Call): Test Controlled_Type rather than Is_Controlled and Has_Controlled_Component, since we want to include class-wide result types in this treatment. Also test for a controlling result, since that also requires passing a finalization list. (Make_Build_In_Place_Call_In_Allocator): Call Add_Alloc_Form_Actual_* even when the result subtype is constrained, to handle calls involving controlling results. (Make_Build_In_Place_Call_In_Anonymous_Context): Add_Alloc_Form_Actual_* is now called even when the result subtype is constrained, to handle calls involving controlling results. (Make_Build_In_Place_Call_In_Assignment): Remove test for Is_Constrained on call to Add_Alloc_Form_Actual_To_Build_In_Place_Call (that procedure now performs the test). (Make_Build_In_Place_Call_In_Object_Declaration): Add_Alloc_Form_Actual_* is now called even when the result subtype is constrained, to handle calls involving controlling results. (Add_Return): Accomodate rewritten pattern from local raise to goto transformation, so that we still recognize an transfer statement and do the right thing here in that case. (Expand_N_Subprogram_Body): Add dummy Push/Pop_xxx_Label nodes at start and end of subprogram code. (Register_Interface_DT_Entry, Register_Predefined_DT_Entry): Add missing support for primitives that are functions (without formals) with a controlling result. (Inherited_From_Formal): If the actual subtype has not generic parent type, it is not an actual for a formal derived type, and there is no operation to inherit from the formal.
Attachment:
difs
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |