[Patch, fortran] PR30746 - 50th Anniversary Bug - Forward reference to contained function
Paul Richard Thomas
paul.richard.thomas@gmail.com
Thu May 10 20:08:00 GMT 2007
:ADDPATCH fortran:
This represents the fourth or fifth attempt at fixing this bug. I was
beginning to think that it was going to be necessary to split parsing
up into two steps; the first for specification expressions and the
second for the execution part. That might be a nice project for the
future, since it would clobber a number of kludges and fix-ups.
However, it hardly seemed worth it for what is a first magnitude
corner case.
The problem arises because modules are capable of supporting doubly
contained procedures. In this case, parse.c
(gfc_fixup_sibling_symbols) does not work for us all the time because
a reference can be made to a symbol at module level, which should be
overwritten by a procedure that is parsed later. gfc_match_rvalue is
generating expressions that refer to the wrong symbol because the
procedure symbol, in an intermediate namespace, has not yet been
generated.
This patch works by intercepting the incorrectly associated
expressions in gfc_resolve_expr and calling gfc_match_rvalue one more.
This latter then makes the correct host association and the
expression is copied across. Note the messing around with error
flagging; this is necessary to prevent gfc_match_name from generating
an error, when it encounters a literal actual argument. Similarly,
care has to be taken to deallocate the bits of the expression that are
liable to be superceded.
I was concerned that this not load up compilation times too much -
even without opimization, the time increase is at the 1-2% level,
which I think is acceptable. Once any level of optimization is turned
on, the difference becomes unmeasurable.
Bootstrapped and regtested on x86_ia64/FC5 - OK for trunk?
Paul
2007-05-10 Paul Thomas <pault@gcc.gnu.org>
PR fortran/31540
* resolve.c (check_host_association): New function that detects
incorrect host association and corrects it.
(gfc_resolve_expr): Call the new function for variables and
functions.
* match.h : Remove prototype for gfc_match_rvalue.
* gfortran.h : Add prototype for gfc_match_rvalue.
2007-05-10 Paul Thomas <pault@gcc.gnu.org>
PR fortran/31540
* gfortran.dg/host_assoc_function_1.f90: New test.
--
"Success is the ability to go from one failure to another with no loss
of enthusiasm." - Winston Churchill
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr30746.diff
Type: text/x-patch
Size: 4170 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20070510/da2ff050/attachment.bin>
More information about the Fortran
mailing list