From: Janus Weil Date: Fri, 8 May 2009 09:08:13 +0000 (+0200) Subject: re PR fortran/39876 (module procedure name that collides with the GNU intrinsic) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=cb8e4445ef25e1da025712d0595274b297b78ec1;p=gcc.git re PR fortran/39876 (module procedure name that collides with the GNU intrinsic) 2009-05-08 Janus Weil PR fortran/39876 * intrinsic.c (gfc_is_intrinsic): Do not add the EXTERNAL attribute if the symbol is a module procedure. 2009-05-08 Janus Weil PR fortran/39876 * gfortran.dg/intrinsic_3.f90: New. From-SVN: r147279 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index fc0a0494c97..83ad8cdbe5b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2009-05-08 Janus Weil + + PR fortran/39876 + * intrinsic.c (gfc_is_intrinsic): Do not add the EXTERNAL attribute if + the symbol is a module procedure. + 2009-05-08 Tobias Burnus * invoke.texi: Add do/recursion to the -fcheck= summary. diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c index 7676fa221e5..ca125a36335 100644 --- a/gcc/fortran/intrinsic.c +++ b/gcc/fortran/intrinsic.c @@ -836,13 +836,17 @@ gfc_is_intrinsic (gfc_symbol* sym, int subroutine_flag, locus loc) /* See if this intrinsic is allowed in the current standard. */ if (gfc_check_intrinsic_standard (isym, &symstd, false, loc) == FAILURE) { - if (gfc_option.warn_intrinsics_std) - gfc_warning_now ("The intrinsic '%s' at %L is not included in the" - " selected standard but %s and '%s' will be treated as" - " if declared EXTERNAL. Use an appropriate -std=*" - " option or define -fall-intrinsics to allow this" - " intrinsic.", sym->name, &loc, symstd, sym->name); - sym->attr.external = 1; + if (sym->attr.proc == PROC_UNKNOWN) + { + if (gfc_option.warn_intrinsics_std) + gfc_warning_now ("The intrinsic '%s' at %L is not included in the" + " selected standard but %s and '%s' will be" + " treated as if declared EXTERNAL. Use an" + " appropriate -std=* option or define" + " -fall-intrinsics to allow this intrinsic.", + sym->name, &loc, symstd, sym->name); + gfc_add_external (&sym->attr, &loc); + } return false; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2dc3dd9e3e9..fc1bccc8b95 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-05-08 Janus Weil + + PR fortran/39876 + * gfortran.dg/intrinsic_3.f90: New. + 2009-05-07 Janis Johnson PR c/39037 diff --git a/gcc/testsuite/gfortran.dg/intrinsic_3.f90 b/gcc/testsuite/gfortran.dg/intrinsic_3.f90 new file mode 100644 index 00000000000..fcd40e94bbb --- /dev/null +++ b/gcc/testsuite/gfortran.dg/intrinsic_3.f90 @@ -0,0 +1,40 @@ +! { dg-do compile } +! { dg-options "-std=f95" } +! +! PR 39876: module procedure name that collides with the GNU intrinsic +! +! Contributed by Alexei Matveev + +module p + implicit none + + contains + + subroutine test() + implicit none + print *, avg(erfc) + end subroutine test + + function avg(f) + implicit none + double precision :: avg + interface + double precision function f(x) + implicit none + double precision, intent(in) :: x + end function f + end interface + avg = ( f(1.0D0) + f(2.0D0) ) / 2 + end function avg + + function erfc(x) + implicit none + double precision, intent(in) :: x + double precision :: erfc + erfc = x + end function erfc + +end module p + +! { dg-final { cleanup-modules "p" } } +