OSDN Git Service

2009-05-08 Janus Weil <janus@gcc.gnu.org>
authorjanus <janus@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 8 May 2009 09:08:13 +0000 (09:08 +0000)
committerjanus <janus@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 8 May 2009 09:08:13 +0000 (09:08 +0000)
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  <janus@gcc.gnu.org>

PR fortran/39876
* gfortran.dg/intrinsic_3.f90: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@147279 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/intrinsic.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/intrinsic_3.f90 [new file with mode: 0644]

index fc0a049..83ad8cd 100644 (file)
@@ -1,3 +1,9 @@
+2009-05-08  Janus Weil  <janus@gcc.gnu.org>
+
+       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  <burnus@net-b.de>
 
        * invoke.texi: Add do/recursion to the -fcheck= summary.
index 7676fa2..ca125a3 100644 (file)
@@ -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;
     }
index 2dc3dd9..fc1bccc 100644 (file)
@@ -1,3 +1,8 @@
+2009-05-08  Janus Weil  <janus@gcc.gnu.org>
+
+       PR fortran/39876
+       * gfortran.dg/intrinsic_3.f90: New.
+
 2009-05-07  Janis Johnson  <janis187@us.ibm.com>
 
        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 (file)
index 0000000..fcd40e9
--- /dev/null
@@ -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 <alexei.matveev+gcc@gmail.com>
+
+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" } }
+