diff options
author | Thomas Koenig <tkoenig@gcc.gnu.org> | 2016-09-04 16:17:55 +0000 |
---|---|---|
committer | Thomas Koenig <tkoenig@gcc.gnu.org> | 2016-09-04 16:17:55 +0000 |
commit | d6598cf719fb63ead5618cf8908218519e82cc3e (patch) | |
tree | 7ba3242cce173a116ef52dac87549f58429914c0 /gcc/fortran/frontend-passes.c | |
parent | abb62d32a1f472ba3b1f9ae07bcdcc1d7f014699 (diff) | |
download | gcc-d6598cf719fb63ead5618cf8908218519e82cc3e.zip gcc-d6598cf719fb63ead5618cf8908218519e82cc3e.tar.gz gcc-d6598cf719fb63ead5618cf8908218519e82cc3e.tar.bz2 |
re PR fortran/71902 (Unneeded temporary on reallocatable character assignment)
2016-09-04 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/71902
* frontend-passes.c (realloc_string_callback): Also check for the
lhs being deferred. Name temporary variable "realloc_string".
2016-09-04 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/71902
* gfortran.dg/dependency_47.f90: New test.
* gfortran.dg/dependency_49.f90: New test.
From-SVN: r239977
Diffstat (limited to 'gcc/fortran/frontend-passes.c')
-rw-r--r-- | gcc/fortran/frontend-passes.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/gcc/fortran/frontend-passes.c b/gcc/fortran/frontend-passes.c index c138f4d..cd10979 100644 --- a/gcc/fortran/frontend-passes.c +++ b/gcc/fortran/frontend-passes.c @@ -164,19 +164,34 @@ realloc_string_callback (gfc_code **c, int *walk_subtrees ATTRIBUTE_UNUSED, gfc_expr *expr1, *expr2; gfc_code *co = *c; gfc_expr *n; + gfc_ref *ref; + bool found_substr; if (co->op != EXEC_ASSIGN) return 0; expr1 = co->expr1; if (expr1->ts.type != BT_CHARACTER || expr1->rank != 0 - || !expr1->symtree->n.sym->attr.allocatable) + || !gfc_expr_attr(expr1).allocatable + || !expr1->ts.deferred) 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 (ref->type == REF_SUBSTRING) + { + found_substr = true; + break; + } + } + if (!found_substr) + return 0; + if (!gfc_check_dependency (expr1, expr2, true)) return 0; @@ -190,7 +205,7 @@ realloc_string_callback (gfc_code **c, int *walk_subtrees ATTRIBUTE_UNUSED, current_code = c; inserted_block = NULL; changed_statement = NULL; - n = create_var (expr2, "trim"); + n = create_var (expr2, "realloc_string"); co->expr2 = n; return 0; } |