]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/64943 (No error on ultimate allocatable components in IO list)
authorTobias Burnus <burnus@net-b.de>
Thu, 5 Feb 2015 21:58:38 +0000 (22:58 +0100)
committerTobias Burnus <burnus@gcc.gnu.org>
Thu, 5 Feb 2015 21:58:38 +0000 (22:58 +0100)
2015-02-05  Tobias Burnus  <burnus@net-b.de>

        PR fortran/64943
        * resolve.c (resolve_transfer): Also check structure
        constructors.

2015-02-05  Tobias Burnus  <burnus@net-b.de>

        PR fortran/64943
        * gfortran.dg/structure_constructor_12.f90: New.

From-SVN: r220462

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

index def6f1b2f2fcb8db73ebb93185d64c06c3e16787..ae912cbe03f233ded9f608251cc1e26f1a729f72 100644 (file)
@@ -1,3 +1,9 @@
+2015-02-05  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/64943
+       * resolve.c (resolve_transfer): Also check structure
+       constructors.
+
 2015-02-05  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/64757
index 3b0c12a0e6be31dd6c97dd4663995b32d6476e47..0b188dad05b42d2e9a5140399c290a239403b8a0 100644 (file)
@@ -8364,7 +8364,8 @@ resolve_transfer (gfc_code *code)
     }
 
   if (exp == NULL || (exp->expr_type != EXPR_VARIABLE
-                     && exp->expr_type != EXPR_FUNCTION))
+                     && exp->expr_type != EXPR_FUNCTION
+                     && exp->expr_type != EXPR_STRUCTURE))
     return;
 
   /* If we are reading, the variable will be changed.  Note that
@@ -8375,8 +8376,7 @@ resolve_transfer (gfc_code *code)
                                    _("item in READ")))
     return;
 
-  sym = exp->symtree->n.sym;
-  ts = &sym->ts;
+  ts = exp->expr_type == EXPR_STRUCTURE ? &exp->ts : &exp->symtree->n.sym->ts;
 
   /* Go to actual component transferred.  */
   for (ref = exp->ref; ref; ref = ref->next)
@@ -8436,6 +8436,11 @@ resolve_transfer (gfc_code *code)
          return;
        }
     }
+   
+  if (exp->expr_type == EXPR_STRUCTURE)
+    return;
+
+  sym = exp->symtree->n.sym;
 
   if (sym->as != NULL && sym->as->type == AS_ASSUMED_SIZE && exp->ref
       && exp->ref->type == REF_ARRAY && exp->ref->u.ar.type == AR_FULL)
index 3a86c9db6de8edcd33f3b2ce0ca0680564e869d9..cf3a21e282ea9da738a1c515687dfa73f7a6545d 100644 (file)
@@ -1,3 +1,8 @@
+2015-02-05  Tobias Burnus  <burnus@net-b.de>
+
+       PR fortran/64943
+       * gfortran.dg/structure_constructor_12.f90: New.
+
 2015-02-05  Jeff Law  <law@redhat.com>
 
        PR target/58400
diff --git a/gcc/testsuite/gfortran.dg/structure_constructor_12.f90 b/gcc/testsuite/gfortran.dg/structure_constructor_12.f90
new file mode 100644 (file)
index 0000000..aa7e91d
--- /dev/null
@@ -0,0 +1,15 @@
+! { dg-do compile }
+!
+! PR fortran/64943
+!
+! Contributed Dominique d'Humieres
+!
+  type :: Test
+    integer :: i
+  end type
+
+  type :: TestReference
+     class(Test), allocatable :: test(:)
+  end type
+print *, TestReference([Test(99), Test(199)]) ! { dg-error "Data transfer element at .1. cannot have ALLOCATABLE components unless it is processed by a defined input/output procedure" }
+end