:ADDPATCH fortran:
The attached patch allows the test case in the PR to compile. However,
it conflicts with the testcase pr15754.f90. Do we want to allow this
assignment as an extension or should I further refine the checking? Or
is it valid to allow the assignment to NULL as in the PR?
integer, pointer :: ptr1
data ptr1 /NULL()/
end
Regression tested on x86-64-Gnu-Linux.
OK for trunk? Fixing test case appropriately.
Jerry
2007-06-15 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/32360
* expr.c (gfc_check_assign): If the rvalue expression type is
NULL_EXPR,
check to see if the lvalue is a pointer. If it is a pointer, set its
type to match the rvalue and do not issue an error.
------------------------------------------------------------------------
Index: expr.c
===================================================================
*** expr.c (revision 125747)
--- expr.c (working copy)
*************** gfc_check_assign (gfc_expr *lvalue, gfc_
*** 2407,2418 ****
return FAILURE;
}
! if (rvalue->expr_type == EXPR_NULL)
! {
! gfc_error ("NULL appears on right-hand side in assignment at %L",
! &rvalue->where);
! return FAILURE;
! }
if (sym->attr.cray_pointee
&& lvalue->ref != NULL
--- 2407,2423 ----
return FAILURE;
}
! if (rvalue->expr_type == EXPR_NULL)
! {
! if (lvalue->symtree->n.sym->attr.pointer)
! rvalue->ts.type = lvalue->ts.type;
! else
! {
! gfc_error ("NULL appears on right-hand side in assignment at %L",
! &rvalue->where);
! return FAILURE;
! }
! }
if (sym->attr.cray_pointee
&& lvalue->ref != NULL