This patch comes from Richi. Self explanatory.
OK?
2012-08-22 Richard Guenther <[email protected]>
PR fortran/45586
* trans-expr.c (gfc_nonrestricted_type): Make the non-restrict type
distinct from the original type.
diff --git a/trans-types.c b/trans-types.c
index a6e5d99..189f597 100644
--- a/trans-types.c
+++ b/trans-types.c
@@ -2026,7 +2026,8 @@ gfc_nonrestricted_type (tree t)
ret = t;
else
{
- ret = build_variant_type_copy (t);
+ ret = build_distinct_type_copy (t);
+ TYPE_CANONICAL (ret) = TYPE_CANONICAL (t);
TREE_TYPE (ret) = elemtype;
if (TYPE_LANG_SPECIFIC (t)
&& GFC_TYPE_ARRAY_DATAPTR_TYPE (t))
@@ -2070,7 +2071,8 @@ gfc_nonrestricted_type (tree t)
}
if (!field)
break;
- ret = build_variant_type_copy (t);
+ ret = build_distinct_type_copy (t);
+ TYPE_CANONICAL (ret) = TYPE_CANONICAL (t);
TYPE_FIELDS (ret) = NULL_TREE;
/* Here we make sure that as soon as we know we have to copy