This is the mail archive of the gcc-patches@gcc.gnu.org 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]

Re: [Patch, fortran] PR20880 - Failure to detect procedures encompassing own interface


erik,
I hate being the bringer of bad news, but this patch doesn't reg.test
cleanly for me on trunk (r119061) on Gentoo Linux/x86; I get
That's alright - we have the patches reviewed for a reason :-)


gfortran.dg/assumed_charlen_function_1.f90 -O (internal compiler error)
gfortran.dg/func_derived_3.f90 -O2 (internal compiler error)
are still fine for me on a tree that was updated last night. I would be grateful if you would let me have either the appropriate section of the regtest log and/or a gdb session for these two testcases. The patch is sufficiently innocuous that I am astonished that there is an installation difference.
FAIL: gfortran.dg/interface_3.f90
This is my fault - I posted the penultimate version of the patch; the error next to the function reference was missing. I have attached the "real" version.

Many thanks

Paul

Index: gcc/fortran/resolve.c
===================================================================
*** gcc/fortran/resolve.c	(revision 119077)
--- gcc/fortran/resolve.c	(working copy)
*************** static try
*** 5522,5532 ****
--- 5522,5541 ----
  resolve_fl_procedure (gfc_symbol *sym, int mp_flag)
  {
    gfc_formal_arglist *arg;
+   gfc_symtree *st;
  
    if (sym->attr.function
  	&& resolve_fl_var_and_proc (sym, mp_flag) == FAILURE)
      return FAILURE;
  
+   st = gfc_find_symtree (gfc_current_ns->sym_root, sym->name);
+   if (st && st->ambiguous && !sym->attr.generic)
+     {
+       gfc_error ("Procedure %s at %L is ambiguous",
+ 		 sym->name, &sym->declared_at);
+       return FAILURE;
+     }
+ 
    if (sym->ts.type == BT_CHARACTER)
      {
        gfc_charlen *cl = sym->ts.cl;
Index: gcc/fortran/symbol.c
===================================================================
*** gcc/fortran/symbol.c	(revision 119075)
--- gcc/fortran/symbol.c	(working copy)
*************** gfc_add_explicit_interface (gfc_symbol *
*** 1168,1173 ****
--- 1168,1184 ----
        return FAILURE;
      }
  
+   if (current_interface.ns
+ 	&& current_interface.ns->proc_name
+ 	&& current_interface.ns->proc_name->name
+ 	&& strcmp (current_interface.ns->proc_name->name, sym->name) == 0)
+     {
+       gfc_error ("'%s' at %L is the name of the enclosing procedure",
+ 		 sym->name, where);
+       /* Return success so that redundant knock-on errors do not occur.  */
+       return SUCCESS;
+     }
+ 
    sym->formal = formal;
    sym->attr.if_source = source;
  
Index: gcc/testsuite/gfortran.dg/interface_3.f90
===================================================================
*** gcc/testsuite/gfortran.dg/interface_3.f90	(revision 0)
--- gcc/testsuite/gfortran.dg/interface_3.f90	(revision 0)
***************
*** 0 ****
--- 1,45 ----
+ ! { dg-do compile }
+ ! Tests the fix for PR20880, which was due to failure to the failure
+ ! to detect the USE association of a nameless interface for a
+ ! procedure with the same name as the encompassing scope.
+ !
+ ! Contributed by
+ !
+ module test_mod
+ interface
+   subroutine my_sub (a)
+     real a
+   end subroutine
+ end interface
+ interface
+   function my_fun (a)
+     real a, my_fun
+   end function
+ end interface
+ end module
+ 
+ ! This is the original PR
+ subroutine my_sub (a) ! { dg-error "is ambiguous" }
+   use test_mod
+   real a
+   print *, a
+ end subroutine
+ 
+ integer function my_fun (a) ! { dg-error "is ambiguous" }
+   use test_mod
+   real a
+   print *, a
+   my_fun = 1  ! { dg-error "ambiguous reference" }
+ end function
+ 
+ ! This was found whilst investigating => segfault
+ subroutine thy_sub (a)
+   interface 
+     subroutine thy_sub (a) ! { dg-error "enclosing procedure" }
+       real a
+     end subroutine
+   end interface
+   real a
+   print *, a
+ end subroutine
+ ! { dg-final { cleanup-modules "test_mod" } }

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