public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch, fortran] Fix PR 88871
@ 2019-01-17  6:31 Thomas Koenig
  2019-01-18 17:09 ` Thomas Koenig
  2019-01-18 21:50 ` ChangeLog formatting nits Jakub Jelinek
  0 siblings, 2 replies; 3+ messages in thread
From: Thomas Koenig @ 2019-01-17  6:31 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- 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;
       }

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch, fortran] Fix PR 88871
  2019-01-17  6:31 [patch, fortran] Fix PR 88871 Thomas Koenig
@ 2019-01-18 17:09 ` Thomas Koenig
  2019-01-18 21:50 ` ChangeLog formatting nits Jakub Jelinek
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Koenig @ 2019-01-18 17:09 UTC (permalink / raw)
  To: fortran, gcc-patches

Am 17.01.19 um 07:30 schrieb Thomas Koenig:
> 
> No test case because, well - it did show up on a few systems, so we will
> notice if it regresses. OK for trunk?

Both Dominique and Jürgen confirmed that it fixes the PR.

I will commit this tomorrow unless there are any objections - I'd
like to get this out of the way.

Regards

	Thomas

^ permalink raw reply	[flat|nested] 3+ messages in thread

* ChangeLog formatting nits
  2019-01-17  6:31 [patch, fortran] Fix PR 88871 Thomas Koenig
  2019-01-18 17:09 ` Thomas Koenig
@ 2019-01-18 21:50 ` Jakub Jelinek
  1 sibling, 0 replies; 3+ messages in thread
From: Jakub Jelinek @ 2019-01-18 21:50 UTC (permalink / raw)
  To: Thomas Koenig, Paul Thomas; +Cc: fortran, gcc-patches

Hi!

On Thu, Jan 17, 2019 at 07:30:34AM +0100, Thomas Koenig wrote:
> 2019-01-17  Thomas Koenig  <tkoenig@gcc.gnu.org>
> 
> 	PR fortran/88871
> 	* resolve.c (resolve_ref):  Fix logic for removal of
> 	reference.

Just a few ChangeLog formatting nits of what I've seen recently from
multiple people, there should be exactly one space after ):, not two,
and there should be no space between ) and :, or, if there is just
filename, between filename and :, so
	* filename.whatever : New test.
is not correct and it should be
	* filename.whatever: New test.
Similarly:
	* filename.whatever : External declarations for foo and blah.
etc. should be
	* filename.whatever (foo, blah): Declare.
or similar.

Thanks.

	Jakub

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-01-18 21:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-17  6:31 [patch, fortran] Fix PR 88871 Thomas Koenig
2019-01-18 17:09 ` Thomas Koenig
2019-01-18 21:50 ` ChangeLog formatting nits Jakub Jelinek

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).