[gcc(refs/vendors/ARM/heads/arm-struct-reorg-wip)] PR fortran/95978 - ICE in gfc_match_data, at fortran/decl.c:731

Tamar Christina tnfchris@gcc.gnu.org
Fri Jul 17 15:22:36 GMT 2020


https://gcc.gnu.org/g:aa0868ffe0fd45891a9596bf4995f1b610243fa6

commit aa0868ffe0fd45891a9596bf4995f1b610243fa6
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Mon Jun 29 23:20:16 2020 +0200

    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.
    
    (cherry picked from commit 583812c2e2f3593823622b0a5821d957c832dbd0)

Diff:
---
 gcc/fortran/decl.c                    |  2 +-
 gcc/testsuite/gfortran.dg/pr95978.f90 | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index adcd371b2d1..ad3ad1c8b89 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 00000000000..47bd7067096
--- /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


More information about the Gcc-cvs mailing list