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]

[Ada] Missing check for 'Access of component of dereferenced access formal


The compiler neglected to emit an accessibility level check when applying
the Access attribute to an aliased subcomponent of a dereference of an
access parameter. This is addressed by testing the outermost prefix object
of a selected or indexed component for being a derferenced access paramter,
rather than testing only the immediate prefix of the attribute, and then
applying an accessibility check directly to the access parameter. This
replaces the old code that rewrote the prefix as an access type conversion.
This is necessary, since generating a conversion in the subcomponent case
is problematic (no appropriate target access type is available), and simpler
in any case. Also, a fix was made to use the proper accessibility level when
passing an access discriminant as an actual for an access parameter, now
properly implementing RM05-3.10.2(12.4/2), which defines the level to be
that of the enclosing object.

See gnat.dg/missing_acc_check.adb

Tested on i686-pc-linux-gnu, committed on trunk

2008-07-31  Gary Dismukes  <dismukes@adacore.com>

	* exp_attr.adb (Enclosing_Object): New function local to handling of
	access attributes,
	for retrieving the innermost enclosing object prefix of a compound name.
	(Expand_N_Attribute_Reference, N_Attribute_Access): In the case where an
	Access attribute has a prefix that is a dereference of an access
	parameter (or the prefix is a subcomponent selected from such a
	dereference), apply an accessibility check to the access parameter.
	Replaces code that rewrote the prefix as a type conversion (and that
	didn't handle subcomponent cases).
	Also, this is now only applied in the case of 'Access.
	
	* exp_ch6.adb (Expand_Call): Add handling for the case of an access
	discriminant passed as an actual to an access formal, passing the
	Object_Access_Level of the object containing the access discriminant.

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]