User account creation filtered due to spam.

Bug 42188 - [OOP] F03:C612. The leftmost part-name shall be the name of a data object.
Summary: [OOP] F03:C612. The leftmost part-name shall be the name of a data object.
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: ---
Assignee: janus
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2009-11-26 21:01 UTC by janus
Modified: 2016-12-02 15:18 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-09-10 21:38:08


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description janus 2009-11-26 21:01:34 UTC
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.