[PATCH, Fortran] PROCEDURE declarations

Janus Weil jaydub66@googlemail.com
Sat Sep 1 22:16:00 GMT 2007


Hi all,
I just made another structural change to my implementation of
procedure declarations: Up to now I had just one matcher function
"gfc_match_procedure", which handled all occurrences of the PROCEDURE
keyword.
But actually the patch supports two distinct situations where PROCEDURE is used:

* The first one is the general PROCEDURE statement, which can specify
an interface and some attributes for the procedure, as in

PROCEDURE(intrfc), public, bind(c):: proc

Here PROCEDURE acts similar to EXTERNAL.


* The second situation is inside an interface declaration:

INTERFACE gen
  PROCEDURE a
  MODULE PROCEDURE b
  SUBROUTINE c
  END SUBROUTINE
END INTERFACE

Here the syntax is quite different (e.g. no attributes may be specified etc).


I think it makes sense to practice a better separation of both cases
in the code, which makes it more readable and error proof. And apart
from that it makes it easier to implement the remaining parts of the
PROCEDURE syntax, e.g. procedure pointers, procedure pointer
components and type-bound procedures.
So I introduced two new functions "gfc_match_procedure_decl" and
"gfc_match_procedure_in_interface" to separately match PROCEDURE
statements in the situations described above, and kept
"gfc_match_procedure" just for deciding which one to use (from there
one could later also call stuff like "gfc_match_procedure_component").
The new patch is attached. I hope you agree with me that this makes
sense. If you have any concerns (or further comments) please let me
know.
Cheers,
Janus



2007-09-01  Janus Weil  <jaydub66@gmail.com>
	    Paul Thomas  <pault@gcc.gnu.org>

	* decl.c (gfc_match_procedure,gfc_match_procedure_decl,
	gfc_match_procedure_in_interface): Handle PROCEDURE statements.
	* gfortran.h (struct gfc_symbol): New member "gfc_symbol *interface".
	(enum gfc_statement): New element "ST_PROCEDURE".
	(strcut symbol_attribute): New member "unsigned procedure".
	* interface.c (check_interface0): Extended error checking.
	* match.h: Add function prototypes.
	* parse.c (decode_statement,next_statement,gfc_ascii_statement,
	parse_derived,parse_interface): Implement PROCEDURE statements.
	* resolve.c (resolve_symbol): Ditto.
	* symbol.c (check_conflict): Ditto.
	(copy_formal_args): New function for copying formal argument lists.


2007-09-01  Janus Weil  <jaydub66@gmail.com>
	    Tobias Burnus  <burnus@net-b.de>

	* gfortran.dg/proc_decl_1.f90: New.
	* gfortran.dg/proc_decl_2.f90: New.
	* gfortran.dg/proc_decl_3.f90: New.
	* gfortran.dg/proc_decl_4.f90: New.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: procdecl128012.diff
Type: text/x-patch
Size: 22593 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070901/20c4afe1/attachment.bin>


More information about the Gcc-patches mailing list