public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR fortran/68283 -- remove a rogue gfc_internal_error()
@ 2015-11-11 18:34 Steve Kargl
  2015-11-11 19:20 ` Jerry DeLisle
  0 siblings, 1 reply; 5+ messages in thread
From: Steve Kargl @ 2015-11-11 18:34 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 731 bytes --]

This probably falls under the "obviously correct" moniker.
It has been built and tested on i386-*-freebsd.  OK to commit?

The patch removes a gfc_internal_error().  I suspect that it
was originally put into gfortran to cover "correctly written
valid Fortran code cannot possibly ever hit this line of 
code; so, it must be an internal error to reach this line".
The code in PR 68283 is not valid Fortran.  A number of error
messages are spewed by gfortran prior to hitting this line of code.
The patch simply removes the gfc_internal_error(), which allows
gfortran to exit gracefully.

2015-11-11  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/68283
	* primary.c (gfc_variable_attr): Remove a gfc_internal_error().

-- 
Steve

[-- Attachment #2: pr68283.diff --]
[-- Type: text/x-diff, Size: 414 bytes --]

Index: gcc/fortran/primary.c
===================================================================
--- gcc/fortran/primary.c	(revision 229970)
+++ gcc/fortran/primary.c	(working copy)
@@ -2268,8 +2268,6 @@ gfc_variable_attr (gfc_expr *expr, gfc_t
 		    && errors > 0)
 		  break;
 	      }
-	    if (n == ref->u.ar.as->rank)
-	      gfc_internal_error ("gfc_variable_attr(): Bad array reference");
 	  }
 
 	break;

^ permalink raw reply	[flat|nested] 5+ messages in thread
* Re: [PATCH] PR fortran/68283 -- remove a rogue gfc_internal_error()
@ 2015-11-14 13:51 Dominique d'Humières
  2015-11-14 15:30 ` Thomas Koenig
  2015-11-14 17:22 ` Steve Kargl
  0 siblings, 2 replies; 5+ messages in thread
From: Dominique d'Humières @ 2015-11-14 13:51 UTC (permalink / raw)
  To: Steve Kargl; +Cc: jvdelisle, tkoenig, Paul Richard Thomas, fortran, gcc-patches

Hi Steve,

Although I have not strong objection to your proposed patch, I’ld prefer the following one

--- ../_clean/gcc/fortran/primary.c	2015-10-18 13:07:28.000000000 +0200
+++ gcc/fortran/primary.c	2015-11-13 23:32:08.000000000 +0100
@@ -2194,7 +2194,7 @@ check_substring:
 symbol_attribute
 gfc_variable_attr (gfc_expr *expr, gfc_typespec *ts)
 {
-  int dimension, codimension, pointer, allocatable, target, n;
+  int dimension, codimension, pointer, allocatable, target;
   symbol_attribute attr;
   gfc_ref *ref;
   gfc_symbol *sym;
@@ -2253,22 +2253,9 @@ gfc_variable_attr (gfc_expr *expr, gfc_t
 	  case AR_UNKNOWN:
 	    /* If any of start, end or stride is not integer, there will
 	       already have been an error issued.  */
-	    for (n = 0; n < ref->u.ar.as->rank; n++)
-	      {
-		int errors;
-		gfc_get_errors (NULL, &errors);
-		if (((ref->u.ar.start[n]
-		      && ref->u.ar.start[n]->ts.type == BT_UNKNOWN)
-		     ||
-		     (ref->u.ar.end[n]
-		      && ref->u.ar.end[n]->ts.type == BT_UNKNOWN)
-		     ||
-		     (ref->u.ar.stride[n]
-		      && ref->u.ar.stride[n]->ts.type == BT_UNKNOWN))
-		    && errors > 0)
-		  break;
-	      }
-	    if (n == ref->u.ar.as->rank)
+	    int errors;
+	    gfc_get_errors (NULL, &errors);
+	    if (errors == 0)
 	      gfc_internal_error ("gfc_variable_attr(): Bad array reference");
 	  }
 
Now both patches are just papering over the real issues:

(1) Why is this block reached when compiling with -ffrontend-optimize, but not with -fno-frontend-optimize (Thomas)?
(2) Is there expected side effect(s) when removing the' for‘ block introduced at revision r221955 for pr56852 (Paul)?

Dominique

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

end of thread, other threads:[~2015-11-14 17:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-11 18:34 [PATCH] PR fortran/68283 -- remove a rogue gfc_internal_error() Steve Kargl
2015-11-11 19:20 ` Jerry DeLisle
2015-11-14 13:51 Dominique d'Humières
2015-11-14 15:30 ` Thomas Koenig
2015-11-14 17:22 ` Steve Kargl

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