]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR fortran/69398 ([OOP] ICE on class with duplicate dimension attribute...
authorSteven G. Kargl <kargl@gcc.gnu.org>
Thu, 20 Jun 2019 23:27:13 +0000 (23:27 +0000)
committerSteven G. Kargl <kargl@gcc.gnu.org>
Thu, 20 Jun 2019 23:27:13 +0000 (23:27 +0000)
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

gcc/fortran/ChangeLog
gcc/fortran/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/pr69398.f90 [new file with mode: 0644]

index 087a1fd86fd9cf0ccbe50e0a441c9d0aeb8ff6bc..0395a1a7abc9f93c42765c03230b232076e9a802 100644 (file)
@@ -1,3 +1,10 @@
+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
index 1c785a4f74c85d424d0928683f17f1b875fdfeeb..a005bd7962b4e0616bf49447b9b355b91292eba4 100644 (file)
@@ -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;
index 7e17f67bf2dc17585434568b379baaebc702f600..f42fe5887e6395e172dc6ef0b6bc4da468e8d45c 100644 (file)
@@ -1,3 +1,9 @@
+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
diff --git a/gcc/testsuite/gfortran.dg/pr69398.f90 b/gcc/testsuite/gfortran.dg/pr69398.f90
new file mode 100644 (file)
index 0000000..6863746
--- /dev/null
@@ -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
+