diff options
author | Daniel Kraft <d@domob.eu> | 2008-09-21 17:33:37 +0200 |
---|---|---|
committer | Daniel Kraft <domob@gcc.gnu.org> | 2008-09-21 17:33:37 +0200 |
commit | 4b7f8314ba66ab03974e94bf80718b157cc1350f (patch) | |
tree | 7e12ab2f71e4936cfd889e91f274ac7585d3640b /gcc/fortran/trans-array.c | |
parent | 74a9b8976475b250d6d9d68b2ea557cc0e778f4e (diff) | |
download | gcc-4b7f8314ba66ab03974e94bf80718b157cc1350f.zip gcc-4b7f8314ba66ab03974e94bf80718b157cc1350f.tar.gz gcc-4b7f8314ba66ab03974e94bf80718b157cc1350f.tar.bz2 |
re PR fortran/35846 (ICE on nested character constructors)
2008-09-21 Daniel Kraft <d@domob.eu>
PR fortran/35846
* trans.h (gfc_conv_string_length): New argument `expr'.
* trans-expr.c (flatten_array_ctors_without_strlen): New method.
(gfc_conv_string_length): New argument `expr' that is used in a new
special case handling if cl->length is NULL.
(gfc_conv_subref_array_arg): Pass expr to gfc_conv_string_length.
* trans-array.c (gfc_conv_expr_descriptor): Ditto.
(gfc_trans_auto_array_allocation): Pass NULL as new expr.
(gfc_trans_g77_array), (gfc_trans_dummy_array_bias): Ditto.
(gfc_trans_deferred_array): Ditto.
(gfc_trans_array_constructor): Save and restore old values of globals
used for bounds checking.
* trans-decl.c (gfc_trans_dummy_character): Ditto.
(gfc_trans_auto_character_variable): Ditto.
2008-09-21 Daniel Kraft <d@domob.eu>
PR fortran/35846
* gfortran.dg/nested_array_constructor_1.f90: New test.
* gfortran.dg/nested_array_constructor_2.f90: New test.
* gfortran.dg/nested_array_constructor_3.f90: New test.
* gfortran.dg/nested_array_constructor_4.f90: New test.
* gfortran.dg/nested_array_constructor_5.f90: New test.
* gfortran.dg/nested_array_constructor_6.f90: New test.
From-SVN: r140529
Diffstat (limited to 'gcc/fortran/trans-array.c')
-rw-r--r-- | gcc/fortran/trans-array.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c index f4af4f2..42b9967 100644 --- a/gcc/fortran/trans-array.c +++ b/gcc/fortran/trans-array.c @@ -1694,6 +1694,13 @@ gfc_trans_array_constructor (gfc_loopinfo * loop, gfc_ss * ss, locus * where) tree type; tree loopfrom; bool dynamic; + bool old_first_len, old_typespec_chararray_ctor; + tree old_first_len_val; + + /* Save the old values for nested checking. */ + old_first_len = first_len; + old_first_len_val = first_len_val; + old_typespec_chararray_ctor = typespec_chararray_ctor; /* Do bounds-checking here and in gfc_trans_array_ctor_element only if no typespec was given for the array constructor. */ @@ -1792,7 +1799,7 @@ gfc_trans_array_constructor (gfc_loopinfo * loop, gfc_ss * ss, locus * where) if (size && compare_tree_int (size, nelem) == 0) { gfc_trans_constant_array_constructor (loop, ss, type); - return; + goto finish; } } } @@ -1849,6 +1856,12 @@ gfc_trans_array_constructor (gfc_loopinfo * loop, gfc_ss * ss, locus * where) gcc_unreachable (); } #endif + +finish: + /* Restore old values of globals. */ + first_len = old_first_len; + first_len_val = old_first_len_val; + typespec_chararray_ctor = old_typespec_chararray_ctor; } @@ -4080,7 +4093,7 @@ gfc_trans_auto_array_allocation (tree decl, gfc_symbol * sym, tree fnbody) if (sym->ts.type == BT_CHARACTER && onstack && !INTEGER_CST_P (sym->ts.cl->backend_decl)) { - gfc_conv_string_length (sym->ts.cl, &block); + gfc_conv_string_length (sym->ts.cl, NULL, &block); gfc_trans_vla_type_sizes (sym, &block); @@ -4104,7 +4117,7 @@ gfc_trans_auto_array_allocation (tree decl, gfc_symbol * sym, tree fnbody) if (sym->ts.type == BT_CHARACTER && !INTEGER_CST_P (sym->ts.cl->backend_decl)) - gfc_conv_string_length (sym->ts.cl, &block); + gfc_conv_string_length (sym->ts.cl, NULL, &block); size = gfc_trans_array_bounds (type, sym, &offset, &block); @@ -4170,7 +4183,7 @@ gfc_trans_g77_array (gfc_symbol * sym, tree body) if (sym->ts.type == BT_CHARACTER && TREE_CODE (sym->ts.cl->backend_decl) == VAR_DECL) - gfc_conv_string_length (sym->ts.cl, &block); + gfc_conv_string_length (sym->ts.cl, NULL, &block); /* Evaluate the bounds of the array. */ gfc_trans_array_bounds (type, sym, &offset, &block); @@ -4262,7 +4275,7 @@ gfc_trans_dummy_array_bias (gfc_symbol * sym, tree tmpdesc, tree body) if (sym->ts.type == BT_CHARACTER && TREE_CODE (sym->ts.cl->backend_decl) == VAR_DECL) - gfc_conv_string_length (sym->ts.cl, &block); + gfc_conv_string_length (sym->ts.cl, NULL, &block); checkparm = (sym->as->type == AS_EXPLICIT && flag_bounds_check); @@ -4848,7 +4861,6 @@ gfc_conv_expr_descriptor (gfc_se * se, gfc_expr * expr, gfc_ss * ss) break; } - gfc_init_loopinfo (&loop); /* Associate the SS with the loop. */ @@ -4872,7 +4884,7 @@ gfc_conv_expr_descriptor (gfc_se * se, gfc_expr * expr, gfc_ss * ss) loop.temp_ss->next = gfc_ss_terminator; if (expr->ts.type == BT_CHARACTER && !expr->ts.cl->backend_decl) - gfc_conv_string_length (expr->ts.cl, &se->pre); + gfc_conv_string_length (expr->ts.cl, expr, &se->pre); loop.temp_ss->data.temp.type = gfc_typenode_for_spec (&expr->ts); @@ -5672,7 +5684,7 @@ gfc_trans_deferred_array (gfc_symbol * sym, tree body) if (sym->ts.type == BT_CHARACTER && !INTEGER_CST_P (sym->ts.cl->backend_decl)) { - gfc_conv_string_length (sym->ts.cl, &fnblock); + gfc_conv_string_length (sym->ts.cl, NULL, &fnblock); gfc_trans_vla_type_sizes (sym, &fnblock); } |