public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/42048]  New: [F03] Erroneous syntax error message on TBP call
@ 2009-11-15 10:39 janus at gcc dot gnu dot org
  2009-11-15 10:43 ` [Bug fortran/42048] " janus at gcc dot gnu dot org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-11-15 10:39 UTC (permalink / raw)
  To: gcc-bugs

Reported by Damian Rouson:


module grid_module
 implicit none
 type grid
 contains
   procedure :: new_grid
 end type
contains
 subroutine new_grid(this)
   class(grid) :: this
 end subroutine
end module

module field_module
 use grid_module
 implicit none

 type field
   type(grid) :: mesh
 end type

contains

 type(field) function new_field()
  call new_field%mesh%new_grid()
 end function

 ! This compiles when uncommented:
 !function new_field() result(new)
 !  type(field) :: new
 !  call new%mesh%new_grid()
 !end function

end module


This is rejected with:

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


-- 
           Summary: [F03] Erroneous syntax error message on TBP call
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          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=42048


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

* [Bug fortran/42048] [F03] Erroneous syntax error message on TBP call
  2009-11-15 10:39 [Bug fortran/42048] New: [F03] Erroneous syntax error message on TBP call janus at gcc dot gnu dot org
@ 2009-11-15 10:43 ` janus at gcc dot gnu dot org
  2009-11-15 14:33 ` janus at gcc dot gnu dot org
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-11-15 10:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from janus at gcc dot gnu dot org  2009-11-15 10:43 -------
The following patch makes the test case compile:

Index: gcc/fortran/match.c
===================================================================
--- gcc/fortran/match.c (revision 154106)
+++ gcc/fortran/match.c (working copy)
@@ -2975,7 +2975,7 @@ gfc_match_call (void)

   /* If this is a variable of derived-type, it probably starts a type-bound
      procedure call.  */
-  if (sym->attr.flavor != FL_PROCEDURE
+  if ((sym->attr.flavor != FL_PROCEDURE || sym == gfc_current_ns->proc_name)
       && (sym->ts.type == BT_DERIVED || sym->ts.type == BT_CLASS))
     return match_typebound_call (st);


-- 


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


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

* [Bug fortran/42048] [F03] Erroneous syntax error message on TBP call
  2009-11-15 10:39 [Bug fortran/42048] New: [F03] Erroneous syntax error message on TBP call janus at gcc dot gnu dot org
  2009-11-15 10:43 ` [Bug fortran/42048] " janus at gcc dot gnu dot org
@ 2009-11-15 14:33 ` janus at gcc dot gnu dot org
  2009-11-15 14:54 ` janus at gcc dot gnu dot org
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-11-15 14:33 UTC (permalink / raw)
  To: gcc-bugs



-- 

janus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |janus at gcc dot gnu dot org
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-11-15 14:32:58
               date|                            |


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


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

* [Bug fortran/42048] [F03] Erroneous syntax error message on TBP call
  2009-11-15 10:39 [Bug fortran/42048] New: [F03] Erroneous syntax error message on TBP call janus at gcc dot gnu dot org
  2009-11-15 10:43 ` [Bug fortran/42048] " janus at gcc dot gnu dot org
  2009-11-15 14:33 ` janus at gcc dot gnu dot org
@ 2009-11-15 14:54 ` janus at gcc dot gnu dot org
  2009-11-15 14:55 ` janus at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-11-15 14:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from janus at gcc dot gnu dot org  2009-11-15 14:54 -------
Subject: Bug 42048

Author: janus
Date: Sun Nov 15 14:54:05 2009
New Revision: 154190

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154190
Log:
2009-11-15  Janus Weil  <janus@gcc.gnu.org>

        PR fortran/42048
        * match.c (gfc_match_call): If we're inside a function with derived
        type return value, allow calling a TBP of the result variable.


2009-11-15  Janus Weil  <janus@gcc.gnu.org>

        PR fortran/42048
        * gfortran.dg/typebound_call_11.f03: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/typebound_call_11.f03
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/match.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug fortran/42048] [F03] Erroneous syntax error message on TBP call
  2009-11-15 10:39 [Bug fortran/42048] New: [F03] Erroneous syntax error message on TBP call janus at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2009-11-15 14:54 ` janus at gcc dot gnu dot org
@ 2009-11-15 14:55 ` janus at gcc dot gnu dot org
  2009-11-15 14:59 ` burnus at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-11-15 14:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from janus at gcc dot gnu dot org  2009-11-15 14:55 -------
Fixed with r154190. Closing.


-- 

janus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


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

* [Bug fortran/42048] [F03] Erroneous syntax error message on TBP call
  2009-11-15 10:39 [Bug fortran/42048] New: [F03] Erroneous syntax error message on TBP call janus at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2009-11-15 14:55 ` janus at gcc dot gnu dot org
@ 2009-11-15 14:59 ` burnus at gcc dot gnu dot org
  2009-11-15 15:06 ` janus at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-11-15 14:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from burnus at gcc dot gnu dot org  2009-11-15 14:59 -------
> -  if (sym->attr.flavor != FL_PROCEDURE
> +  if ((sym->attr.flavor != FL_PROCEDURE || sym == gfc_current_ns->proc_name)

Wouldn't it be more obvious to check for attr.result or something like that?
>From the testcase I understand how it works, but when I first looked at "sym ==
gfc_current_ns->proc_name" I was completely puzzled.

Besides, it probably fails for strange constructions such as

 type(field) function new_field()
  call g()
 contains
  subroutine g()
    call new_field%mesh%new_grid()
  end subroutine g
 end function new_field


-- 


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


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

* [Bug fortran/42048] [F03] Erroneous syntax error message on TBP call
  2009-11-15 10:39 [Bug fortran/42048] New: [F03] Erroneous syntax error message on TBP call janus at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2009-11-15 14:59 ` burnus at gcc dot gnu dot org
@ 2009-11-15 15:06 ` janus at gcc dot gnu dot org
  2009-11-15 15:12 ` janus at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-11-15 15:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from janus at gcc dot gnu dot org  2009-11-15 15:05 -------
(In reply to comment #4)
> Besides, it probably fails for strange constructions such as

Ah, indeed. Sorry for comitting too early :(

Seems it was not quite obvious enough ...


-- 

janus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |


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


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

* [Bug fortran/42048] [F03] Erroneous syntax error message on TBP call
  2009-11-15 10:39 [Bug fortran/42048] New: [F03] Erroneous syntax error message on TBP call janus at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2009-11-15 15:06 ` janus at gcc dot gnu dot org
@ 2009-11-15 15:12 ` janus at gcc dot gnu dot org
  2009-11-15 15:24 ` janus at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-11-15 15:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from janus at gcc dot gnu dot org  2009-11-15 15:12 -------
(In reply to comment #4)
> Besides, it probably fails for strange constructions such as

Another thing that does not work is:

 type(field) function new_field()
  ! ...
 end function

 subroutine test
   call new_field()%mesh%new_grid()
 end subroutine

OTOH, is this even valid?


-- 


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


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

* [Bug fortran/42048] [F03] Erroneous syntax error message on TBP call
  2009-11-15 10:39 [Bug fortran/42048] New: [F03] Erroneous syntax error message on TBP call janus at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2009-11-15 15:12 ` janus at gcc dot gnu dot org
@ 2009-11-15 15:24 ` janus at gcc dot gnu dot org
  2009-11-15 15:32 ` janus at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-11-15 15:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from janus at gcc dot gnu dot org  2009-11-15 15:24 -------
(In reply to comment #6)
> OTOH, is this even valid?

At first glance, I don't see why it shouldn't be. Btw, this also fails with
type-bound functions:

   integer :: i
   i = new_field()%mesh%new_int()


-- 


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


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

* [Bug fortran/42048] [F03] Erroneous syntax error message on TBP call
  2009-11-15 10:39 [Bug fortran/42048] New: [F03] Erroneous syntax error message on TBP call janus at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2009-11-15 15:24 ` janus at gcc dot gnu dot org
@ 2009-11-15 15:32 ` janus at gcc dot gnu dot org
  2009-11-15 15:40 ` janus at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-11-15 15:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from janus at gcc dot gnu dot org  2009-11-15 15:32 -------
Uh, it seems we're opening a can of worms here. The following also fails:

   type(grid) :: g
   g = new_field()%mesh

Let's hope these beasts are all invalid ;)


-- 


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


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

* [Bug fortran/42048] [F03] Erroneous syntax error message on TBP call
  2009-11-15 10:39 [Bug fortran/42048] New: [F03] Erroneous syntax error message on TBP call janus at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2009-11-15 15:32 ` janus at gcc dot gnu dot org
@ 2009-11-15 15:40 ` janus at gcc dot gnu dot org
  2009-11-15 15:49 ` janus at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-11-15 15:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from janus at gcc dot gnu dot org  2009-11-15 15:40 -------
(In reply to comment #8)
> Let's hope these beasts are all invalid ;)

At least this one is rejected by ifort and NAG. ifort says:

error #6837: The leftmost part-ref in a data-ref can not be a function
reference.   
   g = new_field()%mesh     


-- 


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


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

* [Bug fortran/42048] [F03] Erroneous syntax error message on TBP call
  2009-11-15 10:39 [Bug fortran/42048] New: [F03] Erroneous syntax error message on TBP call janus at gcc dot gnu dot org
                   ` (9 preceding siblings ...)
  2009-11-15 15:40 ` janus at gcc dot gnu dot org
@ 2009-11-15 15:49 ` janus at gcc dot gnu dot org
  2009-11-15 16:00 ` janus at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-11-15 15:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from janus at gcc dot gnu dot org  2009-11-15 15:49 -------
(In reply to comment #9)
> error #6837: The leftmost part-ref in a data-ref can not be a function
> reference.   

This is C612 in the Fortran 2003 standard:

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.


This makes comments #6 to #8 invalid. However, a proper error message could be
added for these cases (similar to ifort's).


-- 


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


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

* [Bug fortran/42048] [F03] Erroneous syntax error message on TBP call
  2009-11-15 10:39 [Bug fortran/42048] New: [F03] Erroneous syntax error message on TBP call janus at gcc dot gnu dot org
                   ` (10 preceding siblings ...)
  2009-11-15 15:49 ` janus at gcc dot gnu dot org
@ 2009-11-15 16:00 ` janus at gcc dot gnu dot org
  2009-11-26 19:01 ` janus at gcc dot gnu dot org
  2009-11-26 21:05 ` janus at gcc dot gnu dot org
  13 siblings, 0 replies; 15+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-11-15 16:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from janus at gcc dot gnu dot org  2009-11-15 16:00 -------
(In reply to comment #4)
> Wouldn't it be more obvious to check for attr.result or something like that?

Tobias, I don't quite see how that would work. Simply checking for attr.result
is surely not enough. After all this construct is only allowed if we're inside
the new_field function ...


-- 

janus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu dot
                   |                            |org


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


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

* [Bug fortran/42048] [F03] Erroneous syntax error message on TBP call
  2009-11-15 10:39 [Bug fortran/42048] New: [F03] Erroneous syntax error message on TBP call janus at gcc dot gnu dot org
                   ` (11 preceding siblings ...)
  2009-11-15 16:00 ` janus at gcc dot gnu dot org
@ 2009-11-26 19:01 ` janus at gcc dot gnu dot org
  2009-11-26 21:05 ` janus at gcc dot gnu dot org
  13 siblings, 0 replies; 15+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-11-26 19:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from janus at gcc dot gnu dot org  2009-11-26 19:01 -------
Subject: Bug 42048

Author: janus
Date: Thu Nov 26 19:01:02 2009
New Revision: 154679

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154679
Log:
2009-11-26  Janus Weil  <janus@gcc.gnu.org>

        PR fortran/42048
        PR fortran/42167
        * gfortran.h (gfc_is_function_return_value): New prototype.
        * match.c (gfc_match_call): Use new function
        'gfc_is_function_return_value'.
        * primary.c (gfc_is_function_return_value): New function to check if a
        symbol is the return value of an encompassing function.
        (match_actual_arg,gfc_match_rvalue,match_variable): Use new function
        'gfc_is_function_return_value'.
        * resolve.c (resolve_common_blocks,resolve_actual_arglist): Ditto.

2009-11-26  Janus Weil  <janus@gcc.gnu.org>

        PR fortran/42048
        PR fortran/42167
        * gfortran.dg/select_type_10.f03: New test case.
        * gfortran.dg/typebound_call_11.f03: Extended test case.

Added:
    trunk/gcc/testsuite/gfortran.dg/select_type_10.f03
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/gfortran.h
    trunk/gcc/fortran/match.c
    trunk/gcc/fortran/primary.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/typebound_call_11.f03


-- 


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


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

* [Bug fortran/42048] [F03] Erroneous syntax error message on TBP call
  2009-11-15 10:39 [Bug fortran/42048] New: [F03] Erroneous syntax error message on TBP call janus at gcc dot gnu dot org
                   ` (12 preceding siblings ...)
  2009-11-26 19:01 ` janus at gcc dot gnu dot org
@ 2009-11-26 21:05 ` janus at gcc dot gnu dot org
  13 siblings, 0 replies; 15+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-11-26 21:05 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from janus at gcc dot gnu dot org  2009-11-26 21:05 -------
Comment #4 is fixed with r154679. For the issues in comment #6 to #10 I have
opened PR42188, so this one can be closed.


-- 

janus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED


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


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

end of thread, other threads:[~2009-11-26 21:05 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-15 10:39 [Bug fortran/42048] New: [F03] Erroneous syntax error message on TBP call janus at gcc dot gnu dot org
2009-11-15 10:43 ` [Bug fortran/42048] " janus at gcc dot gnu dot org
2009-11-15 14:33 ` janus at gcc dot gnu dot org
2009-11-15 14:54 ` janus at gcc dot gnu dot org
2009-11-15 14:55 ` janus at gcc dot gnu dot org
2009-11-15 14:59 ` burnus at gcc dot gnu dot org
2009-11-15 15:06 ` janus at gcc dot gnu dot org
2009-11-15 15:12 ` janus at gcc dot gnu dot org
2009-11-15 15:24 ` janus at gcc dot gnu dot org
2009-11-15 15:32 ` janus at gcc dot gnu dot org
2009-11-15 15:40 ` janus at gcc dot gnu dot org
2009-11-15 15:49 ` janus at gcc dot gnu dot org
2009-11-15 16:00 ` janus at gcc dot gnu dot org
2009-11-26 19:01 ` janus at gcc dot gnu dot org
2009-11-26 21:05 ` janus at gcc dot gnu dot org

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