diff options
author | Mikael Morin <mikael.morin@tele2.fr> | 2008-10-31 16:56:21 +0100 |
---|---|---|
committer | Mikael Morin <mikael@gcc.gnu.org> | 2008-10-31 15:56:21 +0000 |
commit | d3d0b9e07f69bd21120ebdeac22d4e197b7dfd1c (patch) | |
tree | 811f4814607616ee07e17c7629a183aa38712469 /gcc/fortran/expr.c | |
parent | 0e6834af18d539e4615be54eb2f9262898add8b4 (diff) | |
download | gcc-d3d0b9e07f69bd21120ebdeac22d4e197b7dfd1c.zip gcc-d3d0b9e07f69bd21120ebdeac22d4e197b7dfd1c.tar.gz gcc-d3d0b9e07f69bd21120ebdeac22d4e197b7dfd1c.tar.bz2 |
re PR fortran/35840 (ICE for character expression in I/O specifier)
2008-10-31 Mikael Morin <mikael.morin@tele2.fr>
PR fortran/35840
* expr.c (gfc_reduce_init_expr): New function, containing checking code
from gfc_match_init_expr, so that checking can be deferred.
(gfc_match_init_expr): Use gfc_reduce_init_expr.
* io.c (check_io_constraints): Use gfc_reduce_init_expr instead of
checking that the expression is a constant.
* match.h (gfc_reduce_init_expr): Prototype added.
2008-10-31 Mikael Morin <mikael.morin@tele2.fr>
PR fortran/35840
* gfortran.dg/write_check4.f90: New test.
From-SVN: r141497
Diffstat (limited to 'gcc/fortran/expr.c')
-rw-r--r-- | gcc/fortran/expr.c | 55 |
1 files changed, 35 insertions, 20 deletions
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c index 73f2c40..1a5e6db 100644 --- a/gcc/fortran/expr.c +++ b/gcc/fortran/expr.c @@ -2378,21 +2378,15 @@ check_init_expr (gfc_expr *e) return t; } +/* Reduces a general expression to an initialization expression (a constant). + This used to be part of gfc_match_init_expr. + Note that this function doesn't free the given expression on FAILURE. */ -/* Match an initialization expression. We work by first matching an - expression, then reducing it to a constant. */ - -match -gfc_match_init_expr (gfc_expr **result) +gfc_try +gfc_reduce_init_expr (gfc_expr *expr) { - gfc_expr *expr; - match m; gfc_try t; - m = gfc_match_expr (&expr); - if (m != MATCH_YES) - return m; - gfc_init_expr = 1; t = gfc_resolve_expr (expr); if (t == SUCCESS) @@ -2400,18 +2394,12 @@ gfc_match_init_expr (gfc_expr **result) gfc_init_expr = 0; if (t == FAILURE) - { - gfc_free_expr (expr); - return MATCH_ERROR; - } + return FAILURE; if (expr->expr_type == EXPR_ARRAY && (gfc_check_constructor_type (expr) == FAILURE - || gfc_expand_constructor (expr) == FAILURE)) - { - gfc_free_expr (expr); - return MATCH_ERROR; - } + || gfc_expand_constructor (expr) == FAILURE)) + return FAILURE; /* Not all inquiry functions are simplified to constant expressions so it is necessary to call check_inquiry again. */ @@ -2419,6 +2407,33 @@ gfc_match_init_expr (gfc_expr **result) && !gfc_in_match_data ()) { gfc_error ("Initialization expression didn't reduce %C"); + return FAILURE; + } + + return SUCCESS; +} + + +/* Match an initialization expression. We work by first matching an + expression, then reducing it to a constant. */ + +match +gfc_match_init_expr (gfc_expr **result) +{ + gfc_expr *expr; + match m; + gfc_try t; + + expr = NULL; + + m = gfc_match_expr (&expr); + if (m != MATCH_YES) + return m; + + t = gfc_reduce_init_expr (expr); + if (t != SUCCESS) + { + gfc_free_expr (expr); return MATCH_ERROR; } |