From: Thomas Koenig <tkoenig@netcologne.de>
To: "fortran@gcc.gnu.org" <fortran@gcc.gnu.org>,
gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [patch, fortran] Fix PR 88871
Date: Thu, 17 Jan 2019 06:31:00 -0000 [thread overview]
Message-ID: <61631d6c-bf99-b4c9-227d-45a254a2d007@netcologne.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 503 bytes --]
Hello world,
the attached patch fixes PR 88871, a regression introduced by
my recent patch for removing unnecessary substrings.
Regression-tested; this now also works with valgrind on Linux,
where the failure did not show up otherwise.
No test case because, well - it did show up on a few systems, so we will
notice if it regresses. OK for trunk?
Regards
Thomas
2019-01-17 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/88871
* resolve.c (resolve_ref): Fix logic for removal of
reference.
[-- Attachment #2: p3.diff --]
[-- Type: text/x-patch, Size: 1483 bytes --]
Index: resolve.c
===================================================================
--- resolve.c (Revision 267953)
+++ resolve.c (Arbeitskopie)
@@ -5046,6 +5046,7 @@ resolve_ref (gfc_expr *expr)
int current_part_dimension, n_components, seen_part_dimension;
gfc_ref *ref, **prev;
bool equal_length;
+ bool breakout;
for (ref = expr->ref; ref; ref = ref->next)
if (ref->type == REF_ARRAY && ref->u.ar.as == NULL)
@@ -5054,12 +5055,12 @@ resolve_ref (gfc_expr *expr)
break;
}
-
- for (ref = expr->ref, prev = &expr->ref; ref; prev = &ref->next, ref = ref->next)
- switch (ref->type)
+ breakout = false;
+ for (prev = &expr->ref; !breakout && *prev != NULL; prev = &(*prev)->next)
+ switch ((*prev)->type)
{
case REF_ARRAY:
- if (!resolve_array_ref (&ref->u.ar))
+ if (!resolve_array_ref (&(*prev)->u.ar))
return false;
break;
@@ -5069,17 +5070,20 @@ resolve_ref (gfc_expr *expr)
case REF_SUBSTRING:
equal_length = false;
- if (!resolve_substring (ref, &equal_length))
+ if (!resolve_substring (*prev, &equal_length))
return false;
if (expr->expr_type != EXPR_SUBSTRING && equal_length)
{
/* Remove the reference and move the charlen, if any. */
+ ref = *prev;
*prev = ref->next;
ref->next = NULL;
expr->ts.u.cl = ref->u.ss.length;
ref->u.ss.length = NULL;
gfc_free_ref_list (ref);
+ if (*prev == NULL)
+ breakout = true;
}
break;
}
next reply other threads:[~2019-01-17 6:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-17 6:31 Thomas Koenig [this message]
2019-01-18 17:09 ` Thomas Koenig
2019-01-18 21:50 ` ChangeLog formatting nits Jakub Jelinek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=61631d6c-bf99-b4c9-227d-45a254a2d007@netcologne.de \
--to=tkoenig@netcologne.de \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).