This is the mail archive of the 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]

[Fortran, Patch] PR 33917 - PROCEDURE(proc-interface) - ensure proc-interface is resolved

Hi all, hi Janus and Thomas,

:ADDPATCH fortran:


  ! sub be a procedure with an explicit interface
  procedure(sub) :: p4
  procedure(p4) :: p6

fails if the symbol p6 is resolved before p4 as then
p6->interface->attr.if_source is IFSRC_UNKNOWN.

Whether it fails, depends how one walks the symbol tree. See PR33917 for
an example which fails, unless you comment a line.

The following patch simply checks whether the proc-interface symbol in
"PROCEDURE([proc-interface])" has already a non-NULL sym->interface and,
if yes, it uses it then instead of using "sym" itself.

I think in terms of copying attributes this should be ok; however, I
would not mind if you try to come up with a reason why this is wrong
(wrong/missing attributes, memory leak, ...) or whether there is still a
case for which it will (still) fail.

Do you would like to see a comment above the added line or is its
meaning clear?

Built and regression tested on x86-64-linux.
OK for the trunk?

2007-10-27  Tobias Burnus  <>

	PR fortran/33917
	* decl.c (match_procedure_decl): If available, use directly
	the procedure interface.

2007-10-27  Tobias Burnus  <>

	PR fortran/33917
	* gfortran.dg/proc_decl_5.f90: New.
Index: gcc/fortran/decl.c
--- gcc/fortran/decl.c	(Revision 129680)
+++ gcc/fortran/decl.c	(Arbeitskopie)
@@ -3920,6 +3920,9 @@ match_procedure_decl (void)
   /* Various interface checks.  */
   if (proc_if)
+      if (proc_if->interface)
+	proc_if = proc_if->interface;
       if (proc_if->generic)
 	  gfc_error ("Interface '%s' at %C may not be generic", proc_if->name);
Index: gcc/testsuite/gfortran.dg/proc_decl_5.f90
--- gcc/testsuite/gfortran.dg/proc_decl_5.f90	(Revision 0)
+++ gcc/testsuite/gfortran.dg/proc_decl_5.f90	(Revision 0)
@@ -0,0 +1,20 @@
+! { dg-do compile }
+! PR fortran/33917
+! Depending in which order the symbol tree
+! was walked in resolve, gfortran resolved
+! p6 before p4; thus there was no explicit
+! interface available for p4 and an error
+! was printed.
+program s
+  implicit none
+  procedure() :: q2
+  procedure() :: q3
+  procedure() :: q5
+  procedure(sub) :: p4
+  procedure(p4) :: p6
+  subroutine sub
+  end subroutine
+end program s

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