[PATCH, Fortran] ABSTRACT INTERFACE

Tobias Burnus burnus@net-b.de
Sat Aug 18 19:10:00 GMT 2007


Hi Tobias,

To start with the most important:

Is the attached patch ok for the trunk? Regression tested on
x86_64-unknown-linux-gnu.


Tobias Schlüter wrote:
>> +    case INTERFACE_ABSTRACT:
>>        gfc_error ("Missing generic specification in USE statement at
>> %C");
> Please add a test for this error.  In general all error messages
> should be tested.
I think this is impossible. gfc_match_interface has difficulties
returning INTERFACE_NAMELESS as gfc_match_name() [essentially] either
gives an error or matches an (existing or nonexisting) name. But
INTERFACE_ABSTRACT is *never* returned. However, it is needed in
module.c since if not all enum possibilities have a "case..:" in the
switch() block, the compiler bails out with an error.

As compensation I add a test case for -std=f95 ;-)

>> +      match ("abstract interface", gfc_match_abstract_interface,
>> ST_INTERFACE);
> This should probably be "abstract% interface" (i.e. with an obligatory
> blank).
I think I'm not alone forgetting that Fortran ignores at many places
spaces; while they are here required ...

>> +    gfc_error ("Name of ABSTRACT INTERFACE at %C cannot be the same
>> as "
>> +           "an intrinsic type: %s",gfc_new_block->name);
> You're missing some intrinsic types there.
... they are optional for "double precision" and "double complex".

Thanks for reminding and spotting these!


> I take it that there is no way of using this feature by itself?
Not really. ABSTRACT INTERFACEs only make sense as "name" in
PROCEDURE([name]).


PROCEDURE (without pointers) acts as extended version of the EXTERNAL
statement:

- PROCEDURE() or PROCEDURE(REAL) etc. do the same as EXTERNAL (except
that bind(C) is allowed)

- PROCEDURE(abstract interface name)  saves the typing of several
interfaces for functions which have the same interface

- PROCEDURE(existing procedure) does the same if one has already an
interface or use/host associated function with the needed interface


(The real fun of PROCEDURE starts with (procedure) POINTER, e.g.
type  t
  procedure(), pointer, pass(x_this) :: p => null
  type(t), pointer :: next => null
end type t
where call mytype%p() calls the procedure with "mytype" as argument to
"x_this=".)


Tobias
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: abstract.diff
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20070818/00d5cf62/attachment.ksh>


More information about the Fortran mailing list