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 r11-10284] Fortran: error recovery while simplifying intrinsic UNPACK [PR107054]
Date: Fri, 30 Sep 2022 20:33:32 +0000 (GMT) [thread overview]
Message-ID: <20220930203332.8FFDD385483E@sourceware.org> (raw)
https://gcc.gnu.org/g:c4f53f59aaa208f6c7aff0a8b4fb1950b1dc75a0
commit r11-10284-gc4f53f59aaa208f6c7aff0a8b4fb1950b1dc75a0
Author: Harald Anlauf <anlauf@gmx.de>
Date: Tue Sep 27 20:54:28 2022 +0200
Fortran: error recovery while simplifying intrinsic UNPACK [PR107054]
gcc/fortran/ChangeLog:
PR fortran/107054
* simplify.c (gfc_simplify_unpack): Replace assert by condition
that terminates simplification when there are not enough elements
in the constructor of argument VECTOR.
gcc/testsuite/ChangeLog:
PR fortran/107054
* gfortran.dg/pr107054.f90: New test.
(cherry picked from commit 78bc6497fc61bbdacfb416ee0246a775360d9af6)
Diff:
---
gcc/fortran/simplify.c | 13 ++++++++++---
gcc/testsuite/gfortran.dg/pr107054.f90 | 13 +++++++++++++
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index 3b033a6be92..f13a8e57c83 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -8409,9 +8409,16 @@ gfc_simplify_unpack (gfc_expr *vector, gfc_expr *mask, gfc_expr *field)
{
if (mask_ctor->expr->value.logical)
{
- gcc_assert (vector_ctor);
- e = gfc_copy_expr (vector_ctor->expr);
- vector_ctor = gfc_constructor_next (vector_ctor);
+ if (vector_ctor)
+ {
+ e = gfc_copy_expr (vector_ctor->expr);
+ vector_ctor = gfc_constructor_next (vector_ctor);
+ }
+ else
+ {
+ gfc_free_expr (result);
+ return NULL;
+ }
}
else if (field->expr_type == EXPR_ARRAY)
e = gfc_copy_expr (field_ctor->expr);
diff --git a/gcc/testsuite/gfortran.dg/pr107054.f90 b/gcc/testsuite/gfortran.dg/pr107054.f90
new file mode 100644
index 00000000000..bbfe646beba
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr107054.f90
@@ -0,0 +1,13 @@
+! { dg-do compile }
+! PR fortran/107054 - ICE in gfc_simplify_unpack
+! Contributed by G.Steinmetz
+
+program p
+ type t
+ integer :: n = 0
+ end type
+ type(t), parameter :: a(4) = t(2)
+ type(t), parameter :: b(4) = reshape(a,[2]) ! { dg-error "Different shape" }
+ type(t), parameter :: c(2) = pack(b,[.false.,.true.,.false.,.true.]) ! { dg-error "Different shape" }
+ type(t), parameter :: d(4) = unpack(c,[.false.,.true.,.false.,.true.],a)
+end
reply other threads:[~2022-09-30 20:33 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=20220930203332.8FFDD385483E@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: 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).