------- Comment #1 from pault at gcc dot gnu dot org 2007-03-27 10:21 ------- This will be submitted this afternoon - Paul
Index: gcc/fortran/decl.c =================================================================== *** gcc/fortran/decl.c (revision 123183) --- gcc/fortran/decl.c (working copy) *************** gfc_match_modproc (void) *** 4241,4246 **** --- 4241,4247 ---- char name[GFC_MAX_SYMBOL_LEN + 1]; gfc_symbol *sym; match m; + gfc_namespace *module_ns; if (gfc_state_stack->state != COMP_INTERFACE || gfc_state_stack->previous == NULL *************** gfc_match_modproc (void) *** 4251,4256 **** --- 4252,4265 ---- return MATCH_ERROR; } + module_ns = gfc_current_ns->parent; + for (; module_ns; module_ns = module_ns->parent) + if (module_ns->proc_name->attr.flavor == FL_MODULE) + break; + + if (module_ns == NULL) + return MATCH_ERROR; + for (;;) { m = gfc_match_name (name); *************** gfc_match_modproc (void) *** 4259,4265 **** if (m != MATCH_YES) return MATCH_ERROR; ! if (gfc_get_symbol (name, gfc_current_ns->parent, &sym)) return MATCH_ERROR; if (sym->attr.proc != PROC_MODULE --- 4268,4274 ---- if (m != MATCH_YES) return MATCH_ERROR; ! if (gfc_get_symbol (name, module_ns, &sym)) return MATCH_ERROR; if (sym->attr.proc != PROC_MODULE Index: gcc/testsuite/gfortran.dg/contained_module_proc_1.f90 =================================================================== *** gcc/testsuite/gfortran.dg/contained_module_proc_1.f90 (revision 0) --- gcc/testsuite/gfortran.dg/contained_module_proc_1.f90 (revision 0) *************** *** 0 **** --- 1,40 ---- + ! { dg-do run } + ! Tests the check for PR31292, in which the module procedure + ! statement would put the symbol for assign_t in the wrong + ! namespace and this caused the interface checking to fail. + ! + ! Contributed by Tobias Burnus <[EMAIL PROTECTED]> + ! + module chk_gfortran + implicit none + type t + integer x + end type t + contains + function is_gfortran() + logical is_gfortran + interface assignment(=) + module procedure assign_t + end interface assignment(=) + type(t) y(3) + + y%x = (/1,2,3/) + y = y((/2,3,1/)) + is_gfortran = y(3)%x == 1 + end function is_gfortran + + elemental subroutine assign_t(lhs,rhs) + type(t), intent(in) :: rhs + type(t), intent(out) :: lhs + + lhs%x = rhs%x + end subroutine assign_t + end module chk_gfortran + + program fire + use chk_gfortran + implicit none + if(.not. is_gfortran()) call abort() + end program fire + ! { dg-final { cleanup-modules "chk_gfortran" } } + -- pault at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|unassigned at gcc dot gnu |pault at gcc dot gnu dot org |dot org | Status|UNCONFIRMED |ASSIGNED Ever Confirmed|0 |1 Last reconfirmed|0000-00-00 00:00:00 |2007-03-27 10:21:29 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31292