[Ada] Fix PR ada/92362

Message ID 58325078.VrUzyTc7tU@polaris
State New
Headers show
  • [Ada] Fix PR ada/92362
Related show

Commit Message

Eric Botcazou Nov. 25, 2019, 10:53 a.m.
This is a regression present on mainline and 9 branch: the expression of an 
Address aspect is elaborated twice (if it has side effects) because of a silly 
mistake made in an ealier change.

Tested on x86_64-suse-linux, applied on the mainline and 9 branch.

2019-11-25  Eric Botcazou  <ebotcazou@adacore.com>

	PR ada/92362
	* gcc-interface/trans.c (gnat_to_gnu) <N_Attribute_Definition_Clause>:
	Use a temporary instead of clobbering the result with a freeze node.

2019-11-25  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/addr14.adb: New test.

Eric Botcazou


Index: gcc-interface/trans.c
--- gcc-interface/trans.c	(revision 277906)
+++ gcc-interface/trans.c	(working copy)
@@ -8421,7 +8421,7 @@  gnat_to_gnu (Node_Id gnat_node)
       gnat_temp = Entity (Name (gnat_node));
       if (Freeze_Node (gnat_temp))
-	  tree gnu_address = gnat_to_gnu (Expression (gnat_node));
+	  tree gnu_address = gnat_to_gnu (Expression (gnat_node)), gnu_temp;
 	  /* Get the value to use as the address and save it as the equivalent
 	     for the object; when it is frozen, gnat_to_gnu_entity will do the
@@ -8431,7 +8431,7 @@  gnat_to_gnu (Node_Id gnat_node)
 	     of the object is limited and it is initialized with the result of
 	     a function call.  */
 	  if (Is_Subprogram (gnat_temp))
-	    gnu_result = gnu_address;
+	    gnu_temp = gnu_address;
 	      tree gnu_type = gnat_to_gnu_type (Etype (gnat_temp));
@@ -8440,11 +8440,11 @@  gnat_to_gnu (Node_Id gnat_node)
 		= build_reference_type_for_mode (gnu_type, ptr_mode, true);
 	      gnu_address = convert (gnu_type, gnu_address);
-	      gnu_result
+	      gnu_temp
 		= build_unary_op (INDIRECT_REF, NULL_TREE, gnu_address);
-	  save_gnu_tree (gnat_temp, gnu_result, true);
+	  save_gnu_tree (gnat_temp, gnu_temp, true);