public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/41581]  New: [OOP] Allocation of a CLASS with SOURCE=<class> does not work
@ 2009-10-05 12:52 burnus at gcc dot gnu dot org
  2009-10-05 12:53 ` [Bug fortran/41581] " burnus at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-10-05 12:52 UTC (permalink / raw)
  To: gcc-bugs

Currently, the size needed for allocation is not taken into account with CLASS. 

The example below should print
  42 -4.0
but prints
  512   0.0000000

Expected:

a) The warning
"Warning: Dynamic size allocation at (1) not supported yet, using size of
declared type"
is turned into an error as interim measure
(cf. ifort: "Feature not yet implemented: SOURCE=polymorphic_expression")

b) The dynamic-size implementation is implemented.


Example:

type t
end type t
type,extends(t) :: t2
  integer :: i = 54
  real :: r = 384.02
end type t2

class(t), allocatable :: m1, m2
allocate(t2 :: m2)
select type(m2)
 type is (t2)
   m2%i = 42
   m2%r = -4.0
end select
allocate(m1, source=m2)
select type(m1)
 type is (t2)
 print *, m1%i, m1%r ! shall print "42  -4.0"
end select
end


-- 
           Summary: [OOP] Allocation of a CLASS with SOURCE=<class> does not
                    work
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


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


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

* [Bug fortran/41581] [OOP] Allocation of a CLASS with SOURCE=<class> does not work
  2009-10-05 12:52 [Bug fortran/41581] New: [OOP] Allocation of a CLASS with SOURCE=<class> does not work burnus at gcc dot gnu dot org
@ 2009-10-05 12:53 ` burnus at gcc dot gnu dot org
  2009-10-09 20:46 ` burnus at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-10-05 12:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from burnus at gcc dot gnu dot org  2009-10-05 12:53 -------
See also PR 41582.


-- 

burnus at gcc dot gnu dot org changed:

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


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


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

* [Bug fortran/41581] [OOP] Allocation of a CLASS with SOURCE=<class> does not work
  2009-10-05 12:52 [Bug fortran/41581] New: [OOP] Allocation of a CLASS with SOURCE=<class> does not work burnus at gcc dot gnu dot org
  2009-10-05 12:53 ` [Bug fortran/41581] " burnus at gcc dot gnu dot org
@ 2009-10-09 20:46 ` burnus at gcc dot gnu dot org
  2009-10-11 19:07 ` janus at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2009-10-09 20:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from burnus at gcc dot gnu dot org  2009-10-09 20:46 -------
To prevent wrong-code, SOURCE=<class> is now rejected (cf. PR 41582).

For the run-time version: One might also need to check whether SOURCE is
allocated - at least with some checking option.


-- 


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


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

* [Bug fortran/41581] [OOP] Allocation of a CLASS with SOURCE=<class> does not work
  2009-10-05 12:52 [Bug fortran/41581] New: [OOP] Allocation of a CLASS with SOURCE=<class> does not work burnus at gcc dot gnu dot org
  2009-10-05 12:53 ` [Bug fortran/41581] " burnus at gcc dot gnu dot org
  2009-10-09 20:46 ` burnus at gcc dot gnu dot org
@ 2009-10-11 19:07 ` janus at gcc dot gnu dot org
  2009-10-13 16:13 ` janus at gcc dot gnu dot org
  2009-10-13 16:14 ` janus at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-10-11 19:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from janus at gcc dot gnu dot org  2009-10-11 19:07 -------
Mine.

The plan: Add a '$size' field to the class container, which will be used at
runtime to determine the size of the memory block to be allocated.


-- 

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-10-11 19:07:13
               date|                            |


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


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

* [Bug fortran/41581] [OOP] Allocation of a CLASS with SOURCE=<class> does not work
  2009-10-05 12:52 [Bug fortran/41581] New: [OOP] Allocation of a CLASS with SOURCE=<class> does not work burnus at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2009-10-11 19:07 ` janus at gcc dot gnu dot org
@ 2009-10-13 16:13 ` janus at gcc dot gnu dot org
  2009-10-13 16:14 ` janus at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-10-13 16:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from janus at gcc dot gnu dot org  2009-10-13 16:12 -------
Subject: Bug 41581

Author: janus
Date: Tue Oct 13 16:12:24 2009
New Revision: 152715

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

        PR fortran/41581
        * decl.c (encapsulate_class_symbol): Add new component '$size'.
        * resolve.c (resolve_allocate_expr): Move CLASS handling to
        gfc_trans_allocate.
        (resolve_class_assign): Replaced by gfc_trans_class_assign.
        (resolve_code): Remove calls to resolve_class_assign.
        * trans.c (gfc_trans_code): Use new function gfc_trans_class_assign.
        * trans-expr.c (get_proc_ptr_comp): Fix a memory leak.
        (gfc_conv_procedure_call): For CLASS dummies, set the
        $size component.
        (gfc_trans_class_assign): New function, replacing resolve_class_assign.
        * trans-stmt.h (gfc_trans_class_assign): New prototype.
        * trans-stmt.c (gfc_trans_allocate): Use correct size when allocating
        CLASS variables. Do proper initialization. Move some code here from
        resolve_allocate_expr.


2009-10-13  Janus Weil  <janus@gcc.gnu.org>

        PR fortran/41581
        * gfortran.dg/class_allocate_2.f03: Modified.
        * gfortran.dg/class_allocate_3.f03: New test case.

Added:
    trunk/gcc/testsuite/gfortran.dg/class_allocate_3.f03
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/decl.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/fortran/trans-expr.c
    trunk/gcc/fortran/trans-stmt.c
    trunk/gcc/fortran/trans-stmt.h
    trunk/gcc/fortran/trans.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/class_allocate_2.f03


-- 


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


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

* [Bug fortran/41581] [OOP] Allocation of a CLASS with SOURCE=<class> does not work
  2009-10-05 12:52 [Bug fortran/41581] New: [OOP] Allocation of a CLASS with SOURCE=<class> does not work burnus at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2009-10-13 16:13 ` janus at gcc dot gnu dot org
@ 2009-10-13 16:14 ` janus at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: janus at gcc dot gnu dot org @ 2009-10-13 16:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from janus at gcc dot gnu dot org  2009-10-13 16:14 -------
Fixed with r152715. 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=41581


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

end of thread, other threads:[~2009-10-13 16:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-05 12:52 [Bug fortran/41581] New: [OOP] Allocation of a CLASS with SOURCE=<class> does not work burnus at gcc dot gnu dot org
2009-10-05 12:53 ` [Bug fortran/41581] " burnus at gcc dot gnu dot org
2009-10-09 20:46 ` burnus at gcc dot gnu dot org
2009-10-11 19:07 ` janus at gcc dot gnu dot org
2009-10-13 16:13 ` janus at gcc dot gnu dot org
2009-10-13 16:14 ` 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).