diff options
author | fxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-09-20 22:03:22 +0000 |
---|---|---|
committer | fxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-09-20 22:03:22 +0000 |
commit | e6b82afc8bc3e215ea6f07dcbe997c5892355511 (patch) | |
tree | c777e12a86d2297992869f6434a715f22b9b1da3 /gcc | |
parent | f321262a0fa5f45378dd29188f67439d90c279c0 (diff) | |
download | gcc-e6b82afc8bc3e215ea6f07dcbe997c5892355511.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@128633 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/fortran/decl.c | 8 | ||||
-rw-r--r-- | gcc/fortran/gfortran.h | 5 | ||||
-rw-r--r-- | gcc/fortran/module.c | 8 | ||||
-rw-r--r-- | gcc/fortran/parse.c | 3 | ||||
-rw-r--r-- | gcc/fortran/resolve.c | 3 | ||||
-rw-r--r-- | gcc/fortran/symbol.c | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/used_types_18.f90 | 3 |
9 files changed, 42 insertions, 8 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index f3a65cd086b..5a81ebe71d4 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,5 +1,17 @@ 2007-09-20 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> + 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. + +2007-09-20 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> + PR fortran/33288 * arith.c (reduce_unary, reduce_binary_ac, reduce_binary_ca, reduce_binary_aa): Call ourselves recursively if an element of diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index f9f92ad91b7..7fa8548fb56 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -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) @@ -3426,7 +3427,8 @@ gfc_match_data_decl (void) /* Any symbol that we find had better be a type definition which has its components defined. */ if (sym != NULL && sym->attr.flavor == FL_DERIVED - && current_ts.derived->components != NULL) + && (current_ts.derived->components != NULL + || current_ts.derived->attr.zero_comp)) goto ok; /* Now we have an error, which we signal, and then fix up @@ -5884,7 +5886,7 @@ gfc_match_derived_decl (void) && gfc_add_flavor (&sym->attr, FL_DERIVED, sym->name, NULL) == FAILURE) return MATCH_ERROR; - if (sym->components != NULL) + if (sym->components != NULL || sym->attr.zero_comp) { gfc_error ("Derived type definition of '%s' at %C has already been " "defined", sym->name); diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index a5f4881f453..32b15616600 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -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; diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index 0b01ee4c8cb..3418afa0c16 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -1523,7 +1523,7 @@ typedef enum AB_ELEMENTAL, AB_PURE, AB_RECURSIVE, AB_GENERIC, AB_ALWAYS_EXPLICIT, AB_CRAY_POINTER, AB_CRAY_POINTEE, AB_THREADPRIVATE, AB_ALLOC_COMP, AB_POINTER_COMP, AB_PRIVATE_COMP, AB_VALUE, AB_VOLATILE, AB_PROTECTED, - AB_IS_BIND_C, AB_IS_C_INTEROP, AB_IS_ISO_C, AB_ABSTRACT + AB_IS_BIND_C, AB_IS_C_INTEROP, AB_IS_ISO_C, AB_ABSTRACT, AB_ZERO_COMP } ab_attribute; @@ -1560,6 +1560,7 @@ static const mstring attr_bits[] = minit ("ALLOC_COMP", AB_ALLOC_COMP), minit ("POINTER_COMP", AB_POINTER_COMP), minit ("PRIVATE_COMP", AB_PRIVATE_COMP), + minit ("ZERO_COMP", AB_ZERO_COMP), minit ("PROTECTED", AB_PROTECTED), minit ("ABSTRACT", AB_ABSTRACT), minit (NULL, -1) @@ -1673,6 +1674,8 @@ mio_symbol_attribute (symbol_attribute *attr) MIO_NAME (ab_attribute) (AB_POINTER_COMP, attr_bits); if (attr->private_comp) MIO_NAME (ab_attribute) (AB_PRIVATE_COMP, attr_bits); + if (attr->zero_comp) + MIO_NAME (ab_attribute) (AB_ZERO_COMP, attr_bits); mio_rparen (); @@ -1788,6 +1791,9 @@ mio_symbol_attribute (symbol_attribute *attr) case AB_PRIVATE_COMP: attr->private_comp = 1; break; + case AB_ZERO_COMP: + attr->zero_comp = 1; + break; } } } diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c index 50c0c0dd979..a6672f46ca6 100644 --- a/gcc/fortran/parse.c +++ b/gcc/fortran/parse.c @@ -1651,6 +1651,9 @@ parse_derived (void) } } + if (!seen_component) + sym->attr.zero_comp = 1; + pop_state (); } diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 1b3aab61373..26632bbde84 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -7627,7 +7627,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, diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index 6ed366f607f..d6bd9638df6 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ee10c4cfdcc..14fb1f344a1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,11 @@ 2007-09-20 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> + PR fortran/33221 + * gfortran.dg/used_types_18.f90: Declare variable of empty + derived type. + +2007-09-20 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org> + PR fortran/33288 * gfortran.dg/array_constructor_19.f90: New test. diff --git a/gcc/testsuite/gfortran.dg/used_types_18.f90 b/gcc/testsuite/gfortran.dg/used_types_18.f90 index e3dca1f735d..0acebc4c830 100644 --- a/gcc/testsuite/gfortran.dg/used_types_18.f90 +++ b/gcc/testsuite/gfortran.dg/used_types_18.f90 @@ -9,4 +9,7 @@ ! type t end type + +type(t) :: a +print *, a end |