public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, Fortran, OOP] PR 42188: F03:C612. The leftmost part-name shall be the name of a data object
@ 2016-12-02 15:24 Janus Weil
  2016-12-03 17:01 ` Steve Kargl
  0 siblings, 1 reply; 3+ messages in thread
From: Janus Weil @ 2016-12-02 15:24 UTC (permalink / raw)
  To: gfortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 509 bytes --]

Hi all,

another simple fix for a rather old PR. This one adds a new check, in
order to provide better error messages than just "Unclassifiable
statement".

Regtests cleanly on x86_64-linux-gnu. Ok for trunk?

Cheers,
Janus



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

    PR fortran/42188
    * gfortran.dg/derived_result_2.f90.f90: New test case.

[-- Attachment #2: pr42188.diff --]
[-- Type: text/plain, Size: 568 bytes --]

Index: gcc/fortran/primary.c
===================================================================
--- gcc/fortran/primary.c	(revision 243176)
+++ gcc/fortran/primary.c	(working copy)
@@ -3298,6 +3298,15 @@ gfc_match_rvalue (gfc_expr **result)
       if (sym->result == NULL)
 	sym->result = sym;
 
+      gfc_gobble_whitespace ();
+      /* F08:C612.  */
+      if (gfc_peek_ascii_char() == '%')
+	{
+	  gfc_error ("The leftmost part-ref in a data-ref can not be a "
+		     "function reference at %C");
+	  m = MATCH_ERROR;
+	}
+
       m = MATCH_YES;
       break;
 

[-- Attachment #3: derived_result_2.f90 --]
[-- Type: text/x-fortran, Size: 921 bytes --]

! { dg-do compile }
!
! PR 42188: [OOP] F03:C612. The leftmost part-name shall be the name of a data object
!
! Contributed by Janus Weil <janus@gcc.gnu.org>

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              ! { dg-error "can not be a function reference" }
   call new_field()%mesh%new_grid()  ! { dg-error "Syntax error" }
   i = new_field() % mesh%new_int()  ! { dg-error "can not be a function reference" }
 end subroutine

end module

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

* Re: [Patch, Fortran, OOP] PR 42188: F03:C612. The leftmost part-name shall be the name of a data object
  2016-12-02 15:24 [Patch, Fortran, OOP] PR 42188: F03:C612. The leftmost part-name shall be the name of a data object Janus Weil
@ 2016-12-03 17:01 ` Steve Kargl
  2016-12-03 18:39   ` Janus Weil
  0 siblings, 1 reply; 3+ messages in thread
From: Steve Kargl @ 2016-12-03 17:01 UTC (permalink / raw)
  To: Janus Weil; +Cc: gfortran, gcc-patches

On Fri, Dec 02, 2016 at 04:24:20PM +0100, Janus Weil wrote:
> 
> another simple fix for a rather old PR. This one adds a new check, in
> order to provide better error messages than just "Unclassifiable
> statement".
> 
> Regtests cleanly on x86_64-linux-gnu. Ok for trunk?
> 

OK.

-- 
Steve

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

* Re: [Patch, Fortran, OOP] PR 42188: F03:C612. The leftmost part-name shall be the name of a data object
  2016-12-03 17:01 ` Steve Kargl
@ 2016-12-03 18:39   ` Janus Weil
  0 siblings, 0 replies; 3+ messages in thread
From: Janus Weil @ 2016-12-03 18:39 UTC (permalink / raw)
  To: Steve Kargl; +Cc: gfortran, gcc-patches

2016-12-03 18:01 GMT+01:00 Steve Kargl <sgk@troutmask.apl.washington.edu>:
> On Fri, Dec 02, 2016 at 04:24:20PM +0100, Janus Weil wrote:
>>
>> another simple fix for a rather old PR. This one adds a new check, in
>> order to provide better error messages than just "Unclassifiable
>> statement".
>>
>> Regtests cleanly on x86_64-linux-gnu. Ok for trunk?
>>
>
> OK.

Thanks, Steve. Committed to trunk as r243223.

Cheers,
Janus

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

end of thread, other threads:[~2016-12-03 18:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-02 15:24 [Patch, Fortran, OOP] PR 42188: F03:C612. The leftmost part-name shall be the name of a data object Janus Weil
2016-12-03 17:01 ` Steve Kargl
2016-12-03 18:39   ` Janus Weil

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).