aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorMark Eggleston <markeggleston@gcc.gnu.org>2020-02-24 14:33:35 +0000
committerMark Eggleston <markeggleston@gcc.gnu.org>2020-02-24 14:33:35 +0000
commitc77b6f95e014ad1f6654683ff56f9508fe7f268d (patch)
tree01af0228aa662dd697ed018bbc48333cedc984e1 /gcc/fortran
parentfb6a8b230ad98ab3c42efc2968483ceb5ef62886 (diff)
downloadgcc-c77b6f95e014ad1f6654683ff56f9508fe7f268d.zip
gcc-c77b6f95e014ad1f6654683ff56f9508fe7f268d.tar.gz
gcc-c77b6f95e014ad1f6654683ff56f9508fe7f268d.tar.bz2
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 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 PR fortran/93604 * gfortran.dg/pr93604.f90 : New test.
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog8
-rw-r--r--gcc/fortran/decl.c16
2 files changed, 24 insertions, 0 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 94ceb5c..e25d05c 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,11 @@
+2020-02-24 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.
+
2020-02-24 Tobias Burnus <tobias@codesourcery.com>
PR fortran/93552
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 499d242..7382fea 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;