public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/49562] New: [OOP] ICE at invalid code: assigning value to function of polymorphic object
@ 2011-06-28  8:26 boschmann at tp1 dot physik.uni-siegen.de
  2011-06-28  9:43 ` [Bug fortran/49562] [4.6/4.7 Regression] " janus at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: boschmann at tp1 dot physik.uni-siegen.de @ 2011-06-28  8:26 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: [OOP] ICE at invalid code: assigning value to function
                    of polymorphic object
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: boschmann@tp1.physik.uni-siegen.de
                CC: janus@gcc.gnu.org


The code:

module ice
  type::ice_type
   contains
     procedure::ice_func
  end type ice_type
contains
  pure integer function ice_func(this)
    class(ice_type),intent(in)::this
    ice_func=1
  end function ice_func
  subroutine ice_sub(a)
    class(ice_type)::a
    a%ice_func()=1           ! This is the invalid line
  end subroutine ice_sub
end module ice

The marked line is obviously not allowed. When I replace class(ice_type)::a by
type(ice_type)::a then get a proper error message, but the class statement
results in an internal compiler error.

My gfortran version is 4.7.0 20110620


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

* [Bug fortran/49562] [4.6/4.7 Regression] [OOP] ICE at invalid code: assigning value to function of polymorphic object
  2011-06-28  8:26 [Bug fortran/49562] New: [OOP] ICE at invalid code: assigning value to function of polymorphic object boschmann at tp1 dot physik.uni-siegen.de
@ 2011-06-28  9:43 ` janus at gcc dot gnu.org
  2011-06-28 11:05 ` janus at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: janus at gcc dot gnu.org @ 2011-06-28  9:43 UTC (permalink / raw)
  To: gcc-bugs

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

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.06.28 09:43:24
            Summary|[OOP] ICE at invalid code:  |[4.6/4.7 Regression] [OOP]
                   |assigning value to function |ICE at invalid code:
                   |of polymorphic object       |assigning value to function
                   |                            |of polymorphic object
     Ever Confirmed|0                           |1

--- Comment #1 from janus at gcc dot gnu.org 2011-06-28 09:43:24 UTC ---
In fact this is a regression: With 4.5 one gets the correct error message.


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

* [Bug fortran/49562] [4.6/4.7 Regression] [OOP] ICE at invalid code: assigning value to function of polymorphic object
  2011-06-28  8:26 [Bug fortran/49562] New: [OOP] ICE at invalid code: assigning value to function of polymorphic object boschmann at tp1 dot physik.uni-siegen.de
  2011-06-28  9:43 ` [Bug fortran/49562] [4.6/4.7 Regression] " janus at gcc dot gnu.org
@ 2011-06-28 11:05 ` janus at gcc dot gnu.org
  2011-06-28 11:06 ` janus at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: janus at gcc dot gnu.org @ 2011-06-28 11:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from janus at gcc dot gnu.org 2011-06-28 11:05:08 UTC ---
The fix is pretty trivial:


Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c    (revision 175562)
+++ gcc/fortran/expr.c    (working copy)
@@ -4395,7 +4395,7 @@ gfc_check_vardef_context (gfc_expr* e, bool pointe
     }

   if (!pointer && e->expr_type == EXPR_FUNCTION
-      && sym->result->attr.pointer)
+      && sym->result && sym->result->attr.pointer)
     {
       if (!(gfc_option.allow_std & GFC_STD_F2008))
     {


With this one gets:

    a%ice_func()=1           ! This is the invalid line
    1
Error: Non-variable expression in variable definition context (assignment) at
(1)


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

* [Bug fortran/49562] [4.6/4.7 Regression] [OOP] ICE at invalid code: assigning value to function of polymorphic object
  2011-06-28  8:26 [Bug fortran/49562] New: [OOP] ICE at invalid code: assigning value to function of polymorphic object boschmann at tp1 dot physik.uni-siegen.de
  2011-06-28  9:43 ` [Bug fortran/49562] [4.6/4.7 Regression] " janus at gcc dot gnu.org
  2011-06-28 11:05 ` janus at gcc dot gnu.org
@ 2011-06-28 11:06 ` janus at gcc dot gnu.org
  2011-06-28 11:19 ` janus at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: janus at gcc dot gnu.org @ 2011-06-28 11:06 UTC (permalink / raw)
  To: gcc-bugs

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

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |janus at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #3 from janus at gcc dot gnu.org 2011-06-28 11:06:29 UTC ---
Also: Mine. [Will commit as obvious after regtesting.]


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

* [Bug fortran/49562] [4.6/4.7 Regression] [OOP] ICE at invalid code: assigning value to function of polymorphic object
  2011-06-28  8:26 [Bug fortran/49562] New: [OOP] ICE at invalid code: assigning value to function of polymorphic object boschmann at tp1 dot physik.uni-siegen.de
                   ` (2 preceding siblings ...)
  2011-06-28 11:06 ` janus at gcc dot gnu.org
@ 2011-06-28 11:19 ` janus at gcc dot gnu.org
  2011-06-28 12:53 ` [Bug fortran/49562] [4.6/4.7 Regression] [OOP] assigning value to type-bound function janus at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: janus at gcc dot gnu.org @ 2011-06-28 11:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from janus at gcc dot gnu.org 2011-06-28 11:18:47 UTC ---
For the record: The regression is probably due to r165749:

http://gcc.gnu.org/viewcvs?view=revision&revision=165749


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

* [Bug fortran/49562] [4.6/4.7 Regression] [OOP] assigning value to type-bound function
  2011-06-28  8:26 [Bug fortran/49562] New: [OOP] ICE at invalid code: assigning value to function of polymorphic object boschmann at tp1 dot physik.uni-siegen.de
                   ` (3 preceding siblings ...)
  2011-06-28 11:19 ` janus at gcc dot gnu.org
@ 2011-06-28 12:53 ` janus at gcc dot gnu.org
  2011-06-28 12:59 ` janus at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: janus at gcc dot gnu.org @ 2011-06-28 12:53 UTC (permalink / raw)
  To: gcc-bugs

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

janus at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|ice-on-invalid-code         |ice-on-valid-code
            Summary|[4.6/4.7 Regression] [OOP]  |[4.6/4.7 Regression] [OOP]
                   |ICE-on-invalid: assigning   |assigning value to
                   |value to type-bound         |type-bound function
                   |function                    |

--- Comment #5 from janus at gcc dot gnu.org 2011-06-28 12:52:58 UTC ---
Note: You can get the same ICE on *valid* code, if you give the return value of
'ice_func' the POINTER attribute (allowed by F08):


module ice
  type::ice_type
   contains
     procedure::ice_func
  end type ice_type
contains
  pure function ice_func(this)
    integer, pointer :: ice_func
    class(ice_type),intent(in)::this
    ice_func=1
  end function ice_func
  subroutine ice_sub(a)
    class(ice_type)::a
    a%ice_func()=1           ! This is valid now
  end subroutine ice_sub
end module ice


Unfortunately this test case is rejected with the patch in comment #2.


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

* [Bug fortran/49562] [4.6/4.7 Regression] [OOP] assigning value to type-bound function
  2011-06-28  8:26 [Bug fortran/49562] New: [OOP] ICE at invalid code: assigning value to function of polymorphic object boschmann at tp1 dot physik.uni-siegen.de
                   ` (4 preceding siblings ...)
  2011-06-28 12:53 ` [Bug fortran/49562] [4.6/4.7 Regression] [OOP] assigning value to type-bound function janus at gcc dot gnu.org
@ 2011-06-28 12:59 ` janus at gcc dot gnu.org
  2011-07-02 11:09 ` janus at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: janus at gcc dot gnu.org @ 2011-06-28 12:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from janus at gcc dot gnu.org 2011-06-28 12:59:20 UTC ---
(In reply to comment #5)
> Unfortunately this test case is rejected with the patch in comment #2.

However, it is accepted with this improved patch:


Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c    (revision 175580)
+++ gcc/fortran/expr.c    (working copy)
@@ -4394,8 +4394,8 @@ gfc_check_vardef_context (gfc_expr* e, bool pointe
       sym = e->value.function.esym ? e->value.function.esym :
e->symtree->n.sym;
     }

-  if (!pointer && e->expr_type == EXPR_FUNCTION
-      && sym->result->attr.pointer)
+  attr = gfc_expr_attr (e);
+  if (!pointer && e->expr_type == EXPR_FUNCTION && attr.pointer)
     {
       if (!(gfc_option.allow_std & GFC_STD_F2008))
     {
@@ -4432,7 +4432,6 @@ gfc_check_vardef_context (gfc_expr* e, bool pointe

   /* Find out whether the expr is a pointer; this also means following
      component references to the last one.  */
-  attr = gfc_expr_attr (e);
   is_pointer = (attr.pointer || attr.proc_pointer);
   if (pointer && !is_pointer)
     {


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

* [Bug fortran/49562] [4.6/4.7 Regression] [OOP] assigning value to type-bound function
  2011-06-28  8:26 [Bug fortran/49562] New: [OOP] ICE at invalid code: assigning value to function of polymorphic object boschmann at tp1 dot physik.uni-siegen.de
                   ` (5 preceding siblings ...)
  2011-06-28 12:59 ` janus at gcc dot gnu.org
@ 2011-07-02 11:09 ` janus at gcc dot gnu.org
  2011-07-09 18:38 ` burnus at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: janus at gcc dot gnu.org @ 2011-07-02 11:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from janus at gcc dot gnu.org 2011-07-02 11:08:45 UTC ---
Author: janus
Date: Sat Jul  2 11:08:41 2011
New Revision: 175779

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175779
Log:
2011-07-02  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/49562
    * expr.c (gfc_check_vardef_context): Handle type-bound procedures.


2011-07-02  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/49562
    * gfortran.dg/typebound_proc_23.f90: New.

Added:
    trunk/gcc/testsuite/gfortran.dg/typebound_proc_23.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/expr.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug fortran/49562] [4.6/4.7 Regression] [OOP] assigning value to type-bound function
  2011-06-28  8:26 [Bug fortran/49562] New: [OOP] ICE at invalid code: assigning value to function of polymorphic object boschmann at tp1 dot physik.uni-siegen.de
                   ` (6 preceding siblings ...)
  2011-07-02 11:09 ` janus at gcc dot gnu.org
@ 2011-07-09 18:38 ` burnus at gcc dot gnu.org
  2011-07-10  9:32 ` janus at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-07-09 18:38 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

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

--- Comment #8 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-07-09 18:37:31 UTC ---
Janus, what's the status of this PR?
I think only backporting is missing, is that correct?


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

* [Bug fortran/49562] [4.6/4.7 Regression] [OOP] assigning value to type-bound function
  2011-06-28  8:26 [Bug fortran/49562] New: [OOP] ICE at invalid code: assigning value to function of polymorphic object boschmann at tp1 dot physik.uni-siegen.de
                   ` (7 preceding siblings ...)
  2011-07-09 18:38 ` burnus at gcc dot gnu.org
@ 2011-07-10  9:32 ` janus at gcc dot gnu.org
  2011-07-10 11:50 ` janus at gcc dot gnu.org
  2011-07-10 11:53 ` janus at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: janus at gcc dot gnu.org @ 2011-07-10  9:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from janus at gcc dot gnu.org 2011-07-10 09:31:31 UTC ---
(In reply to comment #8)
> Janus, what's the status of this PR?
> I think only backporting is missing, is that correct?

Right. I'm just about to apply the backport ...


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

* [Bug fortran/49562] [4.6/4.7 Regression] [OOP] assigning value to type-bound function
  2011-06-28  8:26 [Bug fortran/49562] New: [OOP] ICE at invalid code: assigning value to function of polymorphic object boschmann at tp1 dot physik.uni-siegen.de
                   ` (8 preceding siblings ...)
  2011-07-10  9:32 ` janus at gcc dot gnu.org
@ 2011-07-10 11:50 ` janus at gcc dot gnu.org
  2011-07-10 11:53 ` janus at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: janus at gcc dot gnu.org @ 2011-07-10 11:50 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from janus at gcc dot gnu.org 2011-07-10 11:50:09 UTC ---
Author: janus
Date: Sun Jul 10 11:50:04 2011
New Revision: 176117

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=176117
Log:
2011-07-10  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/49562
    * expr.c (gfc_check_vardef_context): Handle type-bound procedures.


2011-07-10  Janus Weil  <janus@gcc.gnu.org>

    PR fortran/49562
    * gfortran.dg/typebound_proc_23.f90: New.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/gfortran.dg/typebound_proc_23.f90
Modified:
    branches/gcc-4_6-branch/gcc/fortran/ChangeLog
    branches/gcc-4_6-branch/gcc/fortran/expr.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog


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

* [Bug fortran/49562] [4.6/4.7 Regression] [OOP] assigning value to type-bound function
  2011-06-28  8:26 [Bug fortran/49562] New: [OOP] ICE at invalid code: assigning value to function of polymorphic object boschmann at tp1 dot physik.uni-siegen.de
                   ` (9 preceding siblings ...)
  2011-07-10 11:50 ` janus at gcc dot gnu.org
@ 2011-07-10 11:53 ` janus at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: janus at gcc dot gnu.org @ 2011-07-10 11:53 UTC (permalink / raw)
  To: gcc-bugs

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

janus at gcc dot gnu.org changed:

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

--- Comment #11 from janus at gcc dot gnu.org 2011-07-10 11:52:35 UTC ---
Fixed on trunk and 4.6. Closing.

Also: Thanks for reporting, Hans-Werner!


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

end of thread, other threads:[~2011-07-10 11:53 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-28  8:26 [Bug fortran/49562] New: [OOP] ICE at invalid code: assigning value to function of polymorphic object boschmann at tp1 dot physik.uni-siegen.de
2011-06-28  9:43 ` [Bug fortran/49562] [4.6/4.7 Regression] " janus at gcc dot gnu.org
2011-06-28 11:05 ` janus at gcc dot gnu.org
2011-06-28 11:06 ` janus at gcc dot gnu.org
2011-06-28 11:19 ` janus at gcc dot gnu.org
2011-06-28 12:53 ` [Bug fortran/49562] [4.6/4.7 Regression] [OOP] assigning value to type-bound function janus at gcc dot gnu.org
2011-06-28 12:59 ` janus at gcc dot gnu.org
2011-07-02 11:09 ` janus at gcc dot gnu.org
2011-07-09 18:38 ` burnus at gcc dot gnu.org
2011-07-10  9:32 ` janus at gcc dot gnu.org
2011-07-10 11:50 ` janus at gcc dot gnu.org
2011-07-10 11:53 ` janus at gcc dot gnu.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).