* [Regression, patch][Fortran] ICE in gfc_conv_constant_to_tree PR93604
@ 2020-02-17 11:26 Mark Eggleston
2020-02-24 12:05 ` Mark Eggleston
0 siblings, 1 reply; 3+ messages in thread
From: Mark Eggleston @ 2020-02-17 11:26 UTC (permalink / raw)
To: gcc-patches, fortran
[-- Attachment #1: Type: text/plain, Size: 636 bytes --]
Please find attached patch for PR93604.
gcc/fortran/ChangeLog
   Steven G. Kargl <kargl@gcc.gnu.org>
   PR fortran/93604
   * decl.c (gfc_match_data) : Check whether the data expression
   is a derived type and is a constructor. If a BOZ constant
   is encountered in the constructor output an error and return
   MATCH_ERROR.
gcc/testsuite/ChangeLog
   Mark Eggleston <mark.eggleston@codethink.com>
   PR fortran/93604
   * gfortran.dg/pr93604.f90 : New test.
OK to commit?
--
https://www.codethink.co.uk/privacy.html
[-- Attachment #2: 0001-Fortran-ICE-in-gfc_conv_constant_to_tree-PR93604.patch --]
[-- Type: text/x-patch, Size: 2318 bytes --]
From b4bd5742d842c860da5b35955301e3c1a1e06160 Mon Sep 17 00:00:00 2001
From: Mark Eggleston <markeggleston@gcc.gnu.org>
Date: Thu, 6 Feb 2020 13:42:33 +0000
Subject: [PATCH] [Fortran] ICE in gfc_conv_constant_to_tree PR93604
Using a BOZ constant in a structure constructor in a data statement
resulted in an ICE. Output a "BOZ literal constant cannot appear in
a structure constructor" error message instead.
Original patch provided by Steven G. Kargl <kargl@gcc.gnu.org>.
Test case added later.
gcc/fortran/ChangeLog
* decl.c (gfc_match_data) : Check whether the data expression
is a derived type and is a constructor. If a BOZ constant
is encountered in the constructor output an error and return
MATCH_ERROR.
gcc/testsuite/ChangeLog
* gfortran.dg/pr93604.f90 : New test.
---
gcc/fortran/decl.c | 16 ++++++++++++++++
gcc/testsuite/gfortran.dg/pr93604.f90 | 10 ++++++++++
2 files changed, 26 insertions(+)
create mode 100644 gcc/testsuite/gfortran.dg/pr93604.f90
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 499d2429aba..7382fea03e4 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -716,6 +716,22 @@ gfc_match_data (void)
new_data->next = gfc_current_ns->data;
gfc_current_ns->data = new_data;
+ /* A BOZ literal constant cannot appear in a structure constructor.
+ Check for that here for a data statement value. */
+ if (new_data->value->expr->ts.type == BT_DERIVED
+ && new_data->value->expr->value.constructor)
+ {
+ gfc_constructor *c;
+ c = gfc_constructor_first (new_data->value->expr->value.constructor);
+ for (; c; c = gfc_constructor_next (c))
+ if (c->expr->ts.type == BT_BOZ)
+ {
+ gfc_error ("BOZ literal constant at %L cannot appear in a "
+ "structure constructor", &c->expr->where);
+ return MATCH_ERROR;
+ }
+ }
+
if (gfc_match_eos () == MATCH_YES)
break;
diff --git a/gcc/testsuite/gfortran.dg/pr93604.f90 b/gcc/testsuite/gfortran.dg/pr93604.f90
new file mode 100644
index 00000000000..2c695d37829
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr93604.f90
@@ -0,0 +1,10 @@
+! { dg-do compile }
+
+program p
+ type t
+ integer :: a
+ end type
+ type(t) :: x
+ data x /t(z'1')/ ! { dg-error "cannot appear in a structure constructor" }
+end
+
--
2.11.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Regression, patch][Fortran] ICE in gfc_conv_constant_to_tree PR93604
2020-02-17 11:26 [Regression, patch][Fortran] ICE in gfc_conv_constant_to_tree PR93604 Mark Eggleston
@ 2020-02-24 12:05 ` Mark Eggleston
2020-02-24 13:30 ` Thomas Koenig
0 siblings, 1 reply; 3+ messages in thread
From: Mark Eggleston @ 2020-02-24 12:05 UTC (permalink / raw)
To: gcc-patches, fortran
**ping**
On 17/02/2020 11:26, Mark Eggleston wrote:
> Please find attached patch for PR93604.
>
> gcc/fortran/ChangeLog
>
>    Steven G. Kargl <kargl@gcc.gnu.org>
>
> Â Â Â PR fortran/93604
> Â Â Â * decl.c (gfc_match_data) : Check whether the data expression
> Â Â Â is a derived type and is a constructor. If a BOZ constant
> Â Â Â is encountered in the constructor output an error and return
> Â Â Â MATCH_ERROR.
>
> gcc/testsuite/ChangeLog
>
>    Mark Eggleston <mark.eggleston@codethink.com>
>
> Â Â Â PR fortran/93604
> Â Â Â * gfortran.dg/pr93604.f90 : New test.
>
> OK to commit?
>
--
https://www.codethink.co.uk/privacy.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Regression, patch][Fortran] ICE in gfc_conv_constant_to_tree PR93604
2020-02-24 12:05 ` Mark Eggleston
@ 2020-02-24 13:30 ` Thomas Koenig
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Koenig @ 2020-02-24 13:30 UTC (permalink / raw)
To: Mark Eggleston, gcc-patches, fortran
Hi Mark,
> **ping**
OK!
Regards
Thomas
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-02-24 13:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-17 11:26 [Regression, patch][Fortran] ICE in gfc_conv_constant_to_tree PR93604 Mark Eggleston
2020-02-24 12:05 ` Mark Eggleston
2020-02-24 13:30 ` Thomas Koenig
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).