diff options
author | pault <pault@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-10-18 09:31:21 +0000 |
---|---|---|
committer | pault <pault@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-10-18 09:31:21 +0000 |
commit | 6f29994cb8c6a797f241adac76663143309c03dd (patch) | |
tree | a0441a3335a1f9021773ff84b515947483dce8b6 /gcc/fortran/primary.c | |
parent | 35ece5a6f82ab846ceb930661f50e4ba192ba682 (diff) | |
download | gcc-6f29994cb8c6a797f241adac76663143309c03dd.tar.gz |
2015-10-18 Paul Thomas <pault@gcc.gnu.org>
PR fortran/67177
PR fortran/67977
* primary.c (match_substring): Add an argument 'deferred' to
flag that a substring reference with null start and end should
not be optimized away for deferred length strings.
(match_string_constant, gfc_match_rvalue): Set the argument.
* trans-expr.c (alloc_scalar_allocatable_for_assignment): If
there is a substring reference return.
* trans-intrinsic.c (conv_intrinsic_move_alloc): For deferred
characters, assign the 'from' string length to the 'to' string
length. If the 'from' expression is deferred, set its string
length to zero. If the 'to' expression has allocatable
components, deallocate them.
2015-10-18 Paul Thomas <pault@gcc.gnu.org>
PR fortran/67177
* gfortran.dg/move_alloc_15.f90: New test
* gfortran.dg/move_alloc_16.f90: New test
PR fortran/67977
* gfortran.dg/deferred_character_assignment_1.f90: New test
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228940 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/primary.c')
-rw-r--r-- | gcc/fortran/primary.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c index 9f75666becf..e39c89054d6 100644 --- a/gcc/fortran/primary.c +++ b/gcc/fortran/primary.c @@ -761,7 +761,7 @@ done: { if (*p == '.') continue; - + if (*p != '0') { *p = '0'; @@ -800,7 +800,7 @@ cleanup: /* Match a substring reference. */ static match -match_substring (gfc_charlen *cl, int init, gfc_ref **result) +match_substring (gfc_charlen *cl, int init, gfc_ref **result, bool deferred) { gfc_expr *start, *end; locus old_loc; @@ -852,7 +852,7 @@ match_substring (gfc_charlen *cl, int init, gfc_ref **result) } /* Optimize away the (:) reference. */ - if (start == NULL && end == NULL) + if (start == NULL && end == NULL && !deferred) ref = NULL; else { @@ -1150,7 +1150,7 @@ got_delim: if (ret != -1) gfc_internal_error ("match_string_constant(): Delimiter not found"); - if (match_substring (NULL, 0, &e->ref) != MATCH_NO) + if (match_substring (NULL, 0, &e->ref, false) != MATCH_NO) e->expr_type = EXPR_SUBSTRING; *result = e; @@ -2133,7 +2133,8 @@ check_substring: if (primary->ts.type == BT_CHARACTER) { - switch (match_substring (primary->ts.u.cl, equiv_flag, &substring)) + bool def = primary->ts.deferred == 1; + switch (match_substring (primary->ts.u.cl, equiv_flag, &substring, def)) { case MATCH_YES: if (tail == NULL) @@ -3147,7 +3148,7 @@ gfc_match_rvalue (gfc_expr **result) that we're not sure is a variable yet. */ if ((implicit_char || sym->ts.type == BT_CHARACTER) - && match_substring (sym->ts.u.cl, 0, &e->ref) == MATCH_YES) + && match_substring (sym->ts.u.cl, 0, &e->ref, false) == MATCH_YES) { e->expr_type = EXPR_VARIABLE; |