This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, Fortran] PR42677: [4.5 Regression] Bogus Error: Ambiguous interfaces '...' in intrinsic assignment operator


Hi all,

here is my fix for this PR. The regression actually goes back to one
of my patches (r148519). However, it seems to me this patch just
uncovered a bug which has been there before. Namely:
'gfc_check_interfaces' is being called in 'read_module', which is just
too early, as the test case shows.

If we have a use statement inside an INTERFACE definition, then
'gfc_check_interfaces' comes too early, since the contained procedures
have not been parsed yet. In the test case, 'gfc_check_interfaces' is
called when the USE statement inside of 'delete_m' is parsed. At this
point, it is known that 'assign_to_atm' is an assignment interface.
However, its definition has not been parsed yet, therefore its
explicit interface is not known yet. So it's not possible to check for
interface ambiguities at this point.

In summary: Calling 'gfc_check_interfaces' in 'read_module' is too
early. Anyway, 'gfc_check_interfaces' is being called by
'resolve_types' later on, so it seems to me we can just remove the
call in 'read_module'.

This also has another advantage: It guarantees that interface checking
is always being done at resolution stage, which in turn makes the
attribute 'ambiguous_interfaces' unnecessary. This attribute was only
used to remember the fact that there was an ambiguity conflict, so
that a warning could be thrown at resolution stage, when it is known
whether the interface actually has been referenced. Now, if we only
check for ambiguities at resolution stage, we can directly throw the
warning and need no additional attribute.

The patch has been regression-tested on x86_64-unknown-linux-gnu. Ok for trunk?

Cheers,
Janus


gcc/fortran/
2010-01-16  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/42677
	* gfortran.h (symbol_attribute): Remove 'ambiguous_interfaces'.
	* interface.c (check_interface1): Move a warning message here from
	resolve_fl_procedure.
	(check_sym_interfaces): Removed 'attr.ambiguous_interfaces'.
	* module.c (read_module): Remove call to gfc_check_interfaces, since
	this comes too early here.
	* resolve.c (resolve_fl_procedure): Move warning message to
	check_interface1.

gcc/testsuite/
2010-01-16  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/42677
	* gfortran.dg/interface_assignment_5.f90: New test.

Attachment: pr42677.diff
Description: Binary data

Attachment: interface_assignment_5.f90
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]