[Patch, Fortran, OOP] PR 47978: Invalid INTENT in overriding TBP not detected

Janus Weil janus@gcc.gnu.org
Fri Sep 9 19:03:00 GMT 2011


Hi all,

here is another small patch for an accepts-invalid OOP problem: When
overriding a type-bound procedure, we need to check that the intents
of the formal args agree (or more general: their 'characteristics', as
defined in chapter 12.3.2 of the F08 standard). For now I'm only
checking type+rank as well as the INTENT and OPTIONAL attributes, but
I added a FIXME for more comprehensive checking (which could be added
in a follow-up patch).

On the technical side of things, I'm adding a new function
'check_dummy_characteristics', which is called in two places:
 * gfc_compare_interfaces and
 * gfc_check_typebound_override.

A slight subtlety is given by the fact that for the PASS argument, the
type of the argument does not have to agree when overriding.

The improved checking also caught an invalid test case in the
testsuite (dynamic_dispatch_5), for another one the error message
changed slightly (typebound_proc_6).

Regtested on x86_64-unknown-linux-gnu. Ok for trunk?

Cheers,
Janus


2011-09-09  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/47978
	* interface.c (check_dummy_characteristics): New function to check the
	characteristics of dummy arguments.
	(gfc_compare_interfaces,gfc_check_typebound_override): Call it here.


2011-09-09  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/47978
	* gfortran.dg/dynamic_dispatch_5.f03: Fix invalid test case.
	* gfortran.dg/typebound_proc_6.f03: Changed wording in error message.
	* gfortran.dg/typebound_override_1.f90: New.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr47978_v2.diff
Type: text/x-diff
Size: 5856 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20110909/b39280a4/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: typebound_override_2.f90
Type: text/x-fortran
Size: 655 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20110909/b39280a4/attachment-0001.bin>


More information about the Gcc-patches mailing list