Index: gcc-4.3/gcc/testsuite/gfortran.dg/implicit_10.f90 =================================================================== --- gcc-4.3/gcc/testsuite/gfortran.dg/implicit_10.f90 (revision 0) +++ gcc-4.3/gcc/testsuite/gfortran.dg/implicit_10.f90 (revision 0) @@ -0,0 +1,33 @@ +! { dg-do run } +! Check fix for PR24783 where we did try to resolve the implicit type +! from the wrong namespace thus rejecting valid code. + MODULE mod1 + IMPLICIT NONE + CONTAINS + SUBROUTINE sub(vec, ny) + IMPLICIT REAL (a-h,o-z) + IMPLICIT INTEGER (i-n) + DIMENSION vec(ny) + ny = fun(vec(ny),1,1) + RETURN + END SUBROUTINE sub + REAL FUNCTION fun(r1, i1, i2) + IMPLICIT REAL (r,f) + IMPLICIT INTEGER (i) + DIMENSION r1(i1:i2) + r1(i1) = i1 + 1 + r1(i2) = i2 + 1 + fun = r1(i1) + r1(i2) + END FUNCTION fun + END MODULE mod1 + + use mod1 + IMPLICIT REAL (d) + INTEGER i + dimension di(5) + i = 1 + if (fun(di(i),1,2).NE.5) call abort() + call sub(di(i),i) + if (i.NE.4) call abort() + end +! { dg-final { cleanup-modules "mod1" } } Index: gcc-4.3/gcc/fortran/resolve.c =================================================================== --- gcc-4.3/gcc/fortran/resolve.c (revision 118752) +++ gcc-4.3/gcc/fortran/resolve.c (working copy) @@ -232,7 +232,7 @@ resolve_formal_arglist (gfc_symbol * pro { gfc_error ("Character-valued argument '%s' of statement function at " - "%L must has constant length", + "%L must have constant length", sym->name, &sym->declared_at); continue; } @@ -2956,7 +2956,7 @@ resolve_variable (gfc_expr * e) else { /* Must be a simple variable reference. */ - if (gfc_set_default_type (sym, 1, NULL) == FAILURE) + if (gfc_set_default_type (sym, 1, sym->ns) == FAILURE) return FAILURE; e->ts = sym->ts; } @@ -5998,11 +5998,9 @@ resolve_symbol (gfc_symbol * sym) case FL_PARAMETER: if (resolve_fl_parameter (sym) == FAILURE) return; - break; default: - break; } @@ -6682,7 +6680,7 @@ resolve_equivalence (gfc_equiv *eq) { if (value_name != NULL) { - gfc_error ("Initialized objects '%s' and '%s' cannot both " + gfc_error ("Initialized objects '%s' and '%s' cannot both " "be in the EQUIVALENCE statement at %L", value_name, sym->name, &e->where); continue;