aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorThomas Koenig <tkoenig@gcc.gnu.org>2017-08-16 17:21:22 +0000
committerThomas Koenig <tkoenig@gcc.gnu.org>2017-08-16 17:21:22 +0000
commitb68a9f34f170f48a08c737d1cbfdc147dc42f275 (patch)
treef665cf8546e9da726bb55ae84e899e0ff69146e1 /gcc/fortran
parentadb5b54b28383885b4a34b95698cc302af8e0415 (diff)
downloadgcc-b68a9f34f170f48a08c737d1cbfdc147dc42f275.zip
gcc-b68a9f34f170f48a08c737d1cbfdc147dc42f275.tar.gz
gcc-b68a9f34f170f48a08c737d1cbfdc147dc42f275.tar.bz2
re PR fortran/81116 (Last character of allocatable-length string reset to blank in an assigment)
2017-08-16 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/81116 * frontend-passes.c (realloc_string_callback): If expression is a concatenation, also check for dependency. (constant_string_length): Check for presence of symtree. 2017-08-16 Thomas Koenig <tkoenig@gcc.gnu.org> PR fortran/81116 * gfortran.dg/realloc_on_assignment_29.f90: New test. From-SVN: r251125
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog7
-rw-r--r--gcc/fortran/frontend-passes.c25
2 files changed, 22 insertions, 10 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 24e5a24..4a572cf 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,10 @@
+2017-08-16 Thomas Koenig <tkoenig@gcc.gnu.org>
+
+ PR fortran/81116
+ * frontend-passes.c (realloc_string_callback): If expression is a
+ concatenation, also check for dependency.
+ (constant_string_length): Check for presence of symtree.
+
2017-08-13 Thomas Koenig <tkoenig@gcc.gnu.org>
* gfortran.texi: Document format of unformatted sequential files.
diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c
index 11c7503..7a3d027 100644
--- a/gcc/fortran/frontend-passes.c
+++ b/gcc/fortran/frontend-passes.c
@@ -238,21 +238,25 @@ realloc_string_callback (gfc_code **c, int *walk_subtrees ATTRIBUTE_UNUSED,
return 0;
expr2 = gfc_discard_nops (co->expr2);
- if (expr2->expr_type != EXPR_VARIABLE)
- return 0;
- found_substr = false;
- for (ref = expr2->ref; ref; ref = ref->next)
+ if (expr2->expr_type == EXPR_VARIABLE)
{
- if (ref->type == REF_SUBSTRING)
+ found_substr = false;
+ for (ref = expr2->ref; ref; ref = ref->next)
{
- found_substr = true;
- break;
+ if (ref->type == REF_SUBSTRING)
+ {
+ found_substr = true;
+ break;
+ }
}
+ if (!found_substr)
+ return 0;
}
- if (!found_substr)
+ else if (expr2->expr_type != EXPR_OP
+ || expr2->value.op.op != INTRINSIC_CONCAT)
return 0;
-
+
if (!gfc_check_dependency (expr1, expr2, true))
return 0;
@@ -625,7 +629,8 @@ constant_string_length (gfc_expr *e)
/* Return length of char symbol, if constant. */
- if (e->symtree->n.sym->ts.u.cl && e->symtree->n.sym->ts.u.cl->length
+ if (e->symtree && e->symtree->n.sym->ts.u.cl
+ && e->symtree->n.sym->ts.u.cl->length
&& e->symtree->n.sym->ts.u.cl->length->expr_type == EXPR_CONSTANT)
return gfc_copy_expr (e->symtree->n.sym->ts.u.cl->length);