===================================================================
@@ -5587,6 +5587,10 @@ gnat_to_gnu_param (Entity_Id gnat_param,
DECL_BY_COMPONENT_PTR_P (gnu_param) = by_component_ptr;
DECL_BY_DESCRIPTOR_P (gnu_param) = (mech == By_Descriptor ||
mech == By_Short_Descriptor);
+ /* Note that, in case of a parameter passed by double reference, the
+ DECL_POINTS_TO_READONLY_P flag is meant for the second reference.
+ The first reference always points to read-only, as it points to
+ the second reference, i.e. the reference to the actual parameter. */
DECL_POINTS_TO_READONLY_P (gnu_param)
= (ro_param && (by_ref || by_component_ptr));
DECL_CAN_NEVER_BE_NULL_P (gnu_param) = Can_Never_Be_Null (gnat_param);
===================================================================
@@ -1038,8 +1038,9 @@ Identifier_to_gnu (Node_Id gnat_node, tr
if (TREE_CODE (gnu_result) == INDIRECT_REF)
TREE_THIS_NOTRAP (gnu_result) = 1;
- if (read_only)
- TREE_READONLY (gnu_result) = 1;
+ /* The first reference, in case of a double reference, always points
+ to read-only, see gnat_to_gnu_param for the rationale. */
+ TREE_READONLY (gnu_result) = 1;
}
/* If it's a PARM_DECL to foreign convention subprogram, convert it. */