[Patch, fortran] PR22304 - gfortran silently changes values in equivalenced variables
Paul Thomas
paulthomas2@wanadoo.fr
Fri Aug 5 16:25:00 GMT 2005
This patch, that Mike Albert found, is devastatingly simple; just one
added line. It is discussed in the list for the PR but not adopted
because it was not clear how it worked.
In fact, it is also relatively easy to understand:
(i) Translate_common calls add_equivalences, which calls
find_equivalences. At present, this only marks, as used, the
equivalence partners that appear in the common block.
(ii) Later, finish_equivalences does the same again. This time it
creates local unions for all equivalence variables that are not used;
ie. those that are declared in the local scope.
(iii) Thus, where this happens, references in this scope point to the
local union, rather than the common block.
(iv) The fix acts on step (i) by marking the partners in the local
scope, as used, as well.
There is a strange side-effect of this fix, noted by Thomas Koenig, in
the PR correspondence: Where this fix operates, -fdump-tree-original
produces a scope block that is not terminated by a right brace. The
gimple output is fine and the programs run fine. Using one more
variable in this scope clears the problem and restores the right brace.
Is this a gfortran or a tree-dump problem?
2005-08-05 Mike Albert <albertm@uphs.upenn.edu>
PR fortran/22304
* trans-common.c (find_equivalences): Ensure that both partners
in common block equivalences are marked as used. This prevents
the second call to this function from making local unions.
2005-08-05 Paul Thomas <pault@gcc.gnu.org>
PR fortran/22304
* gfortran.dg/common_equivalence_1.f: New.
Patch and test case are attached.
OK for mainline and 4.0?
Paul T
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: comm_equiv.diff
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20050805/2302fdbc/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: common_equivalence_1.f
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20050805/2302fdbc/attachment-0001.ksh>
More information about the Fortran
mailing list