[gcc/devel/omp/gcc-9] backport: re PR fortran/69398 ([OOP] ICE on class with duplicate dimension attribute specified)

Tobias Burnus burnus@gcc.gnu.org
Thu Mar 5 14:01:00 GMT 2020


https://gcc.gnu.org/g:3beb78027244b69fe18219d84a658220fa478194

commit 3beb78027244b69fe18219d84a658220fa478194
Author: Steven G. Kargl <kargl@gcc.gnu.org>
Date:   Thu Jun 20 23:27:13 2019 +0000

    backport: re PR fortran/69398 ([OOP] ICE on class with duplicate dimension attribute specified)
    
    2019-06-20  Steven G. Kargl  <kargl@gcc.gnu.org>
    
    	Backport from mainline
    	PR fortran/69398
    	* decl.c (attr_decl): Check for duplicate DIMENSION attribute for a
    	CLASS entity.
    
    2019-06-20  Steven G. Kargl  <kargl@gcc.gnu.org>
    
    	Backport from mainline
    	PR fortran/69398
    	* gfortran.dg/pr69398.f90: New test.
    
    From-SVN: r272530

Diff:
---
 gcc/fortran/ChangeLog                 |  7 +++++++
 gcc/fortran/decl.c                    |  9 +++++++++
 gcc/testsuite/ChangeLog               |  6 ++++++
 gcc/testsuite/gfortran.dg/pr69398.f90 | 11 +++++++++++
 4 files changed, 33 insertions(+)

diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 087a1fd..0395a1a 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,6 +1,13 @@
 2019-06-20  Steven G. Kargl  <kargl@gcc.gnu.org>
 
 	Backport from mainline
+	PR fortran/69398
+	* decl.c (attr_decl): Check for duplicate DIMENSION attribute for a
+	CLASS entity.
+
+2019-06-20  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+	Backport from mainline
 	PR fortran/68544
 	* resolve.c (is_dt_name): New function to compare symbol name against
 	list of derived types.
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 1c785a4..a005bd7 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 set 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, &current_attr, &var_locus))
 	{
 	  m = MATCH_ERROR;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7e17f67..f42fe58 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,6 +1,12 @@
 2019-06-20  Steven G. Kargl  <kargl@gcc.gnu.org>
 
 	Backport from mainline
+	PR fortran/69398
+	* gfortran.dg/pr69398.f90: New test.
+
+2019-06-20  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+	Backport from mainline
 	PR fortran/68544
 	* gfortran.dg/pr68544.f90: New test.
 	* gfortran.dg/pr85687.f90: Modify test for new error message.
diff --git a/gcc/testsuite/gfortran.dg/pr69398.f90 b/gcc/testsuite/gfortran.dg/pr69398.f90
new file mode 100644
index 0000000..6863746
--- /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
+



More information about the Gcc-cvs mailing list