public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/33221] New: IMPORTing of TYPE declarations without components fails
@ 2007-08-28 17:57 burnus at gcc dot gnu dot org
2007-09-01 8:21 ` [Bug fortran/33221] Using type(...) " burnus at gcc dot gnu dot org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-08-28 17:57 UTC (permalink / raw)
To: gcc-bugs
The following is a valid Fortran 2003 program, but if "type t" has no
components, it cannot be imported:
Error: Derived type 't' at (1) is being used before it is defined
type t
! integer :: i
end type t
interface
subroutine fff(a)
import :: t
type(t) :: a
end subroutine fff
end interface
end
--
Summary: IMPORTing of TYPE declarations without components fails
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
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=33221
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/33221] Using type(...) of TYPE declarations without components fails
2007-08-28 17:57 [Bug fortran/33221] New: IMPORTing of TYPE declarations without components fails burnus at gcc dot gnu dot org
@ 2007-09-01 8:21 ` burnus at gcc dot gnu dot org
2007-09-18 7:32 ` [Bug fortran/33221] Cannot declare variables of TYPE without components fxcoudert at gcc dot gnu dot org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-09-01 8:21 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from burnus at gcc dot gnu dot org 2007-09-01 08:20 -------
It already fails for
TYPE t
END TYPE t
type(t) :: myt
end
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|IMPORTing of TYPE |Using type(...) of TYPE
|declarations without |declarations without
|components fails |components fails
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33221
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/33221] Cannot declare variables of TYPE without components
2007-08-28 17:57 [Bug fortran/33221] New: IMPORTing of TYPE declarations without components fails burnus at gcc dot gnu dot org
2007-09-01 8:21 ` [Bug fortran/33221] Using type(...) " burnus at gcc dot gnu dot org
@ 2007-09-18 7:32 ` fxcoudert at gcc dot gnu dot org
2007-09-18 8:26 ` fxcoudert at gcc dot gnu dot org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-09-18 7:32 UTC (permalink / raw)
To: gcc-bugs
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2007-09-18 07:32:37
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33221
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/33221] Cannot declare variables of TYPE without components
2007-08-28 17:57 [Bug fortran/33221] New: IMPORTing of TYPE declarations without components fails burnus at gcc dot gnu dot org
2007-09-01 8:21 ` [Bug fortran/33221] Using type(...) " burnus at gcc dot gnu dot org
2007-09-18 7:32 ` [Bug fortran/33221] Cannot declare variables of TYPE without components fxcoudert at gcc dot gnu dot org
@ 2007-09-18 8:26 ` fxcoudert at gcc dot gnu dot org
2007-09-18 11:32 ` fxcoudert at gcc dot gnu dot org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-09-18 8:26 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from fxcoudert at gcc dot gnu dot org 2007-09-18 08:26 -------
This is because, in gfc_use_derived (symbol.c), when checking whether a derived
type is in the current unit or a parent unit, we check (sym->components !=
NULL) and if it's true, we take it to mean that the derived type was in a
parent unit (while, in fact, it's simply NULL because there *is* no component).
We need either a better test for the derived type being in the current scoping
unit, or a way to indicate a derived type without components other than setting
components to NULL.
One thing that comes to mind is the following patch. It allows derived types
with zero components to be accepted, but I fear that it might make us accept
invalid code with empty derived types outside the current scoping unit.
Index: symbol.c
===================================================================
--- symbol.c (revision 128540)
+++ symbol.c (working copy)
@@ -1703,7 +1703,7 @@ gfc_use_derived (gfc_symbol *sym)
gfc_symtree *st;
int i;
- if (sym->components != NULL)
+ if (sym->components != NULL || sym->attr.zero_comp)
return sym; /* Already defined. */
if (sym->ns->parent == NULL)
Index: decl.c
===================================================================
--- decl.c (revision 128540)
+++ decl.c (working copy)
@@ -3414,7 +3414,8 @@ gfc_match_data_decl (void)
goto cleanup;
}
- if (current_ts.type == BT_DERIVED && current_ts.derived->components == NULL)
+ if (current_ts.type == BT_DERIVED && current_ts.derived->components == NULL
+ && !current_ts.derived->attr.zero_comp)
{
if (current_attr.pointer && gfc_current_state () == COMP_DERIVED)
Index: gfortran.h
===================================================================
--- gfortran.h (revision 128540)
+++ gfortran.h (working copy)
@@ -650,8 +650,9 @@ typedef struct
unsigned cray_pointer:1, cray_pointee:1;
/* The symbol is a derived type with allocatable components, pointer
- components or private components, possibly nested. */
- unsigned alloc_comp:1, pointer_comp:1, private_comp:1;
+ components or private components, possibly nested. zer_comp
+ is true if the derived type has no component at all. */
+ unsigned alloc_comp:1, pointer_comp:1, private_comp:1, zero_comp:1;
/* The namespace where the VOLATILE attribute has been set. */
struct gfc_namespace *volatile_ns;
Index: resolve.c
===================================================================
--- resolve.c (revision 128540)
+++ resolve.c (working copy)
@@ -7567,7 +7567,8 @@ resolve_symbol (gfc_symbol *sym)
the type is not declared in the scope of the implicit
statement. Change the type to BT_UNKNOWN, both because it is so
and to prevent an ICE. */
- if (sym->ts.type == BT_DERIVED && sym->ts.derived->components == NULL)
+ if (sym->ts.type == BT_DERIVED && sym->ts.derived->components == NULL
+ && !sym->ts.derived->attr.zero_comp)
{
gfc_error ("The derived type '%s' at %L is of type '%s', "
"which has not been defined", sym->name,
Index: parse.c
===================================================================
--- parse.c (revision 128540)
+++ parse.c (working copy)
@@ -1651,6 +1651,9 @@ parse_derived (void)
}
}
+ if (!seen_component)
+ sym->attr.zero_comp = 1;
+
pop_state ();
}
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fxcoudert at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33221
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/33221] Cannot declare variables of TYPE without components
2007-08-28 17:57 [Bug fortran/33221] New: IMPORTing of TYPE declarations without components fails burnus at gcc dot gnu dot org
` (2 preceding siblings ...)
2007-09-18 8:26 ` fxcoudert at gcc dot gnu dot org
@ 2007-09-18 11:32 ` fxcoudert at gcc dot gnu dot org
2007-09-20 22:03 ` fxcoudert at gcc dot gnu dot org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-09-18 11:32 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from fxcoudert at gcc dot gnu dot org 2007-09-18 11:31 -------
(In reply to comment #2)
> One thing that comes to mind is the following patch. It allows derived types
> with zero components to be accepted, but I fear that it might make us accept
> invalid code with empty derived types outside the current scoping unit.
After thinking some more, I think that fear is not justified. There are a few
other places that need adjusting, but I'll submit a complete patch shortly.
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |fxcoudert at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
Last reconfirmed|2007-09-18 07:32:37 |2007-09-18 11:31:46
date| |
Target Milestone|--- |4.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33221
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/33221] Cannot declare variables of TYPE without components
2007-08-28 17:57 [Bug fortran/33221] New: IMPORTing of TYPE declarations without components fails burnus at gcc dot gnu dot org
` (3 preceding siblings ...)
2007-09-18 11:32 ` fxcoudert at gcc dot gnu dot org
@ 2007-09-20 22:03 ` fxcoudert at gcc dot gnu dot org
2007-09-20 22:05 ` fxcoudert at gcc dot gnu dot org
2008-07-12 11:28 ` domob at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-09-20 22:03 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from fxcoudert at gcc dot gnu dot org 2007-09-20 22:03 -------
Subject: Bug 33221
Author: fxcoudert
Date: Thu Sep 20 22:03:22 2007
New Revision: 128633
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128633
Log:
PR fortran/33221
* gfortran.h (symbol_attribute): Add zero_comp field.
* symbol.c (gfc_use_derived): Handle case of emtpy derived types.
* decl.c (gfc_match_data_decl): Likewise.
(gfc_match_derived_decl): Likewise.
* module.c (ab_attribute, attr_bits): Add AB_ZERO_COMP member.
(mio_symbol_attribute): Write and read AB_ZERO_COMP.
* resolve.c (resolve_symbol): Handle case of emtpy derived types.
* parse.c (parse_derived): Likewise.
* gfortran.dg/used_types_18.f90: Declare variable of empty
derived type.
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/decl.c
trunk/gcc/fortran/gfortran.h
trunk/gcc/fortran/module.c
trunk/gcc/fortran/parse.c
trunk/gcc/fortran/resolve.c
trunk/gcc/fortran/symbol.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gfortran.dg/used_types_18.f90
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33221
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/33221] Cannot declare variables of TYPE without components
2007-08-28 17:57 [Bug fortran/33221] New: IMPORTing of TYPE declarations without components fails burnus at gcc dot gnu dot org
` (4 preceding siblings ...)
2007-09-20 22:03 ` fxcoudert at gcc dot gnu dot org
@ 2007-09-20 22:05 ` fxcoudert at gcc dot gnu dot org
2008-07-12 11:28 ` domob at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-09-20 22:05 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from fxcoudert at gcc dot gnu dot org 2007-09-20 22:05 -------
Fixed.
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33221
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/33221] Cannot declare variables of TYPE without components
2007-08-28 17:57 [Bug fortran/33221] New: IMPORTing of TYPE declarations without components fails burnus at gcc dot gnu dot org
` (5 preceding siblings ...)
2007-09-20 22:05 ` fxcoudert at gcc dot gnu dot org
@ 2008-07-12 11:28 ` domob at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: domob at gcc dot gnu dot org @ 2008-07-12 11:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from domob at gcc dot gnu dot org 2008-07-12 11:27 -------
Subject: Bug 33221
Author: domob
Date: Sat Jul 12 11:26:50 2008
New Revision: 137737
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=137737
Log:
2008-07-12 Daniel Kraft <d@domob.eu>
* resolve.c (resolve_fl_derived): Allow pointer components to empty
derived types fixing a missing part of PR fortran/33221.
2008-06-22 Daniel Kraft <d@domob.eu>
* gfortran.dg/used_types_21.f90: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/used_types_21.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/resolve.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33221
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-07-12 11:28 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-28 17:57 [Bug fortran/33221] New: IMPORTing of TYPE declarations without components fails burnus at gcc dot gnu dot org
2007-09-01 8:21 ` [Bug fortran/33221] Using type(...) " burnus at gcc dot gnu dot org
2007-09-18 7:32 ` [Bug fortran/33221] Cannot declare variables of TYPE without components fxcoudert at gcc dot gnu dot org
2007-09-18 8:26 ` fxcoudert at gcc dot gnu dot org
2007-09-18 11:32 ` fxcoudert at gcc dot gnu dot org
2007-09-20 22:03 ` fxcoudert at gcc dot gnu dot org
2007-09-20 22:05 ` fxcoudert at gcc dot gnu dot org
2008-07-12 11:28 ` domob 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).