diff mbox

[Ada] Fix infinite loop on pointer to discriminated type

Message ID 201010251944.03516.ebotcazou@adacore.com
State New
Headers show

Commit Message

Eric Botcazou Oct. 25, 2010, 5:44 p.m. UTC
Recent changes have exposed a latent issue in update_pointer_to: we fail to 
clear the TYPE_POINTER_TO/TYPE_REFERENCE_TO fields of the old type after 
redirecting its pointer and reference types.

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


2010-10-25  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/utils.c (update_pointer_to): Clear TYPE_POINTER_TO and
	TYPE_REFERENCE_TO of the old type after redirecting its pointer and
	reference types.


2010-10-25  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/pointer_discr1.adb: New test.
	* gnat.dg/pointer_discr1_pkg1.ads: New helper.
	* gnat.dg/pointer_discr1_pkg2.ads: Likewise.
	* gnat.dg/pointer_discr1_pkg3.ads: Likewise.
diff mbox

Patch

Index: gcc-interface/utils.c
===================================================================
--- gcc-interface/utils.c	(revision 165910)
+++ gcc-interface/utils.c	(working copy)
@@ -3427,6 +3427,7 @@  update_pointer_to (tree old_type, tree n
       for (; ptr; ptr = TYPE_NEXT_PTR_TO (ptr))
 	for (t = TYPE_MAIN_VARIANT (ptr); t; t = TYPE_NEXT_VARIANT (t))
 	  TREE_TYPE (t) = new_type;
+      TYPE_POINTER_TO (old_type) = NULL_TREE;
 
       /* Chain REF and its variants at the end.  */
       new_ref = TYPE_REFERENCE_TO (new_type);
@@ -3443,6 +3444,7 @@  update_pointer_to (tree old_type, tree n
       for (; ref; ref = TYPE_NEXT_REF_TO (ref))
 	for (t = TYPE_MAIN_VARIANT (ref); t; t = TYPE_NEXT_VARIANT (t))
 	  TREE_TYPE (t) = new_type;
+      TYPE_REFERENCE_TO (old_type) = NULL_TREE;
     }
 
   /* Now deal with the unconstrained array case.  In this case the pointer