Follow-up to PR42048. Consider the following code:

module grid_module
 implicit none
 type grid
 contains
   procedure :: new_grid
   procedure :: new_int
 end type
contains
 subroutine new_grid(this)
   class(grid) :: this
 end subroutine
 integer function new_int(this)
   class(grid) :: this
   new_int = 42
 end function
end module

module field_module
 use grid_module
 implicit none

 type field
   type(grid) :: mesh
 end type

contains

 type(field) function new_field()
 end function

 subroutine test
   integer :: i
   type(grid) :: g
   g = new_field()%mesh
   call new_field()%mesh%new_grid()
   i = new_field()%mesh%new_int()
 end subroutine

end module


which is currently rejected with

test.f90:41.3:

   g = new_field()%mesh
   1
Error: Unclassifiable statement at (1)
test.f90:42.19:

   call new_field()%mesh%new_grid()
                   1
Error: Syntax error in CALL statement at (1)
test.f90:43.3:

   i = new_field()%mesh%new_int()
   1
Error: Unclassifiable statement at (1)


Rejecting it is fine, I think, but the error messages should be improved. ifort
says

error #6837: The leftmost part-ref in a data-ref can not be a function
reference.   


The relevant parts from the standard are:

R612 data-ref is part-ref [ % part-ref ] ...
R613 part-ref is part-name [ ( section-subscript-list ) ]

C612 (R612) The leftmost part-name shall be the name of a data object.

2.4.3.1 Data object
A data object (often abbreviated to object) is a constant (4.1.2), a variable
(6), or a subobject of a constant.


-- 
           Summary: F03:C612. The leftmost part-name shall be the name of a
                    data object.
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: janus at gcc dot gnu dot org


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

Reply via email to