From 52f4993488d2dd12d66dd99c2937e59319d0b1b6 Mon Sep 17 00:00:00 2001 From: Daniel Kraft Date: Tue, 2 Sep 2008 10:13:21 +0200 Subject: gfortran.h (struct gfc_namespace): New member `implicit_loc'. 2008-09-02 Daniel Kraft * gfortran.h (struct gfc_namespace): New member `implicit_loc'. (gfc_add_abstract): New method. * decl.c (gfc_get_type_attr_spec): Match ABSTRACT attribute. (gfc_match_derived_decl): Copy abstract attribute in derived symbol. * dump-parse-tree.c (show_attr): Show ABSTRACT attribute as `ABSTRACT' only to allow for ABSTRACT types. * parse.c (parse_interface): Use new gfc_add_abstract. * primary.c (gfc_match_structure_constructor): Check that no ABSTRACT type is constructed. * resolve.c (resolve_typespec_used): New method. (resolve_fl_derived): Check type in respect to ABSTRACT attribute and check that no component is of an ABSTRACT type. (resolve_symbol): Check that no symbol is of an ABSTRACT type. (resolve_types): Check IMPLICIT declarations for ABSTRACT types. * symbol.c (gfc_merge_new_implicit): Remember loci of IMPLICIT's. (gfc_add_abstract): New method. 2008-09-02 Daniel Kraft * gfortran.dg/abstract_type_1.f90: New test. * gfortran.dg/abstract_type_2.f03: New test. * gfortran.dg/abstract_type_3.f03: New test. * gfortran.dg/abstract_type_4.f03: New test. From-SVN: r139885 --- gcc/fortran/primary.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'gcc/fortran/primary.c') diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c index c187749..6689443 100644 --- a/gcc/fortran/primary.c +++ b/gcc/fortran/primary.c @@ -2125,7 +2125,8 @@ build_actual_constructor (gfc_structure_ctor_component **comp_head, } match -gfc_match_structure_constructor (gfc_symbol *sym, gfc_expr **result, bool parent) +gfc_match_structure_constructor (gfc_symbol *sym, gfc_expr **result, + bool parent) { gfc_structure_ctor_component *comp_tail, *comp_head, *comp_iter; gfc_constructor *ctor_head, *ctor_tail; @@ -2145,6 +2146,13 @@ gfc_match_structure_constructor (gfc_symbol *sym, gfc_expr **result, bool parent gfc_find_component (sym, NULL, false, true); + /* Check that we're not about to construct an ABSTRACT type. */ + if (!parent && sym->attr.abstract) + { + gfc_error ("Can't construct ABSTRACT type '%s' at %C", sym->name); + return MATCH_ERROR; + } + /* Match the component list and store it in a list together with the corresponding component names. Check for empty argument list first. */ if (gfc_match_char (')') != MATCH_YES) @@ -2243,6 +2251,7 @@ gfc_match_structure_constructor (gfc_symbol *sym, gfc_expr **result, bool parent { gfc_current_locus = where; gfc_free_expr (comp_tail->val); + comp_tail->val = NULL; m = gfc_match_structure_constructor (comp->ts.derived, &comp_tail->val, true); -- cgit v1.1