public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Steve Kargl <sgk@troutmask.apl.washington.edu>
To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [PATCH] PR fortran/36192 -- yet another fix for an ICE
Date: Thu, 29 Oct 2015 18:36:00 -0000	[thread overview]
Message-ID: <20151029183512.GA67095@troutmask.apl.washington.edu> (raw)

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

The patch for PR fortran/36192 that I committed here:

https://gcc.gnu.org/ml/gcc-bugs/2015-10/msg02160.html

cured an ICE for a testcase that was reduced from the
originally submitted mutilated Fortran code.  The 
original code could in fact invoke another ICE.  This
patch cures that ICE.  The patch simply checks that
the array indices have INTEGER type before calling
GMP routines.  Tested om x86_64-*-freebsd.
OK to commit?

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

	PR fortran/36192
	* interface.c (get_expr_storage_size):  Check for INTEGER type before
	calling gmp routines.

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

	PR fortran/36192
	* gfortran.dg/pr36192_1.f90: New test.

-- 
Steve

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

Index: gcc/fortran/interface.c
===================================================================
--- gcc/fortran/interface.c	(revision 229542)
+++ gcc/fortran/interface.c	(working copy)
@@ -2455,7 +2455,9 @@ get_expr_storage_size (gfc_expr *e)
 	  {
 	    if (ref->u.ar.as->lower[i] && ref->u.ar.as->upper[i]
 		&& ref->u.ar.as->lower[i]->expr_type == EXPR_CONSTANT
-		&& ref->u.ar.as->upper[i]->expr_type == EXPR_CONSTANT)
+		&& ref->u.ar.as->lower[i]->ts.type == BT_INTEGER
+		&& ref->u.ar.as->upper[i]->expr_type == EXPR_CONSTANT
+		&& ref->u.ar.as->upper[i]->ts.type == BT_INTEGER)
 	      elements *= mpz_get_si (ref->u.ar.as->upper[i]->value.integer)
 			  - mpz_get_si (ref->u.ar.as->lower[i]->value.integer)
 			  + 1L;
Index: gcc/testsuite/gfortran.dg/pr36192_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr36192_1.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/pr36192_1.f90	(working copy)
@@ -0,0 +1,12 @@
+! { dg-do compile }
+! PR fortran/36192
+program three_body
+   real, parameter ::  n = 2, d = 2
+   real, dimension(n,d) :: x_hq ! { dg-error "of INTEGER type|of INTEGER type" }
+   call step(x_hq)
+   contains
+   subroutine step(x)
+      real, dimension(:,:), intent(in) :: x
+   end subroutine step
+end program three_body
+! { dg-prune-output "must have constant shape" }

             reply	other threads:[~2015-10-29 18:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-29 18:36 Steve Kargl [this message]
2015-10-29 20:15 ` Thomas Koenig

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=20151029183512.GA67095@troutmask.apl.washington.edu \
    --to=sgk@troutmask.apl.washington.edu \
    --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).