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] lvalue_required_p and unchecked conversions


lvalue_required_p is sensitive to the presence of unchecked conversions: when 
it runs into one, it stops climbing up the GNAT tree and returns 0.  Although 
I think that's correct, that can result in the creation of large temporaries 
if the parent node does require an lvalue.

Tested on i586-suse-linux, applied on the mainline.


2009-11-05  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/trans.c (lvalue_required_p) <N_Unchecked_Conversion>:
	New case.


-- 
Eric Botcazou
Index: gcc-interface/trans.c
===================================================================
--- gcc-interface/trans.c	(revision 153881)
+++ gcc-interface/trans.c	(working copy)
@@ -657,17 +657,16 @@ gigi (Node_Id gnat_root, int max_gnat_no
   error_gnat_node = Empty;
 }
 
-/* Return a positive value if an lvalue is required for GNAT_NODE.
-   GNU_TYPE is the type that will be used for GNAT_NODE in the
-   translated GNU tree.  CONSTANT indicates whether the underlying
-   object represented by GNAT_NODE is constant in the Ada sense,
-   ALIASED whether it is aliased (but the latter doesn't affect
-   the outcome if CONSTANT is not true).
-
-   The function climbs up the GNAT tree starting from the node and
-   returns 1 upon encountering a node that effectively requires an
-   lvalue downstream.  It returns int instead of bool to facilitate
-   usage in non purely binary logic contexts.  */
+/* Return a positive value if an lvalue is required for GNAT_NODE.  GNU_TYPE
+   is the type that will be used for GNAT_NODE in the translated GNU tree.
+   CONSTANT indicates whether the underlying object represented by GNAT_NODE
+   is constant in the Ada sense, ALIASED whether it is aliased (but the latter
+   doesn't affect the outcome if CONSTANT is not true).
+
+   The function climbs up the GNAT tree starting from the node and returns 1
+   upon encountering a node that effectively requires an lvalue downstream.
+   It returns int instead of bool to facilitate usage in non-purely binary
+   logic contexts.  */
 
 static int
 lvalue_required_p (Node_Id gnat_node, tree gnu_type, bool constant,
@@ -754,6 +753,13 @@ lvalue_required_p (Node_Id gnat_node, tr
 	      || (Is_Composite_Type (Underlying_Type (Etype (gnat_node)))
 		  && Is_Atomic (Entity (Name (gnat_parent)))));
 
+    case N_Unchecked_Type_Conversion:
+      /* Returning 0 is very likely correct but we get better code if we
+	 go through the conversion.  */
+      return lvalue_required_p (gnat_parent,
+				get_unpadded_type (Etype (gnat_parent)),
+				constant, aliased);
+
     default:
       return 0;
     }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]