Hi, gfortran-4.8 (and 4.7 as well and possibly earlier versions too) complain with this snippet. The error message is not emitted if the declaration of R is uncommented. ! -- test.f90 MODULE M INTRINSIC :: NULL !! Uncommenting the following statement !! causes the error go away ! REAL, POINTER :: R(:) => NULL() END MODULE M MODULE M_INTERN USE M IMPLICIT NONE REAL, POINTER :: ARR(:) => NULL() END MODULE M_INTERN ! -- end of test.f90 $ gfortran -c test.f90 test.f90:12.37: REAL, POINTER :: ARR(:) => NULL() 1 Error: Cannot change attributes of USE-associated symbol null at (1) Kind regards,
Confirmed from 4.3.1 to trunk.
decl.c's gfc_match_null has: gfc_intrinsic_symbol (sym); if (sym->attr.proc != PROC_INTRINSIC && (!gfc_add_procedure(&sym->attr, PROC_INTRINSIC, sym->name, NULL) || !gfc_add_function (&sym->attr, sym->name, NULL))) return MATCH_ERROR; Failing is the call to gfc_add_procedure. Here, attr.proc = PROC_UNKNOWN attr.intrinsic = 1 attr.use_assoc = 1 attr.if_source = IFSRC_DECL Possible patch? --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -1705,2 +1705,3 @@ gfc_match_null (gfc_expr **result) if (sym->attr.proc != PROC_INTRINSIC + && !(sym->attr.use_assoc && sym->attr.intrinsic) && (!gfc_add_procedure(&sym->attr, PROC_INTRINSIC, sym->name, NULL)
Author: burnus Date: Sun May 5 14:01:38 2013 New Revision: 198609 URL: http://gcc.gnu.org/viewcvs?rev=198609&root=gcc&view=rev Log: 2013-05-05 Tobias Burnus <burnus@net-b.de> PR fortran/57141 * decl.c (gfc_match_null): Permit use-associated NULL intrinsic. 2013-05-05 Tobias Burnus <burnus@net-b.de> PR fortran/57141 * gfortran.dg/null_8.f90: New. Added: trunk/gcc/testsuite/gfortran.dg/null_8.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/decl.c trunk/gcc/testsuite/ChangeLog
FIXED on the trunk (GCC 4.9). Thanks for the report!
I am experiencing this problem in gfortran from gcc version 10.2.0 and the same workaround also works. It seems to be a regression.
(In reply to Antonio from comment #5) > I am experiencing this problem in gfortran from gcc version 10.2.0 and the > same workaround also works. It seems to be a regression. Hi Antonio. Do you use exactly the program from the original comment 0 – or some other program? That program works here with mainline (GCC 11) and a GCC 10.2.0. Additionally, exactly that program is part of the regression testsuite since 2013, hence, issues would show up, but don't. Thus, I assume that you have a slightly different program. If so, can you please open a new PR (problem report) – and include/attach your failing variant?
Ok, I have created the following bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99651