[PATCH, Fortran] ABSTRACT INTERFACE

Tobias Schlüter tobias.schlueter@physik.uni-muenchen.de
Sat Aug 18 16:42:00 GMT 2007


Janus Weil wrote:
> Index: gcc/fortran/module.c
> ===================================================================
> --- gcc/fortran/module.c	(revision 127586)
> +++ gcc/fortran/module.c	(working copy)
> @@ -599,6 +599,7 @@ gfc_match_use (void)
>        switch (type)
>  	{
>  	case INTERFACE_NAMELESS:
> +	case INTERFACE_ABSTRACT:
>  	  gfc_error ("Missing generic specification in USE statement at %C");
>  	  goto cleanup;
>  

Please add a test for this error.  In general all error messages should 
be tested.

> Index: gcc/fortran/parse.c
> ===================================================================
> --- gcc/fortran/parse.c	(revision 127586)
> +++ gcc/fortran/parse.c	(working copy)
> @@ -172,6 +172,7 @@ decode_statement (void)
>    switch (c)
>      {
>      case 'a':
> +      match ("abstract interface", gfc_match_abstract_interface, ST_INTERFACE);
>        match ("allocate", gfc_match_allocate, ST_ALLOCATE);
>        match ("allocatable", gfc_match_allocatable, ST_ATTR_DECL);
>        match ("assign", gfc_match_assign, ST_LABEL_ASSIGNMENT);

This should probably be "abstract% interface" (i.e. with an obligatory 
blank).

> @@ -1795,6 +1796,18 @@ loop:
>  	}
>      }
>  
> +  if (current_interface.type == INTERFACE_ABSTRACT)
> +    {
> +      gfc_new_block->attr.abstract = 1;
> +      if (!strcmp(gfc_new_block->name,"integer")
> +	  || !strcmp(gfc_new_block->name,"real")
> +	  || !strcmp(gfc_new_block->name,"complex")
> +	  || !strcmp(gfc_new_block->name,"character")
> +	  || !strcmp(gfc_new_block->name,"logical"))
> +	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.  Please merge this with the 
code from decl.c:5468 (and perhaps similar code in other places, but I 
didn't find any), putting this into a single function, something like 
gfc_is_intrinsic_typename (const char *name, const char *error_message). 
  This function should go into symbol.c.

Apart from that the patch looks fine.  I take it that there is no way of 
using this feature by itself?  In that case I would be a bit reluctant 
to add this by itself, instead of waiting for procedure pointers, but I 
don't think this is worth being overly rigid, especially since the other 
patch seems to be coming along quite well.

Thanks,
- Tobi



More information about the Fortran mailing list