From: Mikael Morin Date: Sun, 25 Jan 2015 20:30:53 +0000 (+0000) Subject: re PR fortran/62044 (ICE in USE statement with RENAME for extended derived type) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0ac399cfa9066b22cc8c30da900eae58cd6e9cc3;p=gcc.git re PR fortran/62044 (ICE in USE statement with RENAME for extended derived type) fortran/ PR fortran/62044 * decl.c (gfc_match_derived_decl): Don't insert a new symtree element. * module.c (MOD_VERSION): Bump. (write_module): Don't write list of extensions. (read_module): Don't jump over list of extensions; don't load list of extensions. (load_derived_extensions, write_dt_extensions, write_derived_extensions): Remove. testsuite/ PR fortran/62044 * gfortran.dg/use_rename_7.f90: New. From-SVN: r220097 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index be961012e4b..15c3ba01f9f 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,14 @@ +2015-01-25 Mikael Morin + + PR fortran/62044 + * decl.c (gfc_match_derived_decl): Don't insert a new symtree element. + * module.c (MOD_VERSION): Bump. + (write_module): Don't write list of extensions. + (read_module): Don't jump over list of extensions; + don't load list of extensions. + (load_derived_extensions, write_dt_extensions, + write_derived_extensions): Remove. + 2015-01-24 Tobias Burnus * parse.c (gfc_parse_file): Fix two-location gfc_error call. @@ -160,7 +171,6 @@ * decl.c (match_pointer_init): Error out if resolution of init expr failed. ->>>>>>> .r219925 2015-01-15 Tobias Burnus * openmp.c (check_symbol_not_pointer, resolve_oacc_data_clauses, diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index cc35c65f268..c26ffebf27d 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -7790,7 +7790,6 @@ gfc_match_derived_decl (void) if (extended && !sym->components) { gfc_component *p; - gfc_symtree *st; /* Add the extended derived type as the first component. */ gfc_add_component (sym, parent, &p); @@ -7815,8 +7814,6 @@ gfc_match_derived_decl (void) /* Provide the links between the extended type and its extension. */ if (!extended->f2k_derived) extended->f2k_derived = gfc_get_namespace (NULL, 0); - st = gfc_new_symtree (&extended->f2k_derived->sym_root, sym->name); - st->n.sym = sym; } if (!sym->hash_value) diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index 4cfc0e202b5..69dc182d52b 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -92,7 +92,7 @@ along with GCC; see the file COPYING3. If not see /* Don't put any single quote (') in MOD_VERSION, if you want it to be recognized. */ -#define MOD_VERSION "13" +#define MOD_VERSION "14" /* Structure that describes a position within a module file. */ @@ -4542,71 +4542,6 @@ load_equiv (void) } -/* This function loads the sym_root of f2k_derived with the extensions to - the derived type. */ -static void -load_derived_extensions (void) -{ - int symbol, j; - gfc_symbol *derived; - gfc_symbol *dt; - gfc_symtree *st; - pointer_info *info; - char name[GFC_MAX_SYMBOL_LEN + 1]; - char module[GFC_MAX_SYMBOL_LEN + 1]; - const char *p; - - mio_lparen (); - while (peek_atom () != ATOM_RPAREN) - { - mio_lparen (); - mio_integer (&symbol); - info = get_integer (symbol); - derived = info->u.rsym.sym; - - /* This one is not being loaded. */ - if (!info || !derived) - { - while (peek_atom () != ATOM_RPAREN) - skip_list (); - continue; - } - - gcc_assert (derived->attr.flavor == FL_DERIVED); - if (derived->f2k_derived == NULL) - derived->f2k_derived = gfc_get_namespace (NULL, 0); - - while (peek_atom () != ATOM_RPAREN) - { - mio_lparen (); - mio_internal_string (name); - mio_internal_string (module); - - /* Only use one use name to find the symbol. */ - j = 1; - p = find_use_name_n (name, &j, false); - if (p) - { - st = gfc_find_symtree (gfc_current_ns->sym_root, p); - dt = st->n.sym; - st = gfc_find_symtree (derived->f2k_derived->sym_root, name); - if (st == NULL) - { - /* Only use the real name in f2k_derived to ensure a single - symtree. */ - st = gfc_new_symtree (&derived->f2k_derived->sym_root, name); - st->n.sym = dt; - st->n.sym->refs++; - } - } - mio_rparen (); - } - mio_rparen (); - } - mio_rparen (); -} - - /* This function loads OpenMP user defined reductions. */ static void load_omp_udrs (void) @@ -4907,7 +4842,7 @@ check_for_ambiguous (gfc_symbol *st_sym, pointer_info *info) static void read_module (void) { - module_locus operator_interfaces, user_operators, extensions, omp_udrs; + module_locus operator_interfaces, user_operators, omp_udrs; const char *p; char name[GFC_MAX_SYMBOL_LEN + 1]; int i; @@ -4926,13 +4861,10 @@ read_module (void) skip_list (); skip_list (); - /* Skip commons, equivalences and derived type extensions for now. */ + /* Skip commons and equivalences for now. */ skip_list (); skip_list (); - get_module_locus (&extensions); - skip_list (); - /* Skip OpenMP UDRs. */ get_module_locus (&omp_udrs); skip_list (); @@ -5238,11 +5170,6 @@ read_module (void) module_name); } - /* Now we should be in a position to fill f2k_derived with derived type - extensions, since everything has been loaded. */ - set_module_locus (&extensions); - load_derived_extensions (); - /* Clean up symbol nodes that were never loaded, create references to hidden symbols. */ @@ -5460,49 +5387,6 @@ write_equiv (void) } -/* Write derived type extensions to the module. */ - -static void -write_dt_extensions (gfc_symtree *st) -{ - if (!gfc_check_symbol_access (st->n.sym)) - return; - if (!(st->n.sym->ns && st->n.sym->ns->proc_name - && st->n.sym->ns->proc_name->attr.flavor == FL_MODULE)) - return; - - mio_lparen (); - mio_pool_string (&st->name); - if (st->n.sym->module != NULL) - mio_pool_string (&st->n.sym->module); - else - { - char name[GFC_MAX_SYMBOL_LEN + 1]; - if (iomode == IO_OUTPUT) - strcpy (name, module_name); - mio_internal_string (name); - if (iomode == IO_INPUT) - module_name = gfc_get_string (name); - } - mio_rparen (); -} - -static void -write_derived_extensions (gfc_symtree *st) -{ - if (!((st->n.sym->attr.flavor == FL_DERIVED) - && (st->n.sym->f2k_derived != NULL) - && (st->n.sym->f2k_derived->sym_root != NULL))) - return; - - mio_lparen (); - mio_symbol_ref (&(st->n.sym)); - gfc_traverse_symtree (st->n.sym->f2k_derived->sym_root, - write_dt_extensions); - mio_rparen (); -} - - /* Write a symbol to the module. */ static void @@ -5899,13 +5783,6 @@ write_module (void) write_char ('\n'); write_char ('\n'); - mio_lparen (); - gfc_traverse_symtree (gfc_current_ns->sym_root, - write_derived_extensions); - mio_rparen (); - write_char ('\n'); - write_char ('\n'); - mio_lparen (); write_omp_udrs (gfc_current_ns->omp_udr_root); mio_rparen (); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6f062e3d2be..861508782f5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-01-25 Mikael Morin + + PR fortran/62044 + * gfortran.dg/use_rename_7.f90: New. + 2015-01-25 Allan Sandfeld Jensen * gcc.target/i386/funcspec-5.c: Test new multiversion targets. diff --git a/gcc/testsuite/gfortran.dg/use_rename_7.f90 b/gcc/testsuite/gfortran.dg/use_rename_7.f90 new file mode 100644 index 00000000000..d74d4a0ba98 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/use_rename_7.f90 @@ -0,0 +1,27 @@ +! { dg-do compile } +! +! PR fortran/62044 +! ICE when loading module UnstructuredGridImages +! because the type UnstructuredGridImageSiloForm +! is not accessible there under its name. +! +! Contributed by Reuben Budiardja + +module UnstructuredGridImageSilo_Form + implicit none + private + type, public, abstract :: GridImageSiloTemplate + end type GridImageSiloTemplate + type, public, extends ( GridImageSiloTemplate ) :: & + UnstructuredGridImageSiloForm + end type UnstructuredGridImageSiloForm +end module UnstructuredGridImageSilo_Form + +module UnstructuredGridImages + use UnstructuredGridImageSilo_Form, & + UnstructuredGridImageForm => UnstructuredGridImageSiloForm +end module UnstructuredGridImages + +module FileSystem + use UnstructuredGridImages +end module FileSystem