http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54992
Paul Thomas <pault at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot |pault at gcc dot gnu.org
|gnu.org |
--- Comment #4 from Paul Thomas <pault at gcc dot gnu.org> 2012-12-26 17:56:31
UTC ---
This is another result of the underlying bug unearthed in PR54990.
Index: gcc/fortran/trans-array.c
===================================================================
*** gcc/fortran/trans-array.c (revision 194721)
--- gcc/fortran/trans-array.c (working copy)
*************** static tree
*** 3099,3112 ****
build_array_ref (tree desc, tree offset, tree decl)
{
tree tmp;
/* Class array references need special treatment because the assigned
type size needs to be used to point to the element. */
if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (desc))
&& TREE_CODE (desc) == COMPONENT_REF
! && GFC_CLASS_TYPE_P (TREE_TYPE (TREE_OPERAND (desc, 0))))
{
! tree type = gfc_get_element_type (TREE_TYPE (desc));
tmp = TREE_OPERAND (desc, 0);
tmp = gfc_get_class_array_ref (offset, tmp);
tmp = fold_convert (build_pointer_type (type), tmp);
--- 3099,3118 ----
build_array_ref (tree desc, tree offset, tree decl)
{
tree tmp;
+ tree type;
+
+ type = TREE_TYPE (TREE_OPERAND (desc, 0));
+ if (TYPE_CANONICAL (type)
+ && GFC_CLASS_TYPE_P (TYPE_CANONICAL (type)))
+ type = TYPE_CANONICAL (type);
/* Class array references need special treatment because the assigned
type size needs to be used to point to the element. */
if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (desc))
&& TREE_CODE (desc) == COMPONENT_REF
! && GFC_CLASS_TYPE_P (type))
{
! type = gfc_get_element_type (TREE_TYPE (desc));
tmp = TREE_OPERAND (desc, 0);
tmp = gfc_get_class_array_ref (offset, tmp);
tmp = fold_convert (build_pointer_type (type), tmp);
fixes it. As remarked in PR54990, I do not know why this regression has
occurred. Evidently, GFC_CLASS_TYPE_P is not being transferred from the
canonical type, whereas this was happening before the regression (or a new type
was not being generated?). I will investigate more.
I have taken this PR.
Cheers
Paul