diff options
author | Paul Thomas <pault@gcc.gnu.org> | 2009-08-05 16:10:19 +0000 |
---|---|---|
committer | Paul Thomas <pault@gcc.gnu.org> | 2009-08-05 16:10:19 +0000 |
commit | fd1e840d81c4d581d118ef1890e682fb90a4a72b (patch) | |
tree | c665e2426f5c2db1de2f984e9fe9682991a6da62 /gcc/fortran/iresolve.c | |
parent | ec52288b33d1928b62fd5ef9ae576d1cf8b51774 (diff) | |
download | gcc-fd1e840d81c4d581d118ef1890e682fb90a4a72b.zip gcc-fd1e840d81c4d581d118ef1890e682fb90a4a72b.tar.gz gcc-fd1e840d81c4d581d118ef1890e682fb90a4a72b.tar.bz2 |
re PR fortran/40847 (segfault & bogus warning)
2009-08-05 Paul Thomas <pault@gcc.gnu.org>
PR fortran/40847
* iresolve.c (gfc_resolve_transfer): Correct error in 'mold'
character length for case where length expresson is NULL.
2009-08-05 Paul Thomas <pault@gcc.gnu.org>
PR fortran/40847
* gfortran.dg/transfer_resolve_1.f90 : New test.
From-SVN: r150493
Diffstat (limited to 'gcc/fortran/iresolve.c')
-rw-r--r-- | gcc/fortran/iresolve.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/gcc/fortran/iresolve.c b/gcc/fortran/iresolve.c index fdbf40c..5bb24a4 100644 --- a/gcc/fortran/iresolve.c +++ b/gcc/fortran/iresolve.c @@ -2340,9 +2340,19 @@ gfc_resolve_transfer (gfc_expr *f, gfc_expr *source ATTRIBUTE_UNUSED, /* TODO: Make this do something meaningful. */ static char transfer0[] = "__transfer0", transfer1[] = "__transfer1"; - if (mold->ts.type == BT_CHARACTER && !mold->ts.cl->length - && !(mold->expr_type == EXPR_VARIABLE && mold->symtree->n.sym->attr.dummy)) - mold->ts.cl->length = gfc_int_expr (mold->value.character.length); + if (mold->ts.type == BT_CHARACTER + && !mold->ts.cl->length + && gfc_is_constant_expr (mold)) + { + int len; + if (mold->expr_type == EXPR_CONSTANT) + mold->ts.cl->length = gfc_int_expr (mold->value.character.length); + else + { + len = mold->value.constructor->expr->value.character.length; + mold->ts.cl->length = gfc_int_expr (len); + } + } f->ts = mold->ts; |