From: Eric Botcazou Date: Wed, 18 Sep 2024 06:24:32 +0000 (+0200) Subject: ada: Fix fallout of change in parameter passing out of aliasing considerations X-Git-Tag: basepoints/gcc-16~4900 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=11e06dd243ac578f81d435ca0aea2ce3340a0650;p=thirdparty%2Fgcc.git ada: Fix fallout of change in parameter passing out of aliasing considerations 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. --- diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc index 93f67404ddb4..5f8a18eebb72 100644 --- a/gcc/ada/gcc-interface/trans.cc +++ b/gcc/ada/gcc-interface/trans.cc @@ -5010,9 +5010,12 @@ Call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target, 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,