This plugs a small hole in the implementation of lvalue_required_p.

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


2015-06-01  Eric Botcazou  <ebotca...@adacore.com>

        * gcc-interface/trans.c (lvalue_required_p) <N_Indexed_Component>: Deal
        with character and enumeration literals as index values.


-- 
Eric Botcazou
Index: gcc-interface/trans.c
===================================================================
--- gcc-interface/trans.c	(revision 223897)
+++ gcc-interface/trans.c	(working copy)
@@ -858,14 +858,17 @@ lvalue_required_p (Node_Id gnat_node, tr
       if (Prefix (gnat_parent) != gnat_node)
 	return 0;
 
-      /* ??? Consider that referencing an indexed component with a
-	 non-constant index forces the whole aggregate to memory.
-	 Note that N_Integer_Literal is conservative, any static
-	 expression in the RM sense could probably be accepted.  */
+      /* ??? Consider that referencing an indexed component with a variable
+	 index forces the whole aggregate to memory.  Note that testing only
+	 for literals is conservative, any static expression in the RM sense
+	 could probably be accepted with some additional work.  */
       for (gnat_temp = First (Expressions (gnat_parent));
 	   Present (gnat_temp);
 	   gnat_temp = Next (gnat_temp))
-	if (Nkind (gnat_temp) != N_Integer_Literal)
+	if (Nkind (gnat_temp) != N_Character_Literal
+	    && Nkind (gnat_temp) != N_Integer_Literal
+	    && !(Is_Entity_Name (gnat_temp)
+		 && Ekind (Entity (gnat_temp)) == E_Enumeration_Literal))
 	  return 1;
 
       /* ... fall through ... */

Reply via email to