From: Steve Kargl <sgk@troutmask.apl.washington.edu>
To: fortran@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [PATCH] PR fortran/36192 -- Check for valid BT_INTEGER
Date: Mon, 26 Oct 2015 01:16:00 -0000 [thread overview]
Message-ID: <20151026011639.GA34497@troutmask.apl.washington.edu> (raw)
[-- Attachment #1: Type: text/plain, Size: 445 bytes --]
The attached patch fixes a segfault in f951 for some poorly
written invalid code. See the testcase for the code in
question. Built and tested on i386-*-freebsd. Ok to commit?
2015-10-25 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/36192
* array.c (gfc_ref_dimen_size): Check for BT_INTEGER before calling
mpz_set.
2015-10-25 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/36192
* gfortran.dg/pr36192.f90: New test.
--
Steve
[-- Attachment #2: pr36192.diff --]
[-- Type: text/x-diff, Size: 1497 bytes --]
Index: gcc/fortran/array.c
===================================================================
--- gcc/fortran/array.c (revision 229301)
+++ gcc/fortran/array.c (working copy)
@@ -2208,7 +2208,8 @@ gfc_ref_dimen_size (gfc_array_ref *ar, i
if (ar->start[dimen] == NULL)
{
if (ar->as->lower[dimen] == NULL
- || ar->as->lower[dimen]->expr_type != EXPR_CONSTANT)
+ || ar->as->lower[dimen]->expr_type != EXPR_CONSTANT
+ || ar->as->lower[dimen]->ts.type != BT_INTEGER)
goto cleanup;
mpz_set (lower, ar->as->lower[dimen]->value.integer);
}
@@ -2222,7 +2223,8 @@ gfc_ref_dimen_size (gfc_array_ref *ar, i
if (ar->end[dimen] == NULL)
{
if (ar->as->upper[dimen] == NULL
- || ar->as->upper[dimen]->expr_type != EXPR_CONSTANT)
+ || ar->as->upper[dimen]->expr_type != EXPR_CONSTANT
+ || ar->as->upper[dimen]->ts.type != BT_INTEGER)
goto cleanup;
mpz_set (upper, ar->as->upper[dimen]->value.integer);
}
Index: gcc/testsuite/gfortran.dg/pr36192.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr36192.f90 (revision 0)
+++ gcc/testsuite/gfortran.dg/pr36192.f90 (working copy)
@@ -0,0 +1,9 @@
+! { dg-do compile }
+! PR fortran/36192.f90
+!
+program three_body
+ real, parameter :: n = 2, d = 2
+ real, dimension(n,d) :: x ! { dg-error "of INTEGER type|of INTEGER type" }
+ x(1,:) = (/ 1.0, 0.0 /)
+end program three_body
+! { dg-prune-output "have constant shape" }
next reply other threads:[~2015-10-26 1:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-26 1:16 Steve Kargl [this message]
2015-10-26 8:49 ` FX
2015-10-26 13:46 ` Steve Kargl
2015-10-26 14:43 ` FX
2015-10-26 16:12 ` Steve Kargl
2015-10-26 10:15 Dominique d'Humières
2015-10-26 16:29 ` Dominique d'Humières
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=20151026011639.GA34497@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).