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] issues with address handling


Tested on i686-linux, committed on trunk

When a CONST_DECL is made by gigi for the definition of constant entity,
a VAR_DECL definition is associated to it in various circumstances, and in
in particular when the entity is public.

Part of the point is to have something to hook to when the constant address
is taken, and this was actually failing when the address is taken from another
unit because the corresponding external VAR_DECL was not made for such
references.

gnat.dg/nat1r.adb is expected to run silently
and it used to raise an exception because "Nat_One_Storage'Address"
in the comparison yields the address of a copy.

The fix applied here consists in attaching to the CONST_DECL node made
for the reference an external VAR_DECL corresponding to the one made for
the definition, expect for Standard entities since they don't have standalone
object level materialization of their own.

Also, the implementation of address clauses is heavyweight: first,
the type of object is made volatile; second, the object is turned into a
reference to the entity it overlays and this reference is flagged as aliasing
everything.

It turns out that the volatile side is problematic with GCC 4 because this
causes the gimplifier to create temporaries for the whole object, which can
get tricky if the object is of a discriminated type (this is F709-002).
Moreover, this seems to badly interact with the Value Numbering pass which
needs to keep track of this volatility and can fail, leading to infinite
loops in the PRE pass of the gcc-head compiler on some ACATS tests.

Now the type of the object is made volatile as per 13.3(19) which reads:
"If the Address of an object is specified, or it is imported or exported, then
the implementation should not perform optimizations based on assumptions of
no aliases."  Which is precisely the purpose of the "can aliasing everything"
bit set on the reference type.

gnat.dg/volatile2.adb must compile silently.

2007-04-06  Olivier Hainque  <hainque@adacore.com>
	    Eric Botcazou <botcazou@adacore.com>

	* decl.c (gnat_to_gnu_entity) <E_Constant>: Associate an external
	VAR_DECL to a CONST_DECL we make for a public constant when we know the
	corresponding definition has created the so made visible variable.
	Handle anonymous access to protected subprogram.
	(gnat_to_gnu_entity) <E_Variable>: Do not make the underlying type of an
	object with an address clause volatile.  Re-enable original fix.
	<E_Subprogram_Type>: Set TYPE_REF_CAN_ALIAS_ALL on the reference type
	too.
	(gnat_to_gnu_entity) <E_Class_Wide_Type>: Retrieve the TYPE_DECL
	associated with either the Equivalent or Root type, instead of the
	naked type node.
	(gnat_to_gnu_entity): Manually mark the top of the DECL_FIELD_OFFSET
	subtree for every field of a global record type.
	(gnat_to_gnu_entity) <E_Record_Subtype>: If the subtype has
	discriminants, invoke again variable_size on its newly computed sizes.

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]