From b7f856e1c131877ffb3ea0000b9fd8ec2c0cb333 Mon Sep 17 00:00:00 2001 From: rguenth Date: Mon, 2 Jul 2018 08:00:47 +0000 Subject: [PATCH] 2018-07-02 Richard Biener PR lto/86321 * trans-types.c (gfc_get_array_type_bounds): Unshare TYPE_FIELDs for the distinct type copy. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@262301 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/trans-types.c | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b8e71975672..ac4a2374fe5 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2018-07-02 Richard Biener + + PR lto/86321 + * trans-types.c (gfc_get_array_type_bounds): Unshare TYPE_FIELDs + for the distinct type copy. + 2018-07-02 Paul Thomas PR fortran/82969 diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c index f50eb0a9f01..5b396236f85 100644 --- a/gcc/fortran/trans-types.c +++ b/gcc/fortran/trans-types.c @@ -1923,6 +1923,14 @@ gfc_get_array_type_bounds (tree etype, int dimen, int codimen, tree * lbound, base_type = gfc_get_array_descriptor_base (dimen, codimen, restricted); fat_type = build_distinct_type_copy (base_type); + /* Unshare TYPE_FIELDs. */ + for (tree *tp = &TYPE_FIELDS (fat_type); *tp; tp = &DECL_CHAIN (*tp)) + { + tree next = DECL_CHAIN (*tp); + *tp = copy_node (*tp); + DECL_CONTEXT (*tp) = fat_type; + DECL_CHAIN (*tp) = next; + } /* Make sure that nontarget and target array type have the same canonical type (and same stub decl for debug info). */ base_type = gfc_get_array_descriptor_base (dimen, codimen, false); -- 2.11.4.GIT