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 r12-8529] Fortran: fix checking of arguments to UNPACK when MASK is a variable [PR105813] Date: Thu, 30 Jun 2022 20:02:17 +0000 (GMT) [thread overview] Message-ID: <20220630200217.AA94F3858010@sourceware.org> (raw) https://gcc.gnu.org/g:eb4336f546b2a770717af608c79b4d46f45ef7c2 commit r12-8529-geb4336f546b2a770717af608c79b4d46f45ef7c2 Author: Harald Anlauf <anlauf@gmx.de> Date: Fri Jun 24 22:21:39 2022 +0200 Fortran: fix checking of arguments to UNPACK when MASK is a variable [PR105813] gcc/fortran/ChangeLog: PR fortran/105813 * check.cc (gfc_check_unpack): Try to simplify MASK argument to UNPACK so that checking of the VECTOR argument can work when MASK is a variable. gcc/testsuite/ChangeLog: PR fortran/105813 * gfortran.dg/unpack_vector_1.f90: New test. (cherry picked from commit f21f17f95c0237f4f987a5fa9f1fa9c7e0db3c40) Diff: --- gcc/fortran/check.cc | 2 ++ gcc/testsuite/gfortran.dg/unpack_vector_1.f90 | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/gcc/fortran/check.cc b/gcc/fortran/check.cc index 0c2cb50c6a7..91d87a1b2c1 100644 --- a/gcc/fortran/check.cc +++ b/gcc/fortran/check.cc @@ -6353,6 +6353,8 @@ gfc_check_unpack (gfc_expr *vector, gfc_expr *mask, gfc_expr *field) if (!same_type_check (vector, 0, field, 2)) return false; + gfc_simplify_expr (mask, 0); + if (mask->expr_type == EXPR_ARRAY && gfc_array_size (vector, &vector_size)) { diff --git a/gcc/testsuite/gfortran.dg/unpack_vector_1.f90 b/gcc/testsuite/gfortran.dg/unpack_vector_1.f90 new file mode 100644 index 00000000000..5347c111e8f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/unpack_vector_1.f90 @@ -0,0 +1,12 @@ +! { dg-do compile } +! PR fortran/105813 +! Fix checking of VECTOR argument to UNPACK when MASK is a variable. +! Contributed by G.Steinmetz + +program p + logical, parameter :: mask(2,2) = reshape ([.true., .true., & + .false., .true.], & + shape (mask)) + print *, unpack ([1,2,3], mask, 0) ! OK + print *, unpack ([1,2], mask, 0) ! { dg-error "must provide at least" } +end
reply other threads:[~2022-06-30 20:02 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=20220630200217.AA94F3858010@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).