]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2019-06-19 Steven G. Kargl <kargl@gcc.gnu.org>
authorkargl <kargl@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 19 Jun 2019 18:04:46 +0000 (18:04 +0000)
committerkargl <kargl@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 19 Jun 2019 18:04:46 +0000 (18:04 +0000)
PR fortran/69398
* decl.c (attr_decl): Check for duplicate DIMENSION attribute for a
CLASS entity.

2019-06-19  Steven G. Kargl  <kargl@gcc.gnu.org>

PR fortran/69398
* gfortran.dg/pr69398.f90: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@272481 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 62edba78f61c1534924a256661eb86860ab65c10..2014342f9dacae4ae667cda636e304149481ecc3 100644 (file)
@@ -1,3 +1,9 @@
+2019-06-19  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/69398
+       * decl.c (attr_decl): Check for duplicate DIMENSION attribute for a
+       CLASS entity.
+
 2019-06-19  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/87907
index 5fc06e48f2de65b62c36898ea605debc4790ba43..7fcb60ab7ab85092a4d90c7fe13582a10ec85be3 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 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, &current_attr, &var_locus))
        {
          m = MATCH_ERROR;
index aa41d2aac3824b78638396d24740f4956ec2d2f3..5b81695aa248666ef68907aadb84f8688a7d5a3a 100644 (file)
@@ -1,3 +1,8 @@
+2019-06-19  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+       PR fortran/69398
+       * gfortran.dg/pr69398.f90: New test.
+
 2019-06-19  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/87907
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
+