public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/45516] New: [F08] allocatable compontents of recursive type
@ 2010-09-03 9:57 janus at gcc dot gnu dot org
2010-09-03 9:59 ` [Bug fortran/45516] " janus at gcc dot gnu dot org
2010-09-03 12:12 ` burnus at gcc dot gnu dot org
0 siblings, 2 replies; 3+ messages in thread
From: janus at gcc dot gnu dot org @ 2010-09-03 9:57 UTC (permalink / raw)
To: gcc-bugs
John Reid, The new features of Fortran 2008, chapter 5.3:
A recursive type is permitted to be based on allocatable components. Here is a
simple example of a type that holds a stack:
type entry
real :: value
integer :: index
type(entry), allocatable :: next
end type entry
[...]
For this gfortran currently gives:
type(entry), allocatable :: next
1
Error: Component at (1) must have the POINTER attribute
--
Summary: [F08] allocatable compontents of recursive type
Product: gcc
Version: 4.6.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
OtherBugsDependingO 39627
nThis:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45516
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug fortran/45516] [F08] allocatable compontents of recursive type
2010-09-03 9:57 [Bug fortran/45516] New: [F08] allocatable compontents of recursive type janus at gcc dot gnu dot org
@ 2010-09-03 9:59 ` janus at gcc dot gnu dot org
2010-09-03 12:12 ` burnus at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: janus at gcc dot gnu dot org @ 2010-09-03 9:59 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from janus at gcc dot gnu dot org 2010-09-03 09:59 -------
Here is a patch to accept the type declaration in comment #0:
Index: decl.c
===================================================================
--- decl.c (revision 163798)
+++ decl.c (working copy)
@@ -1494,11 +1494,11 @@ build_struct (const char *name, gfc_charlen *cl, g
gfc_component *c;
gfc_try t = SUCCESS;
- /* F03:C438/C439. If the current symbol is of the same derived type that
we're
- constructing, it must have the pointer attribute. */
+ /* F08:C440. If the current symbol is of the same derived type that we're
+ constructing, it must be POINTER or ALLOCATABLE. */
if ((current_ts.type == BT_DERIVED || current_ts.type == BT_CLASS)
&& current_ts.u.derived == gfc_current_block ()
- && current_attr.pointer == 0)
+ && !current_attr.pointer && !current_attr.allocatable)
{
gfc_error ("Component at %C must have the POINTER attribute");
return FAILURE;
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45516
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug fortran/45516] [F08] allocatable compontents of recursive type
2010-09-03 9:57 [Bug fortran/45516] New: [F08] allocatable compontents of recursive type janus at gcc dot gnu dot org
2010-09-03 9:59 ` [Bug fortran/45516] " janus at gcc dot gnu dot org
@ 2010-09-03 12:12 ` burnus at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-09-03 12:12 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from burnus at gcc dot gnu dot org 2010-09-03 12:12 -------
(In reply to comment #1)
> Here is a patch to accept the type declaration in comment #0:
Well, you at least need to use gfc_notify_std(GFC_STD_F2008, ... And one should
make sure that the allocation/clean up works as expected.
* * *
As follow up to the initial implementation, one should implement at some point
the following, which does not do a deep copy but simply appends the old data.
(Example from the mentioned article.)
type entry
real :: value
integer :: index
type(entry), allocatable :: next
end type entry
type (entry), allocatable :: top
top = entry ( new_value, new_index, top )
(The last line assume reallocate on assignment; I think it already works for
derived types with structure constructor; I know that it does not yet work for
intrinsic types - not does it work on other assignment than structure
constructors.)
The classical way to append a new item is the following, which should avoid a
deep copy (check!):
type (entry), allocatable :: top, temp
temp = entry ( new_value, new_index, temp )
call move_alloc(top,temp%next)
call move_alloc(temp,top)
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |domob at gcc dot gnu dot
| |org, burnus at gcc dot gnu
| |dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45516
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-09-03 12:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-03 9:57 [Bug fortran/45516] New: [F08] allocatable compontents of recursive type janus at gcc dot gnu dot org
2010-09-03 9:59 ` [Bug fortran/45516] " janus at gcc dot gnu dot org
2010-09-03 12:12 ` burnus 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).