From c9935123aef8eac547cdd0e8b06811fc776a6b32 Mon Sep 17 00:00:00 2001 From: "Steven G. Kargl" Date: Wed, 19 Jun 2019 18:04:46 +0000 Subject: [PATCH] re PR fortran/69398 ([OOP] ICE on class with duplicate dimension attribute specified) 2019-06-19 Steven G. Kargl PR fortran/69398 * decl.c (attr_decl): Check for duplicate DIMENSION attribute for a CLASS entity. 2019-06-19 Steven G. Kargl PR fortran/69398 * gfortran.dg/pr69398.f90: New test. From-SVN: r272481 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/decl.c | 9 +++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/pr69398.f90 | 11 +++++++++++ 4 files changed, 31 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/pr69398.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 62edba78f61..2014342f9da 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-06-19 Steven G. Kargl + + PR fortran/69398 + * decl.c (attr_decl): Check for duplicate DIMENSION attribute for a + CLASS entity. + 2019-06-19 Steven G. Kargl PR fortran/87907 diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 5fc06e48f2d..7fcb60ab7ab 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -8372,6 +8372,15 @@ attr_decl1 (void) to the first component, or '_data' field. */ if (sym->ts.type == BT_CLASS && sym->ts.u.derived->attr.is_class) { + /* gfc_set_array_spec sets sym->attr not CLASS_DATA(sym)->attr. Check + for duplicate attribute here. */ + if (CLASS_DATA(sym)->attr.dimension == 1 && as) + { + gfc_error ("Duplicate DIMENSION attribute at %C"); + m = MATCH_ERROR; + goto cleanup; + } + if (!gfc_copy_attr (&CLASS_DATA(sym)->attr, ¤t_attr, &var_locus)) { m = MATCH_ERROR; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index aa41d2aac38..5b81695aa24 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-06-19 Steven G. Kargl + + PR fortran/69398 + * gfortran.dg/pr69398.f90: New test. + 2019-06-19 Steven G. Kargl PR fortran/87907 diff --git a/gcc/testsuite/gfortran.dg/pr69398.f90 b/gcc/testsuite/gfortran.dg/pr69398.f90 new file mode 100644 index 00000000000..68637465048 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr69398.f90 @@ -0,0 +1,11 @@ +! { dg-do compile } +! PR fortran/69398 +! Contributed by Gerhard Steinmetz +program p + type t + end type + class(t), allocatable :: z(:) + target :: z(:) ! { dg-error "Duplicate DIMENSION attribute" } + allocate (z(2)) +end + -- 2.30.2