public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Harald Anlauf <anlauf@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4595] Fortran: reject bad SIZE argument while simplifying ISHFTC [PR106911] Date: Sat, 10 Dec 2022 21:31:57 +0000 (GMT) [thread overview] Message-ID: <20221210213157.237FF38493C3@sourceware.org> (raw) https://gcc.gnu.org/g:ae4438537fbc2ed04f3b0fb32d4e02b0ed6977a1 commit r13-4595-gae4438537fbc2ed04f3b0fb32d4e02b0ed6977a1 Author: Harald Anlauf <anlauf@gmx.de> Date: Sat Dec 10 22:05:15 2022 +0100 Fortran: reject bad SIZE argument while simplifying ISHFTC [PR106911] gcc/fortran/ChangeLog: PR fortran/106911 * simplify.cc (gfc_simplify_ishftc): If the SIZE argument is known to be outside the allowed range, terminate simplification. gcc/testsuite/ChangeLog: PR fortran/106911 * gfortran.dg/pr106911.f90: New test. Diff: --- gcc/fortran/simplify.cc | 3 +++ gcc/testsuite/gfortran.dg/pr106911.f90 | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc index aff9a1b8ced..3d3aaba84df 100644 --- a/gcc/fortran/simplify.cc +++ b/gcc/fortran/simplify.cc @@ -3955,6 +3955,9 @@ gfc_simplify_ishftc (gfc_expr *e, gfc_expr *s, gfc_expr *sz) return NULL; gfc_extract_int (sz, &ssize); + + if (ssize > isize || ssize <= 0) + return &gfc_bad_expr; } else ssize = isize; diff --git a/gcc/testsuite/gfortran.dg/pr106911.f90 b/gcc/testsuite/gfortran.dg/pr106911.f90 new file mode 100644 index 00000000000..f3fe7f6ad68 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr106911.f90 @@ -0,0 +1,18 @@ +! { dg-do compile } +! PR fortran/106911 - ICE in gfc_convert_mpz_to_signed +! Contributed by G.Steinmetz + +program p + implicit none + integer, parameter :: a = 10 + integer, parameter :: b = 20 + integer, parameter :: c = ishftc(1_1, a, b) ! { dg-error "must be less than or equal" } + integer, parameter :: d = ishftc(1_1, a, 0) ! { dg-error "must be positive" } + interface + subroutine s + import :: a, b + integer, parameter :: e = ishftc(1_1, a, b) ! { dg-error "must be less than or equal" } + integer, parameter :: f = ishftc(1_1, a, 0) ! { dg-error "must be positive" } + end + end interface +end
reply other threads:[~2022-12-10 21:31 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20221210213157.237FF38493C3@sourceware.org \ --to=anlauf@gcc.gnu.org \ --cc=gcc-cvs@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: linkBe 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).