gcc/fortran/ChangeLog:
PR fortran/100018
* resolve.c: Add association check before de-referencing pointer.
gcc/testsuite/ChangeLog:
PR fortran/100018
* gfortran.dg/PR10018.f90: New test.
/* Assigning a class object always is a regular assign. */
if (code->expr2->ts.type == BT_CLASS
&& code->expr1->ts.type == BT_CLASS
+ && CLASS_DATA (code->expr2)
&& !CLASS_DATA (code->expr2)->attr.dimension
&& !(gfc_expr_attr (code->expr1).proc_pointer
&& code->expr2->expr_type == EXPR_VARIABLE
--- /dev/null
+! { dg-do compile }
+!
+subroutine foo(that)
+ implicit none
+ class(*), target, intent(in) :: this
+ class(*), pointer, intent(out) :: that
+
+ that => this
+ return
+end subroutine foo
+! { dg-error "Symbol at \\\(1\\\) is not a DUMMY variable" "" { target "*-*-*" } 5 }