aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorAndre Vehreschild <vehre@gcc.gnu.org>2024-07-10 14:37:37 +0200
committerAndre Vehreschild <vehre@gcc.gnu.org>2024-07-18 09:27:46 +0200
commit0231b076dc98eb02e3289b21ace1757782e3917b (patch)
tree2848733269f7e53dbfd6100e6de822dcdef758d0 /gcc/fortran
parent958ee138748fae4371e453eb9b357f576abbe83e (diff)
downloadgcc-0231b076dc98eb02e3289b21ace1757782e3917b.zip
gcc-0231b076dc98eb02e3289b21ace1757782e3917b.tar.gz
gcc-0231b076dc98eb02e3289b21ace1757782e3917b.tar.bz2
Fortran: Use char* for deferred length character arrays [PR82904]
Randomly during compiling the pass IPA: inline would ICE. This was caused by a saved deferred length string. The length variable was not set, but the variable was used in the array's declaration. Now using a character pointer to prevent this. PR fortran/82904 gcc/fortran/ChangeLog: * trans-types.cc (gfc_sym_type): Use type `char*` for saved deferred length char arrays. * trans.cc (get_array_span): Get `.span` also for `char*` typed arrays, i.e. for those that have INTEGER_TYPE instead of ARRAY_TYPE. gcc/testsuite/ChangeLog: * gfortran.dg/deferred_character_38.f90: New test.
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/trans-types.cc6
-rw-r--r--gcc/fortran/trans.cc4
2 files changed, 7 insertions, 3 deletions
diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc
index f7b80a9..01ce54f 100644
--- a/gcc/fortran/trans-types.cc
+++ b/gcc/fortran/trans-types.cc
@@ -2334,8 +2334,10 @@ gfc_sym_type (gfc_symbol * sym, bool is_bind_c)
|| ((sym->attr.result || sym->attr.value)
&& sym->ns->proc_name
&& sym->ns->proc_name->attr.is_bind_c)
- || (sym->ts.deferred && (!sym->ts.u.cl
- || !sym->ts.u.cl->backend_decl))
+ || (sym->ts.deferred
+ && (!sym->ts.u.cl
+ || !sym->ts.u.cl->backend_decl
+ || sym->attr.save))
|| (sym->attr.dummy
&& sym->attr.value
&& gfc_length_one_character_type_p (&sym->ts))))
diff --git a/gcc/fortran/trans.cc b/gcc/fortran/trans.cc
index 1067e03..d4c5409 100644
--- a/gcc/fortran/trans.cc
+++ b/gcc/fortran/trans.cc
@@ -398,7 +398,9 @@ get_array_span (tree type, tree decl)
return gfc_conv_descriptor_span_get (decl);
/* Return the span for deferred character length array references. */
- if (type && TREE_CODE (type) == ARRAY_TYPE && TYPE_STRING_FLAG (type))
+ if (type
+ && (TREE_CODE (type) == ARRAY_TYPE || TREE_CODE (type) == INTEGER_TYPE)
+ && TYPE_STRING_FLAG (type))
{
if (TREE_CODE (decl) == PARM_DECL)
decl = build_fold_indirect_ref_loc (input_location, decl);