If an actual parameter that is a type conversion is passed by reference but
not addressable, the temporary that is created and whose address is passed
instead may need to be in the target type of the conversion to fulfill the
requirements of strict aliasing.
gcc/ada/ChangeLog:
* gcc-interface/trans.cc (Call_to_gnu): If the formal is passed by
reference and the actual is a type conversion but not addressable,
create the temporary in the target type of the conversion if this
is needed to enforce strict aliasing.
TREE_TYPE (gnu_name))))
gnu_name = convert (gnu_name_type, gnu_name);
- /* If the temporary is created because of aliasing considerations,
+ /* If the temporary is created because of aliasing considerations,
+ or would have been so created if the actual was addressable,
it must be in the target type of the (unchecked) conversion. */
- if (aliasing)
+ if (aliasing
+ || (node_is_type_conversion (gnat_actual)
+ && !aliasable_p (gnu_name, gnu_actual_type)))
{
if (Nkind (gnat_actual) == N_Unchecked_Type_Conversion)
gnu_name = unchecked_convert (gnu_actual_type, gnu_name,