re PR fortran/84219 (Failure to generate error for IO of transfer intrinsic, when...
authorPaul Thomas <pault@gcc.gnu.org>
Thu, 1 Mar 2018 11:06:18 +0000 (11:06 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Thu, 1 Mar 2018 11:06:18 +0000 (11:06 +0000)
2018-03-01  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/84219
* target-memory.c (gfc_interpret_derived): Assert that BT_VOID
components are caf tokens.
(gfc_target_interpret_expr): Treat BT_VOID expressions as
integers.

2018-03-01  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/84219
* gfortran.dg/coarray_47.f90: New test.

From-SVN: r258098

gcc/fortran/ChangeLog
gcc/fortran/target-memory.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/coarray_47.f90 [new file with mode: 0644]

index fd522b657417a6c8cff639ec25f27e82cee5d7f5..742b83d096b896c8557611f8ef144cc2b118c2fa 100644 (file)
@@ -1,3 +1,11 @@
+2018-03-01  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/84219
+       * target-memory.c (gfc_interpret_derived): Assert that BT_VOID
+       components are caf tokens.
+       (gfc_target_interpret_expr): Treat BT_VOID expressions as
+       integers.
+
 2018-03-01  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/84538
index e445fbe665da1b408b004186722503d6168e820b..6b9292b5fafee97cbf8efac89f81fcf5890928bb 100644 (file)
@@ -547,6 +547,7 @@ gfc_interpret_derived (unsigned char *buffer, size_t buffer_size, gfc_expr *resu
       gcc_assert (ptr % 8 == 0);
       ptr = ptr/8 + TREE_INT_CST_LOW (DECL_FIELD_OFFSET (cmp->backend_decl));
 
+      gcc_assert (e->ts.type != BT_VOID || cmp->attr.caf_token);
       gfc_target_interpret_expr (&buffer[ptr], buffer_size - ptr, e, true);
     }
 
@@ -602,6 +603,13 @@ gfc_target_interpret_expr (unsigned char *buffer, size_t buffer_size,
       gcc_assert (result->representation.length >= 0);
       break;
 
+    case BT_VOID:
+      /* This deals with caf_tokens.  */
+      result->representation.length =
+        gfc_interpret_integer (result->ts.kind, buffer, buffer_size,
+                              result->value.integer);
+      break;
+
     default:
       gfc_internal_error ("Invalid expression in gfc_target_interpret_expr.");
       break;
index 5347544041592de750ee467a2ab820f30c0732aa..e4ed421e7be320c4b274a0327dbeabd58b9baeda 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-01  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/84219
+       * gfortran.dg/coarray_47.f90: New test.
+
 2018-03-01  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/84538
diff --git a/gcc/testsuite/gfortran.dg/coarray_47.f90 b/gcc/testsuite/gfortran.dg/coarray_47.f90
new file mode 100644 (file)
index 0000000..c33eb9c
--- /dev/null
@@ -0,0 +1,13 @@
+! { dg-do compile }
+! { dg-options "-fcoarray=single" }
+!
+! Contributed by G Steinmetz  <gscfq@t-online.de>
+!
+program p
+   type t
+      integer, allocatable :: t
+   end type
+   type(t) :: x
+   integer :: i = -1
+   print *, transfer(i, x) ! { dg-error "cannot have ALLOCATABLE components" }
+end