2010-11-11 Tobias Burnus <burnus@net-b.de>
PR fortran/46413
* resolve.c (resolve_transfer): Reject I/O transfer of
polymorphic type.
PR fortran/46205
* resolve.c (resolve_code): Reject nonscalar FORALL masks.
2010-11-11 Tobias Burnus <burnus@net-b.de>
PR fortran/46413
* gfortran.dg/class_31.f90: New.
PR fortran/46205
* gfortran.dg/forall_14.f90: New.
@@ -7948,6 +7948,15 @@ resolve_transfer (gfc_code *code)
if (ref->type == REF_COMPONENT)
ts = &ref->u.c.component->ts;
+ if (ts->type == BT_CLASS)
+ {
+ /* FIXME: Test for defined input/output. */
+ gfc_error ("Data transfer element at %L cannot be polymorphic unless "
+ "it is processed by a defined input/output procedure",
+ &code->loc);
+ return;
+ }
+
if (ts->type == BT_DERIVED)
{
/* Check that transferred derived type doesn't contain POINTER
@@ -9098,8 +9107,9 @@ resolve_code (gfc_code *code, gfc_namespace *ns)
case EXEC_FORALL:
resolve_forall_iterators (code->ext.forall_iterator);
- if (code->expr1 != NULL && code->expr1->ts.type != BT_LOGICAL)
- gfc_error ("FORALL mask clause at %L requires a LOGICAL "
+ if (code->expr1 != NULL
+ && (code->expr1->ts.type != BT_LOGICAL || code->expr1->rank))
+ gfc_error ("FORALL mask clause at %L requires a scalar LOGICAL "
"expression", &code->expr1->where);
break;
new file mode 100644
@@ -0,0 +1,12 @@
+! { dg-do compile }
+!
+! PR fortran/46413
+!
+type t
+ integer :: ii =5
+end type t
+class(t), allocatable :: x
+allocate (t :: x)
+
+print *,x ! { dg-error "Data transfer element at .1. cannot be polymorphic" }
+end
new file mode 100644
@@ -0,0 +1,17 @@
+! { dg-do compile }
+!
+! PR fortran/46205
+!
+! Contributed by Jonathan Stott
+!
+
+program forallBug
+ logical :: valid(4) = (/ .true., .true., .false., .true. /)
+ real :: vec(4)
+ integer :: j
+
+ ! This is an illegal statement. It should read valid(j), not valid.
+ forall (j = 1:4, valid) ! { dg-error "requires a scalar LOGICAL expression" }
+ vec(j) = sin(2*3.14159/j)
+ end forall
+end program forallBug