Proposed patch to 13249
Steve Kargl
sgk@troutmask.apl.washington.edu
Sun May 16 17:12:00 GMT 2004
On Sun, May 16, 2004 at 05:18:52PM +0300, Victor Leikehman wrote:
>
> A variable that is both defined in a module, and used as common
> block name, triggers error message "Cannot change attributes of
> USE-associated symbol". For example, the following (valid) code
> is rejected:
>
> MODULE MOD
> INTEGER FOO
> END
> PROGRAM MAIN
> USE MOD
> COMMON /FOO/ BAR
> END
(snip)
>
> Function gfc_add_common, in file symbol.c, says:
>
> gfc_add_common (symbol_attribute * attr, locus * where)
> {
> if (check_used (attr, where) || check_done (attr, where))
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> return FAILURE;
>
> attr->common = 1;
> return check_conflict (attr, where);
> }
>
> The call to check_used() checks the "use" attribute, which
> is 1 for variables defined in modules. I can't understand
> why this check is necessary. Removing the call to check_used
> apparently fixes the problem and does not cause regressions,
> BUT I guess it is there for a purpose...
>
> If nobody can see why this check is needed, I will submit the
> patch.
Victor,
I think the check is there for this modified program
MODULE MOD
INTEGER FOO
END
PROGRAM MAIN
USE MOD
COMMON /BAR/ FOO
END
This is NAG's compiler
kargl[222] f95 -o r r.f90
Error: r.f90, line 6: Redeclaration of symbol FOO from USEd module
detected at /@FOO
[f95 terminated - errors found by pass 1]
This is gfortran and it prints the error message you quoted.
kargl[223] gfc -o r r.f90
In file r.f90:6
COMMON /BAR/ FOO
1
Error: Cannot change attributes of USE-associated symbol at (1)
I suspect the if (...) needs to check that the FOO in your
"COMMON /FOO/ BAR" is not the name of a COMMON block.
--
Steve
More information about the Fortran
mailing list