* [patch, fortran] Fix PR 81116, missing dependency handling for allocatable character
@ 2017-08-07 19:59 Thomas Koenig
2017-08-13 20:41 ` *ping* " Thomas Koenig
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Koenig @ 2017-08-07 19:59 UTC (permalink / raw)
To: fortran, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 571 bytes --]
Hello world,
the attached patch fixes the PR by adding a dependency check
for the case of concatenation operators.
Regression-tested. OK for trunk?
Regards
Thomas
2017-08-07 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-07 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/81116
* gfortran.dg/realloc_on_assignment_29.f90: New test.
[-- Attachment #2: p1.diff --]
[-- Type: text/x-patch, Size: 1405 bytes --]
Index: frontend-passes.c
===================================================================
--- frontend-passes.c (Revision 250720)
+++ frontend-passes.c (Arbeitskopie)
@@ -238,21 +238,25 @@ realloc_string_callback (gfc_code **c, int *walk_s
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);
[-- Attachment #3: realloc_on_assign_29.f90 --]
[-- Type: text/x-fortran, Size: 321 bytes --]
! { dg-do run }
! PR fortran/81116
! The assignment was broken due to a missing temporary.
! Original test case by Clive Page.
program test10
implicit none
character(:), allocatable :: string
!
string = '1234567890'
string = string(1:5) // string(7:)
if (string /= '123457890') call abort
end program test10
^ permalink raw reply [flat|nested] 3+ messages in thread
* *ping* [patch, fortran] Fix PR 81116, missing dependency handling for allocatable character
2017-08-07 19:59 [patch, fortran] Fix PR 81116, missing dependency handling for allocatable character Thomas Koenig
@ 2017-08-13 20:41 ` Thomas Koenig
2017-08-16 3:09 ` Jerry DeLisle
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Koenig @ 2017-08-13 20:41 UTC (permalink / raw)
To: fortran, gcc-patches
> the attached patch fixes the PR by adding a dependency check
> for the case of concatenation operators.
>
> Regression-tested. OK for trunk?
Ping?
Regards
Thomas
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: *ping* [patch, fortran] Fix PR 81116, missing dependency handling for allocatable character
2017-08-13 20:41 ` *ping* " Thomas Koenig
@ 2017-08-16 3:09 ` Jerry DeLisle
0 siblings, 0 replies; 3+ messages in thread
From: Jerry DeLisle @ 2017-08-16 3:09 UTC (permalink / raw)
To: Thomas Koenig, fortran, gcc-patches
On 08/13/2017 10:35 AM, Thomas Koenig wrote:
>
>> the attached patch fixes the PR by adding a dependency check
>> for the case of concatenation operators.
>>
>> Regression-tested. OK for trunk?
>
> Ping?
>
> Regards
>
> Thomas
OK,
Thanks for patch.
Jerry
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-08-16 0:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-07 19:59 [patch, fortran] Fix PR 81116, missing dependency handling for allocatable character Thomas Koenig
2017-08-13 20:41 ` *ping* " Thomas Koenig
2017-08-16 3:09 ` Jerry DeLisle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).