The following program gives a compile time error for a DATA assignment of NULL() to a structure component. Probably related to 38917 Dick Hendrickson SUBROUTINE PF0009 ! fails on Windows XP ! gcc version 4.4.0 20081219 (experimental) [trunk revision 142842] (GCC) TYPE :: HAS_POINTER INTEGER, POINTER :: PTR_S END TYPE HAS_POINTER TYPE (HAS_POINTER) :: PTR_ARRAY(5) DATA PTR_ARRAY(1)%PTR_S /NULL()/ end subroutine pf0009 C:\gfortran>gfortran try_pf0009.f try_pf0009.f:11.38: DATA PTR_ARRAY(1)%PTR_S /NULL()/ 1 Error: NULL appears on right-hand side in assignment at (1)
Confirm. Thanks for the report. R532 data-stmt-constant is ... or null-init R507 null-init is function-reference C506 (R507) The function-reference shall be a reference to the NULL intrinsic function with no arguments Probably a duplicate of PR 38917.
This has a trivial fix: expr.c: 2913 becomes if (have_pointer && lvalue->symtree->n.sym->attr.data) Sorry about the lack of a diff - I will remedy this on submission:-) paul
Created attachment 17174 [details] Fix for the PR - OK'd http://gcc.gnu.org/ml/fortran/2009-01/msg00297.html 2009-01-22 Paul Thomas <pault@gcc.gnu.org> PR fortran/38917 * expr.c (gfc_check_assign): Allow pointer components when checking for NULL. PR fortran/38918 * resolve.c (check_data_variable): Treat pointer arrays with scalars. 2009-01-22 Paul Thomas <pault@gcc.gnu.org> PR fortran/38917 PR fortran/38918 * gfortran.dg/data_pointer_1.f90: New test.
Subject: Bug 38918 Author: pault Date: Tue Mar 31 20:05:44 2009 New Revision: 145371 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=145371 Log: 2009-03-31 Paul Thomas <pault@gcc.gnu.org> PR fortran/38917 * expr.c (gfc_check_assign): Allow pointer components when checking for NULL. PR fortran/38918 * resolve.c (check_data_variable): Treat pointer arrays with scalars. 2009-03-31 Paul Thomas <pault@gcc.gnu.org> PR fortran/38917 PR fortran/38918 * gfortran.dg/data_pointer_1.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/data_pointer_1.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/expr.c trunk/gcc/fortran/resolve.c trunk/gcc/testsuite/ChangeLog
Fixed on trunk. I am prepared to backport but the mood appears to be against it. Thanks for the report. Paul