aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2020-06-29 23:20:16 +0200
committerGiuliano Belinassi <giuliano.belinassi@usp.br>2020-08-17 13:15:26 -0300
commit7d5230ada669a4fb611845e8e4c700cc81ea8493 (patch)
tree1815d0dc91520720379edb92c36150e725a9cd82
parentb164aff5fb6365151dc89e790b89bb67cca46400 (diff)
downloadgcc-7d5230ada669a4fb611845e8e4c700cc81ea8493.zip
gcc-7d5230ada669a4fb611845e8e4c700cc81ea8493.tar.gz
gcc-7d5230ada669a4fb611845e8e4c700cc81ea8493.tar.bz2
PR fortran/95978 - ICE in gfc_match_data, at fortran/decl.c:731
Catch NULL pointer dereference on invalid DATA statement. gcc/fortran/ PR fortran/95978 * decl.c (gfc_match_data): Avoid NULL pointer dereference.
-rw-r--r--gcc/fortran/decl.c2
-rw-r--r--gcc/testsuite/gfortran.dg/pr95978.f9010
2 files changed, 11 insertions, 1 deletions
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index ac1f63f..f38def4 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -728,7 +728,7 @@ gfc_match_data (void)
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)
+ if (c->expr && c->expr->ts.type == BT_BOZ)
{
gfc_error ("BOZ literal constant at %L cannot appear in a "
"structure constructor", &c->expr->where);
diff --git a/gcc/testsuite/gfortran.dg/pr95978.f90 b/gcc/testsuite/gfortran.dg/pr95978.f90
new file mode 100644
index 0000000..47bd706
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr95978.f90
@@ -0,0 +1,10 @@
+! { dg-do compile }
+! PR fortran/95978 - ICE in gfc_match_data, at fortran/decl.c:731
+
+program p
+ type t
+ integer :: a
+ type(t), allocatable :: b
+ data c /t(1)/ ! { dg-error "Unexpected DATA statement" }
+ end type t
+end