]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix fallout of change in parameter passing out of aliasing considerations
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 18 Sep 2024 06:24:32 +0000 (08:24 +0200)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Fri, 25 Oct 2024 09:09:03 +0000 (11:09 +0200)
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.

gcc/ada/gcc-interface/trans.cc

index 93f67404ddb44df9f771e9bf88410605952b60ad..5f8a18eebb7228f8e9cc1b084cc5e8dd70c9ab8c 100644 (file)
@@ -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,