public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/39876]  New: module procedure name that collides with the GNU intrinsic
@ 2009-04-23 21:00 alexei dot matveev+gcc at gmail dot com
  2009-04-23 21:19 ` [Bug fortran/39876] " kargl at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: alexei dot matveev+gcc at gmail dot com @ 2009-04-23 21:00 UTC (permalink / raw)
  To: gcc-bugs

Using module procedure names that collide with the GNU intrinsic extensions
is not possible even with -std=f95:

alexei@novo:~/$ gfortran -c -std=f95 p.f90
p.f90:19.19:

      print *, avg(erfc)
                  1
Error: Intrinsic 'erfc' at (1) is not allowed as an actual argument
p.f90:19.19:

      print *, avg(erfc)
                  1
Error: Type/rank mismatch in argument 'f' at (1)

================ p.f90 ================
! NO: program p -- passing internal procedures                                  
!                  as actual args is not allowed                                
module p ! -- passing module procedure IS allowed                               
  implicit none                                                                 

! call test()

  contains

    subroutine test()
      implicit none
      ! *** end of interface ***

      intrinsic sqrt
      intrinsic dsqrt

    ! print *, avg(sqrt)
      print *, avg(dsqrt)
      print *, avg(erfc)
    end subroutine test

    function avg(f) result(r)
      implicit none
      double precision :: r
      interface
        double precision function f(x)
          implicit none
          double precision, intent(in) :: x
        end function f
      end interface
      ! *** end of interface ***

      r = ( f(1.0D0) + f(2.0D0) ) / 2
    end function avg

    function erfc(x) result(r)
      implicit none
      double precision, intent(in) :: x
      double precision             :: r
      ! *** end of interface ***

      r = x
    end function erfc

end ! module/program


-- 
           Summary: module procedure name that collides with the GNU
                    intrinsic
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: alexei dot matveev+gcc at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39876


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/39876] module procedure name that collides with the GNU intrinsic
  2009-04-23 21:00 [Bug fortran/39876] New: module procedure name that collides with the GNU intrinsic alexei dot matveev+gcc at gmail dot com
@ 2009-04-23 21:19 ` kargl at gcc dot gnu dot org
  2009-04-24  5:22 ` kargl at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: kargl at gcc dot gnu dot org @ 2009-04-23 21:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from kargl at gcc dot gnu dot org  2009-04-23 21:19 -------
Upgrade to 4.4.0.  The collision problem is fixed when you use -std=f95.

There is however another problem.

REMOVE:kargl[159] gfc4x -c -std=f95 j.f90
f951: internal compiler error: in build_function_decl, at
fortran/trans-decl.c:1396
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

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


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39876


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/39876] module procedure name that collides with the GNU intrinsic
  2009-04-23 21:00 [Bug fortran/39876] New: module procedure name that collides with the GNU intrinsic alexei dot matveev+gcc at gmail dot com
  2009-04-23 21:19 ` [Bug fortran/39876] " kargl at gcc dot gnu dot org
@ 2009-04-24  5:22 ` kargl at gcc dot gnu dot org
  2009-04-24 12:32 ` dominiq at lps dot ens dot fr
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: kargl at gcc dot gnu dot org @ 2009-04-24  5:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from kargl at gcc dot gnu dot org  2009-04-24 05:22 -------
This patch allows the code in comment #2 to compile with -std=f95.
Don't know if it is correct.

REMOVE:kargl[194] svn diff trans-decl.c 
Index: trans-decl.c
===================================================================
--- trans-decl.c        (revision 146588)
+++ trans-decl.c        (working copy)
@@ -1396,7 +1396,6 @@ build_function_decl (gfc_symbol * sym)
   gfc_formal_arglist *f;

   gcc_assert (!sym->backend_decl);
-  gcc_assert (!sym->attr.external);

   /* Set the line and filename.  sym->declared_at seems to point to the
      last statement for subroutines, but it'll do for now.  */


-- 

kargl at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
      Known to fail|                            |4.3.2 4.5.0
   Last reconfirmed|0000-00-00 00:00:00         |2009-04-24 05:22:22
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39876


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/39876] module procedure name that collides with the GNU intrinsic
  2009-04-23 21:00 [Bug fortran/39876] New: module procedure name that collides with the GNU intrinsic alexei dot matveev+gcc at gmail dot com
  2009-04-23 21:19 ` [Bug fortran/39876] " kargl at gcc dot gnu dot org
  2009-04-24  5:22 ` kargl at gcc dot gnu dot org
@ 2009-04-24 12:32 ` dominiq at lps dot ens dot fr
  2009-05-06 22:08 ` janus at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: dominiq at lps dot ens dot fr @ 2009-04-24 12:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from dominiq at lps dot ens dot fr  2009-04-24 12:32 -------
> This patch allows the code in comment #2 to compile with -std=f95.
> Don't know if it is correct.
> ...

This will remove diagnostic, but not the cause.  I think the problem comes from
redundant information that are inconsistant, probably 

  attr = {
    allocatable = 0, 
    dimension = 0, 
    external = 1,                <---
    intrinsic = 0, 
...
    if_source = IFSRC_DECL, 
    proc = PROC_MODULE,            <--- 
    cray_pointer = 0, 
    cray_pointee = 0, 
    alloc_comp = 0, 
    pointer_comp = 0, 
    private_comp = 0, 
    zero_comp = 0, 
    volatile_ns = 0x0
  }, 

>From the little I understand 'external' should not be set to 1 for functions
listed as intrinsics but not f95 intrinsics.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39876


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/39876] module procedure name that collides with the GNU intrinsic
  2009-04-23 21:00 [Bug fortran/39876] New: module procedure name that collides with the GNU intrinsic alexei dot matveev+gcc at gmail dot com
                   ` (2 preceding siblings ...)
  2009-04-24 12:32 ` dominiq at lps dot ens dot fr
@ 2009-05-06 22:08 ` janus at gcc dot gnu dot org
  2009-05-07 19:11 ` janus at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-05-06 22:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from janus at gcc dot gnu dot org  2009-05-06 22:07 -------

> From the little I understand 'external' should not be set to 1 for functions
> listed as intrinsics but not f95 intrinsics.

I don't see any reason why 'erfc' should get the EXTERNAL attribute here at
all. In any case this happens in gfc_is_intrinsic:

  /* 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;

      return false;
    }

This code was committed as r138122 by Daniel K. as a fix for PR33141, but it
doesn't seem quite right to me. Either one should avoid setting the EXTERNAL
attribute here at all, or at least only do it if the symbol is not specified by
the user as a module procedure.


-- 

janus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |janus at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39876


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/39876] module procedure name that collides with the GNU intrinsic
  2009-04-23 21:00 [Bug fortran/39876] New: module procedure name that collides with the GNU intrinsic alexei dot matveev+gcc at gmail dot com
                   ` (3 preceding siblings ...)
  2009-05-06 22:08 ` janus at gcc dot gnu dot org
@ 2009-05-07 19:11 ` janus at gcc dot gnu dot org
  2009-05-08  9:08 ` janus at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-05-07 19:11 UTC (permalink / raw)
  To: gcc-bugs



-- 

janus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |janus at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2009-04-24 05:22:22         |2009-05-07 19:11:13
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39876


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/39876] module procedure name that collides with the GNU intrinsic
  2009-04-23 21:00 [Bug fortran/39876] New: module procedure name that collides with the GNU intrinsic alexei dot matveev+gcc at gmail dot com
                   ` (4 preceding siblings ...)
  2009-05-07 19:11 ` janus at gcc dot gnu dot org
@ 2009-05-08  9:08 ` janus at gcc dot gnu dot org
  2009-05-08  9:11 ` janus at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-05-08  9:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from janus at gcc dot gnu dot org  2009-05-08 09:08 -------
Subject: Bug 39876

Author: janus
Date: Fri May  8 09:08:13 2009
New Revision: 147279

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=147279
Log:
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  Janus Weil  <janus@gcc.gnu.org>

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


Added:
    trunk/gcc/testsuite/gfortran.dg/intrinsic_3.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/intrinsic.c
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39876


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/39876] module procedure name that collides with the GNU intrinsic
  2009-04-23 21:00 [Bug fortran/39876] New: module procedure name that collides with the GNU intrinsic alexei dot matveev+gcc at gmail dot com
                   ` (5 preceding siblings ...)
  2009-05-08  9:08 ` janus at gcc dot gnu dot org
@ 2009-05-08  9:11 ` janus at gcc dot gnu dot org
  2009-09-02  0:11 ` pablomme at googlemail dot com
  2009-09-11 22:11 ` kargl at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-05-08  9:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from janus at gcc dot gnu dot org  2009-05-08 09:11 -------
Fixed with r147279. Closing.


-- 

janus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39876


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/39876] module procedure name that collides with the GNU intrinsic
  2009-04-23 21:00 [Bug fortran/39876] New: module procedure name that collides with the GNU intrinsic alexei dot matveev+gcc at gmail dot com
                   ` (6 preceding siblings ...)
  2009-05-08  9:11 ` janus at gcc dot gnu dot org
@ 2009-09-02  0:11 ` pablomme at googlemail dot com
  2009-09-11 22:11 ` kargl at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: pablomme at googlemail dot com @ 2009-09-02  0:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pablomme at googlemail dot com  2009-09-02 00:10 -------
*** Bug 41222 has been marked as a duplicate of this bug. ***


-- 

pablomme at googlemail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pablomme at googlemail dot
                   |                            |com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39876


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug fortran/39876] module procedure name that collides with the GNU intrinsic
  2009-04-23 21:00 [Bug fortran/39876] New: module procedure name that collides with the GNU intrinsic alexei dot matveev+gcc at gmail dot com
                   ` (7 preceding siblings ...)
  2009-09-02  0:11 ` pablomme at googlemail dot com
@ 2009-09-11 22:11 ` kargl at gcc dot gnu dot org
  8 siblings, 0 replies; 10+ messages in thread
From: kargl at gcc dot gnu dot org @ 2009-09-11 22:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from kargl at gcc dot gnu dot org  2009-09-11 22:11 -------
Subject: Bug 39876

Author: kargl
Date: Fri Sep 11 22:11:06 2009
New Revision: 151645

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=151645
Log:
2009-09-11 Steven G. Kargl  <kargl@gcc.gnu.org>

        Backport from mainline, r147279:

    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  Janus Weil  <janus@gcc.gnu.org>

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

Added:
    branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/intrinsic_3.f90
      - copied unchanged from r147279,
trunk/gcc/testsuite/gfortran.dg/intrinsic_3.f90
Modified:
    branches/gcc-4_4-branch/gcc/fortran/ChangeLog
    branches/gcc-4_4-branch/gcc/fortran/intrinsic.c
    branches/gcc-4_4-branch/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39876


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-09-11 22:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-23 21:00 [Bug fortran/39876] New: module procedure name that collides with the GNU intrinsic alexei dot matveev+gcc at gmail dot com
2009-04-23 21:19 ` [Bug fortran/39876] " kargl at gcc dot gnu dot org
2009-04-24  5:22 ` kargl at gcc dot gnu dot org
2009-04-24 12:32 ` dominiq at lps dot ens dot fr
2009-05-06 22:08 ` janus at gcc dot gnu dot org
2009-05-07 19:11 ` janus at gcc dot gnu dot org
2009-05-08  9:08 ` janus at gcc dot gnu dot org
2009-05-08  9:11 ` janus at gcc dot gnu dot org
2009-09-02  0:11 ` pablomme at googlemail dot com
2009-09-11 22:11 ` kargl at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).