]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2019-01-31 Thomas Koenig <tkoenig@gcc.gnu.org>
authortkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 31 Jan 2019 22:21:28 +0000 (22:21 +0000)
committertkoenig <tkoenig@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 31 Jan 2019 22:21:28 +0000 (22:21 +0000)
PR fortran/88669
* resolve.c (resolve_component): If the reference is a BT_CLASS,
copy the contiguous attribute from the reference and use the
correct attributes.

2019-01-31  Thomas Koenig  <tkoenig@gcc.gnu.org>

PR fortran/88669
* gfortran.dg/contiguous_9.f90: New test.

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

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

index c78e32af1731cdf2d5933e1b5aa2827a1174f518..7f2a7afbbb9537dd5c14ed5ce3ccb458243971e5 100644 (file)
@@ -1,3 +1,10 @@
+2019-01-31  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/88669
+       * resolve.c (resolve_component): If the reference is a BT_CLASS,
+       copy the contiguous attribute from the reference and use the
+       correct attributes.
+
 2019-01-30  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        PR fortran/52564
index 2c49aeab5f9822be16fa7cd9f4dc1becb1eb4c01..5e95777af550bf6f6bf9ce1b0c12e4aabba03c36 100644 (file)
@@ -13761,6 +13761,7 @@ static bool
 resolve_component (gfc_component *c, gfc_symbol *sym)
 {
   gfc_symbol *super_type;
+  symbol_attribute *attr;
 
   if (c->attr.artificial)
     return true;
@@ -13803,7 +13804,23 @@ resolve_component (gfc_component *c, gfc_symbol *sym)
     }
 
   /* F2008, C448.  */
-  if (c->attr.contiguous && (!c->attr.dimension || !c->attr.pointer))
+  if (c->ts.type == BT_CLASS)
+    {
+      if (CLASS_DATA (c))
+       {
+         attr = &(CLASS_DATA (c)->attr);
+
+         /* Fix up contiguous attribute.  */
+         if (c->attr.contiguous)
+           attr->contiguous = 1;
+       }
+      else
+       attr = NULL;
+    }
+  else
+    attr = &c->attr;
+
+  if (attr && attr->contiguous && (!attr->dimension || !attr->pointer))
     {
       gfc_error ("Component %qs at %L has the CONTIGUOUS attribute but "
                  "is not an array pointer", c->name, &c->loc);
index ce63dad84d0952800865fbbb13eef31bfcd3cb5c..ec3b597339f46a11b7b5339cd98c2d451d7e0fb9 100644 (file)
@@ -1,3 +1,8 @@
+2019-01-31  Thomas Koenig  <tkoenig@gcc.gnu.org>
+
+       PR fortran/88669
+       * gfortran.dg/contiguous_9.f90: New test.
+
 2019-01-31  Marek Polacek  <polacek@redhat.com>
 
        PR c++/89083, c++/80864 - ICE with list initialization in template.
diff --git a/gcc/testsuite/gfortran.dg/contiguous_9.f90 b/gcc/testsuite/gfortran.dg/contiguous_9.f90
new file mode 100644 (file)
index 0000000..dec6371
--- /dev/null
@@ -0,0 +1,12 @@
+program contiguous_pointer
+
+type t
+end type t
+
+type s
+   class(t), dimension(:), contiguous, pointer :: x ! OK
+   class(t), contiguous, allocatable :: y ! { dg-error "has the CONTIGUOUS attribute but is not an array pointer" }
+   class(t), contiguous, pointer :: z ! { dg-error "has the CONTIGUOUS attribute but is not an array pointer" }
+end type s
+
+end program contiguous_pointer