From d42a2e465d821517819a54f4f613bb6e6443dc05 Mon Sep 17 00:00:00 2001 From: Fritz Reese Date: Mon, 6 Apr 2020 16:14:29 -0400 Subject: [PATCH] Fix fortran/93686 -- ICE matching data statements with derived-type pointers. gcc/fortran/ChangeLog: 2020-04-06 Steven G. Kargl PR fortran/93686 * decl.c (gfc_match_data): Handle data matching for derived type pointers. gcc/testsuite/ChangeLog: 2020-04-06 Steven G. Kargl PR fortran/93686 * gfortran.dg/pr93686_1.f90: New test. * gfortran.dg/pr93686_2.f90: Likewise. * gfortran.dg/pr93686_3.f90: Likewise. * gfortran.dg/pr93686_4.f90: Likewise. --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/decl.c | 4 ++++ gcc/testsuite/ChangeLog | 8 ++++++++ gcc/testsuite/gfortran.dg/pr93686_1.f90 | 10 ++++++++++ gcc/testsuite/gfortran.dg/pr93686_2.f90 | 10 ++++++++++ gcc/testsuite/gfortran.dg/pr93686_3.f90 | 9 +++++++++ gcc/testsuite/gfortran.dg/pr93686_4.f90 | 8 ++++++++ 7 files changed, 55 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr93686_1.f90 create mode 100644 gcc/testsuite/gfortran.dg/pr93686_2.f90 create mode 100644 gcc/testsuite/gfortran.dg/pr93686_3.f90 create mode 100644 gcc/testsuite/gfortran.dg/pr93686_4.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 8c4ace7cdfa..435f93d0d9e 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2020-04-06 Steven G. Kargl + + PR fortran/93686 + * decl.c (gfc_match_data): Handle data matching for derived type + pointers. + 2020-04-02 Tobias Burnus * gfortran.h (gfc_resolve_formal_arglist): Add prototype. diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index ea309089ac9..b3ed63c97cc 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -696,6 +696,10 @@ gfc_match_data (void) /* F2008:C567 (R536) A data-i-do-object or a variable that appears as a data-stmt-object shall not be an object designator in which a pointer appears other than as the entire rightmost part-ref. */ + if (!e->ref && e->ts.type == BT_DERIVED + && e->symtree->n.sym->attr.pointer) + goto partref; + ref = e->ref; if (e->symtree->n.sym->ts.type == BT_DERIVED && e->symtree->n.sym->attr.pointer diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2198e18198b..ef5e0cf527c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2020-04-06 Steven G. Kargl + + PR fortran/93686 + * gfortran.dg/pr93686_1.f90: New test. + * gfortran.dg/pr93686_2.f90: Likewise. + * gfortran.dg/pr93686_3.f90: Likewise. + * gfortran.dg/pr93686_4.f90: Likewise. + 2020-04-06 Joel Brobecker * gcc.target/arm/div64-unwinding.c: Skip on vxworks_kernel targets. diff --git a/gcc/testsuite/gfortran.dg/pr93686_1.f90 b/gcc/testsuite/gfortran.dg/pr93686_1.f90 new file mode 100644 index 00000000000..0e7560a5c17 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr93686_1.f90 @@ -0,0 +1,10 @@ +! { dg-do compile } +! PR fortran/93686 + +program p + type t + integer :: a + end type + type(t), pointer :: x + data x /t(2)/ ! { dg-error "part-ref with pointer attribute near ... is not rightmost part-ref of data-stmt-object" } +end diff --git a/gcc/testsuite/gfortran.dg/pr93686_2.f90 b/gcc/testsuite/gfortran.dg/pr93686_2.f90 new file mode 100644 index 00000000000..aac4d9138ee --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr93686_2.f90 @@ -0,0 +1,10 @@ +! { dg-do compile } +! PR fortran/93686 + +program p + type t + integer :: a = 1 + end type + type(t), pointer :: x + data x /t(2)/ ! { dg-error "part-ref with pointer attribute near ... is not rightmost part-ref of data-stmt-object" } +end diff --git a/gcc/testsuite/gfortran.dg/pr93686_3.f90 b/gcc/testsuite/gfortran.dg/pr93686_3.f90 new file mode 100644 index 00000000000..5b570407f8f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr93686_3.f90 @@ -0,0 +1,9 @@ +! { dg-do compile } +! PR fortran/93686 + +program p + type t + end type + type(t), pointer :: x + data x /t()/ ! { dg-error "part-ref with pointer attribute near ... is not rightmost part-ref of data-stmt-object" } +end diff --git a/gcc/testsuite/gfortran.dg/pr93686_4.f90 b/gcc/testsuite/gfortran.dg/pr93686_4.f90 new file mode 100644 index 00000000000..ff3ae764ab7 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr93686_4.f90 @@ -0,0 +1,8 @@ +! { dg-do compile } +! PR fortran/93686 + +type t +end type +type(t), pointer :: x +data x / ! { dg-error "part-ref with pointer attribute near ... is not rightmost part-ref of data-stmt-object" } +end -- 2.30.2