https://gcc.gnu.org/g:f826d1330063a73020cb0346d53aeb6719db6fa6
commit f826d1330063a73020cb0346d53aeb6719db6fa6 Author: Mikael Morin <mik...@gcc.gnu.org> Date: Fri Apr 11 16:39:13 2025 +0200 Correction ICE PR100906 Diff: --- gcc/fortran/trans-decl.cc | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc index 565d57c2eeb7..0bea99803a5d 100644 --- a/gcc/fortran/trans-decl.cc +++ b/gcc/fortran/trans-decl.cc @@ -4401,7 +4401,7 @@ gfc_trans_assign_aux_var (gfc_symbol * sym, gfc_wrapped_block * block) } static void -gfc_trans_vla_one_sizepos (tree *tp, stmtblock_t *body) +gfc_trans_vla_one_sizepos (tree *tp, tree root_decl, stmtblock_t *body) { tree t = *tp, var, val; @@ -4410,6 +4410,9 @@ gfc_trans_vla_one_sizepos (tree *tp, stmtblock_t *body) if (TREE_CONSTANT (t) || DECL_P (t)) return; + if (contains_placeholder_p (t)) + t = substitute_placeholder_in_expr (t, root_decl); + if (TREE_CODE (t) == SAVE_EXPR) { if (SAVE_EXPR_RESOLVED_P (t)) @@ -4431,7 +4434,7 @@ gfc_trans_vla_one_sizepos (tree *tp, stmtblock_t *body) } static void -gfc_trans_vla_type_sizes_1 (tree type, stmtblock_t *body) +gfc_trans_vla_type_sizes_1 (tree type, tree root_decl, stmtblock_t *body) { tree t; @@ -4442,8 +4445,8 @@ gfc_trans_vla_type_sizes_1 (tree type, stmtblock_t *body) if (TREE_CODE (type) == INTEGER_TYPE) { - gfc_trans_vla_one_sizepos (&TYPE_MIN_VALUE (type), body); - gfc_trans_vla_one_sizepos (&TYPE_MAX_VALUE (type), body); + gfc_trans_vla_one_sizepos (&TYPE_MIN_VALUE (type), root_decl, body); + gfc_trans_vla_one_sizepos (&TYPE_MAX_VALUE (type), root_decl, body); for (t = TYPE_NEXT_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t)) { @@ -4453,10 +4456,10 @@ gfc_trans_vla_type_sizes_1 (tree type, stmtblock_t *body) } else if (TREE_CODE (type) == ARRAY_TYPE) { - gfc_trans_vla_type_sizes_1 (TREE_TYPE (type), body); - gfc_trans_vla_type_sizes_1 (TYPE_DOMAIN (type), body); - gfc_trans_vla_one_sizepos (&TYPE_SIZE (type), body); - gfc_trans_vla_one_sizepos (&TYPE_SIZE_UNIT (type), body); + gfc_trans_vla_type_sizes_1 (TREE_TYPE (type), root_decl, body); + gfc_trans_vla_type_sizes_1 (TYPE_DOMAIN (type), root_decl, body); + gfc_trans_vla_one_sizepos (&TYPE_SIZE (type), root_decl, body); + gfc_trans_vla_one_sizepos (&TYPE_SIZE_UNIT (type), root_decl, body); for (t = TYPE_NEXT_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t)) { @@ -4479,7 +4482,8 @@ gfc_trans_vla_type_sizes_1 (tree type, stmtblock_t *body) void gfc_trans_vla_type_sizes (gfc_symbol *sym, stmtblock_t *body) { - tree type = TREE_TYPE (sym->backend_decl); + tree root_decl = sym->backend_decl; + tree type = TREE_TYPE (root_decl); if (TREE_CODE (type) == FUNCTION_TYPE && (sym->attr.function || sym->attr.result || sym->attr.entry)) @@ -4500,10 +4504,10 @@ gfc_trans_vla_type_sizes (gfc_symbol *sym, stmtblock_t *body) while (POINTER_TYPE_P (etype)) etype = TREE_TYPE (etype); - gfc_trans_vla_type_sizes_1 (etype, body); + gfc_trans_vla_type_sizes_1 (etype, root_decl, body); } - gfc_trans_vla_type_sizes_1 (type, body); + gfc_trans_vla_type_sizes_1 (type, root_decl, body); }