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.
Author: janus Date: Sat Dec 3 18:37:57 2016 New Revision: 243223 URL: https://gcc.gnu.org/viewcvs?rev=243223&root=gcc&view=rev Log: 2016-12-03 Janus Weil <janus@gcc.gnu.org> PR fortran/42188 * primary.c (gfc_match_rvalue): Add a new check that gives better error messages. 2016-12-03 Janus Weil <janus@gcc.gnu.org> PR fortran/42188 * gfortran.dg/derived_result_2.f90.f90: New test case. Added: trunk/gcc/testsuite/gfortran.dg/derived_result_2.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/primary.c trunk/gcc/testsuite/ChangeLog
Fixed on 7-trunk with r243223. Closing.