Bug 39695 - [F03] ProcPtr function results: wrong name in error message
Summary: [F03] ProcPtr function results: wrong name in error message
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks: 20585
  Show dependency treegraph
 
Reported: 2009-04-09 11:47 UTC by janus
Modified: 2013-12-09 14:33 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-12-17 21:05:39


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description janus 2009-04-09 11:47:18 UTC
For procedure pointer results without an explicit RESULT statement, error messages may contain the wrong name (since a hidden result variable named 'ppr@' is added).

Examples:

function f()
  pointer :: f
  interface
    integer function f(x) bind(c)   ! "may not be a C interoperable kind"
      integer :: x
    end function
  end interface
end function

function g()
  interface
    subroutine g()
    end subroutine g
  end interface
  pointer g
  real g   ! "cannot have a type"
end function


On a related note: In the following example the name is right, but the error message appears twice.

function h()
  interface
    integer function h(x)   ! "is missing the pointer attribute" (twice!)
      integer :: x
    end function
  end interface
end function
Comment 1 janus 2009-06-26 12:18:30 UTC
Another test case for this can be found in PR40541:

program test
  procedure(real), pointer :: p
  p => f()  ! << Invalid f() returns a LOGICAL(1) function, but p is a REAL one
contains
 function f()
   pointer :: f
   interface
     logical(1) function f()
     end function
   end interface
   f = .true._1
 end function f
end program test
Comment 2 Dominique d'Humieres 2013-06-25 17:59:07 UTC
As for 4.8.1 and trunk (r200371), only the second test in comment #0 gives the 'ppr@' name:

  real g   ! "cannot have a type"
        1
Error: Symbol 'ppr@' at (1) cannot have a type

The first test does not give any error and the third one gives (once)

    integer function h(x)   ! "is missing the pointer attribute" (twice!)
    1
Error: Procedure pointer result 'h' at (1) is missing the pointer attribute

The error for the test in comment #1 is

  p => f()  ! << Invalid f() returns a LOGICAL(1) function, but p is a REAL one
       1
Error: Interface mismatch in procedure pointer assignment at (1): Type/rank mismatch in function result

for 4.8.1 and

  p => f()  ! << Invalid f() returns a LOGICAL(1) function, but p is a REAL one
       1
Error: Interface mismatch in procedure pointer assignment at (1): Type mismatch in function result (REAL(4)/LOGICAL(1))

for the trunk.
Comment 3 janus 2013-12-09 14:23:35 UTC
Another example: proc_ptr_result_4.f90 in the testsuite yields the following error since 4.9 (see also PR59428):

    procedure(sin), pointer :: f
                                1
Error: Procedure pointer 'ppr@' at (1) shall not be elemental



  function f()
    intrinsic :: sin
    procedure(sin), pointer :: f
    f => sin
  end function f
Comment 4 janus 2013-12-09 14:33:09 UTC
As noted by Dominique in comment 2:

Comment 1 is fixed since 4.8, and out of the three cases in comment 0 only the second one persists (together with comment 3).