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>
+
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Array_Type>: Do not set
TREE_THIS_NOTRAP on the INDIRECT_REF node built for the template.
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);
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
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.
+
+2010-10-25 Eric Botcazou <ebotcazou@adacore.com>
+
* gnat.dg/loop_optimization8.adb: New test.
* gnat.dg/loop_optimization8_pkg1.ad[sb]: New helper.
* gnat.dg/loop_optimization8_pkg2.ad[sb]: Likewise.
--- /dev/null
+-- { dg-do compile }
+
+with Pointer_Discr1_Pkg1;
+with Pointer_Discr1_Pkg3;
+
+procedure Pointer_Discr1 is
+begin
+ Pointer_Discr1_Pkg3.Map(Pointer_Discr1_Pkg1.Window(1));
+end;
--- /dev/null
+with Pointer_Discr1_Pkg2;
+
+package Pointer_Discr1_Pkg1 is
+
+ type Arr is array (1..4) of Pointer_Discr1_Pkg2.T_WINDOW;
+
+ Window : Arr;
+
+end Pointer_Discr1_Pkg1;
--- /dev/null
+with Unchecked_Conversion;
+with Pointer_Discr1_Pkg3;
+
+package Pointer_Discr1_Pkg2 is
+
+ subtype T_WINDOW is Pointer_Discr1_Pkg3.T_WINDOW(Pointer_Discr1_Pkg3.One);
+
+ function TO_WINDOW is new Unchecked_Conversion(Integer, T_WINDOW);
+
+end Pointer_Discr1_Pkg2;
--- /dev/null
+package Pointer_Discr1_Pkg3 is
+
+ type T_TYPE is (One, Two, Three);
+
+ type T_DATA (D : T_TYPE);
+
+ type T_DATA (D : T_TYPE) is null record;
+
+ type T_WINDOW is access T_DATA;
+
+ procedure Map (Window : in T_WINDOW);
+
+end Pointer_Discr1_Pkg3;