diff options
author | kargl <kargl@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-01-20 22:01:41 +0000 |
---|---|---|
committer | kargl <kargl@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-01-20 22:01:41 +0000 |
commit | 1bcc6eb868641c9ec5b9172a08c3ae3cfb4b6a32 (patch) | |
tree | a5e1dd4c7002a6118aa4d0e313e2d22c3b3aa8ad /gcc/fortran/module.c | |
parent | 9c0ec44ae572cfa18b218fff7359b63e4a97142a (diff) | |
download | gcc-1bcc6eb868641c9ec5b9172a08c3ae3cfb4b6a32.tar.gz |
* openmp.c, matchexp.c, module.c, scanner.c, resolve.c, st.c,
parse.c, primary.c, options.c, misc.c, simplify.c: Next installment
in the massive whitespace patch.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121012 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/module.c')
-rw-r--r-- | gcc/fortran/module.c | 479 |
1 files changed, 225 insertions, 254 deletions
diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index 650942ed72c..1eed5e777bf 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -1,7 +1,7 @@ /* Handle modules, which amounts to loading and saving symbols and their attendant structures. - Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free - Software Foundation, Inc. + Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 + Free Software Foundation, Inc. Contributed by Andy Vaught This file is part of GCC. @@ -199,7 +199,7 @@ static bool in_load_equiv; /* Recursively free the tree of pointer structures. */ static void -free_pi_tree (pointer_info * p) +free_pi_tree (pointer_info *p) { if (p == NULL) return; @@ -218,7 +218,7 @@ free_pi_tree (pointer_info * p) module. */ static int -compare_pointers (void * _sn1, void * _sn2) +compare_pointers (void *_sn1, void *_sn2) { pointer_info *sn1, *sn2; @@ -238,7 +238,7 @@ compare_pointers (void * _sn1, void * _sn2) module. */ static int -compare_integers (void * _sn1, void * _sn2) +compare_integers (void *_sn1, void *_sn2) { pointer_info *sn1, *sn2; @@ -366,7 +366,7 @@ get_integer (int integer) /* Recursive function to find a pointer within a tree by brute force. */ static pointer_info * -fp2 (pointer_info * p, const void *target) +fp2 (pointer_info *p, const void *target) { pointer_info *q; @@ -390,14 +390,13 @@ fp2 (pointer_info * p, const void *target) static pointer_info * find_pointer2 (void *p) { - return fp2 (pi_root, p); } /* Resolve any fixups using a known pointer. */ static void -resolve_fixups (fixup_t *f, void * gp) +resolve_fixups (fixup_t *f, void *gp) { fixup_t *next; @@ -409,12 +408,13 @@ resolve_fixups (fixup_t *f, void * gp) } } + /* Call here during module reading when we know what pointer to associate with an integer. Any fixups that exist are resolved at this time. */ static void -associate_integer_pointer (pointer_info * p, void *gp) +associate_integer_pointer (pointer_info *p, void *gp) { if (p->u.pointer != NULL) gfc_internal_error ("associate_integer_pointer(): Already associated"); @@ -577,7 +577,7 @@ gfc_match_use (void) tail = new; /* See what kind of interface we're dealing with. Assume it is - not an operator. */ + not an operator. */ new->operator = INTRINSIC_NONE; if (gfc_match_generic_spec (&type, name, &operator) == MATCH_ERROR) goto cleanup; @@ -681,6 +681,7 @@ find_use_name_n (const char *name, int *inst) return (u->local_name[0] != '\0') ? u->local_name : name; } + /* Given a name, return the name under which to load this symbol. Returns NULL if this symbol shouldn't be loaded. */ @@ -691,8 +692,8 @@ find_use_name (const char *name) return find_use_name_n (name, &i); } -/* Given a real name, return the number of use names associated - with it. */ + +/* Given a real name, return the number of use names associated with it. */ static int number_use_names (const char *name) @@ -745,7 +746,7 @@ static true_name *true_name_root; /* Compare two true_name structures. */ static int -compare_true_names (void * _t1, void * _t2) +compare_true_names (void *_t1, void *_t2) { true_name *t1, *t2; int c; @@ -782,7 +783,7 @@ find_true_name (const char *name, const char *module) p = true_name_root; while (p != NULL) { - c = compare_true_names ((void *)(&t), (void *) p); + c = compare_true_names ((void *) (&t), (void *) p); if (c == 0) return p->sym; @@ -793,11 +794,10 @@ find_true_name (const char *name, const char *module) } -/* Given a gfc_symbol pointer that is not in the true name tree, add - it. */ +/* Given a gfc_symbol pointer that is not in the true name tree, add it. */ static void -add_true_name (gfc_symbol * sym) +add_true_name (gfc_symbol *sym) { true_name *t; @@ -812,9 +812,8 @@ add_true_name (gfc_symbol * sym) recursively traversing the current namespace. */ static void -build_tnt (gfc_symtree * st) +build_tnt (gfc_symtree *st) { - if (st == NULL) return; @@ -834,7 +833,6 @@ static void init_true_name_tree (void) { true_name_root = NULL; - build_tnt (gfc_current_ns->sym_root); } @@ -842,9 +840,8 @@ init_true_name_tree (void) /* Recursively free a true name tree node. */ static void -free_true_name (true_name * t) +free_true_name (true_name *t) { - if (t == NULL) return; free_true_name (t->left); @@ -911,9 +908,8 @@ bad_module (const char *msgid) /* Set the module's input pointer. */ static void -set_module_locus (module_locus * m) +set_module_locus (module_locus *m) { - module_column = m->column; module_line = m->line; fsetpos (module_fp, &m->pos); @@ -923,9 +919,8 @@ set_module_locus (module_locus * m) /* Get the module's input pointer so that we can restore it later. */ static void -get_module_locus (module_locus * m) +get_module_locus (module_locus *m) { - m->column = module_column; m->line = module_line; fgetpos (module_fp, &m->pos); @@ -978,14 +973,14 @@ parse_string (void) bad_module ("Unexpected end of module in string constant"); if (c != '\'') - { + { len++; continue; } c = module_char (); if (c == '\'') - { + { len++; continue; } @@ -1001,12 +996,12 @@ parse_string (void) { c = module_char (); if (c == '\'') - module_char (); /* Guaranteed to be another \' */ + module_char (); /* Guaranteed to be another \' */ *p++ = c; } - module_char (); /* Terminating \' */ - *p = '\0'; /* C-style string for debug purposes */ + module_char (); /* Terminating \' */ + *p = '\0'; /* C-style string for debug purposes. */ } @@ -1239,7 +1234,7 @@ require_atom (atom_type type) be one of the strings in the array. We return the enum value. */ static int -find_enum (const mstring * m) +find_enum (const mstring *m) { int i; @@ -1260,7 +1255,6 @@ find_enum (const mstring * m) static void write_char (char out) { - if (fputc (out, module_fp) == EOF) gfc_fatal_error ("Error writing modules file: %s", strerror (errno)); @@ -1362,9 +1356,8 @@ static void mio_symtree_ref (gfc_symtree **); pointer because enums are sometimes inside bitfields. */ static int -mio_name (int t, const mstring * m) +mio_name (int t, const mstring *m) { - if (iomode == IO_OUTPUT) write_atom (ATOM_NAME, gfc_code2string (m, t)); else @@ -1380,16 +1373,15 @@ mio_name (int t, const mstring * m) #define DECL_MIO_NAME(TYPE) \ static inline TYPE \ - MIO_NAME(TYPE) (TYPE t, const mstring * m) \ + MIO_NAME(TYPE) (TYPE t, const mstring *m) \ { \ - return (TYPE)mio_name ((int)t, m); \ + return (TYPE) mio_name ((int) t, m); \ } #define MIO_NAME(TYPE) mio_name_##TYPE static void mio_lparen (void) { - if (iomode == IO_OUTPUT) write_atom (ATOM_LPAREN, NULL); else @@ -1400,7 +1392,6 @@ mio_lparen (void) static void mio_rparen (void) { - if (iomode == IO_OUTPUT) write_atom (ATOM_RPAREN, NULL); else @@ -1411,7 +1402,6 @@ mio_rparen (void) static void mio_integer (int *ip) { - if (iomode == IO_OUTPUT) write_atom (ATOM_INTEGER, ip); else @@ -1472,7 +1462,6 @@ mio_pool_string (const char **stringp) static void mio_internal_string (char *string) { - if (iomode == IO_OUTPUT) write_atom (ATOM_STRING, string); else @@ -1529,18 +1518,18 @@ static const mstring attr_bits[] = }; /* Specialization of mio_name. */ -DECL_MIO_NAME(ab_attribute) -DECL_MIO_NAME(ar_type) -DECL_MIO_NAME(array_type) -DECL_MIO_NAME(bt) -DECL_MIO_NAME(expr_t) -DECL_MIO_NAME(gfc_access) -DECL_MIO_NAME(gfc_intrinsic_op) -DECL_MIO_NAME(ifsrc) -DECL_MIO_NAME(procedure_type) -DECL_MIO_NAME(ref_type) -DECL_MIO_NAME(sym_flavor) -DECL_MIO_NAME(sym_intent) +DECL_MIO_NAME (ab_attribute) +DECL_MIO_NAME (ar_type) +DECL_MIO_NAME (array_type) +DECL_MIO_NAME (bt) +DECL_MIO_NAME (expr_t) +DECL_MIO_NAME (gfc_access) +DECL_MIO_NAME (gfc_intrinsic_op) +DECL_MIO_NAME (ifsrc) +DECL_MIO_NAME (procedure_type) +DECL_MIO_NAME (ref_type) +DECL_MIO_NAME (sym_flavor) +DECL_MIO_NAME (sym_intent) #undef DECL_MIO_NAME /* Symbol attributes are stored in list with the first three elements @@ -1550,86 +1539,85 @@ DECL_MIO_NAME(sym_intent) written. */ static void -mio_symbol_attribute (symbol_attribute * attr) +mio_symbol_attribute (symbol_attribute *attr) { atom_type t; mio_lparen (); - attr->flavor = MIO_NAME(sym_flavor) (attr->flavor, flavors); - attr->intent = MIO_NAME(sym_intent) (attr->intent, intents); - attr->proc = MIO_NAME(procedure_type) (attr->proc, procedures); - attr->if_source = MIO_NAME(ifsrc) (attr->if_source, ifsrc_types); + attr->flavor = MIO_NAME (sym_flavor) (attr->flavor, flavors); + attr->intent = MIO_NAME (sym_intent) (attr->intent, intents); + attr->proc = MIO_NAME (procedure_type) (attr->proc, procedures); + attr->if_source = MIO_NAME (ifsrc) (attr->if_source, ifsrc_types); if (iomode == IO_OUTPUT) { if (attr->allocatable) - MIO_NAME(ab_attribute) (AB_ALLOCATABLE, attr_bits); + MIO_NAME (ab_attribute) (AB_ALLOCATABLE, attr_bits); if (attr->dimension) - MIO_NAME(ab_attribute) (AB_DIMENSION, attr_bits); + MIO_NAME (ab_attribute) (AB_DIMENSION, attr_bits); if (attr->external) - MIO_NAME(ab_attribute) (AB_EXTERNAL, attr_bits); + MIO_NAME (ab_attribute) (AB_EXTERNAL, attr_bits); if (attr->intrinsic) - MIO_NAME(ab_attribute) (AB_INTRINSIC, attr_bits); + MIO_NAME (ab_attribute) (AB_INTRINSIC, attr_bits); if (attr->optional) - MIO_NAME(ab_attribute) (AB_OPTIONAL, attr_bits); + MIO_NAME (ab_attribute) (AB_OPTIONAL, attr_bits); if (attr->pointer) - MIO_NAME(ab_attribute) (AB_POINTER, attr_bits); + MIO_NAME (ab_attribute) (AB_POINTER, attr_bits); if (attr->protected) - MIO_NAME(ab_attribute) (AB_PROTECTED, attr_bits); + MIO_NAME (ab_attribute) (AB_PROTECTED, attr_bits); if (attr->save) - MIO_NAME(ab_attribute) (AB_SAVE, attr_bits); + MIO_NAME (ab_attribute) (AB_SAVE, attr_bits); if (attr->value) - MIO_NAME(ab_attribute) (AB_VALUE, attr_bits); + MIO_NAME (ab_attribute) (AB_VALUE, attr_bits); if (attr->volatile_) - MIO_NAME(ab_attribute) (AB_VOLATILE, attr_bits); + MIO_NAME (ab_attribute) (AB_VOLATILE, attr_bits); if (attr->target) - MIO_NAME(ab_attribute) (AB_TARGET, attr_bits); + MIO_NAME (ab_attribute) (AB_TARGET, attr_bits); if (attr->threadprivate) - MIO_NAME(ab_attribute) (AB_THREADPRIVATE, attr_bits); + MIO_NAME (ab_attribute) (AB_THREADPRIVATE, attr_bits); if (attr->dummy) - MIO_NAME(ab_attribute) (AB_DUMMY, attr_bits); + MIO_NAME (ab_attribute) (AB_DUMMY, attr_bits); if (attr->result) - MIO_NAME(ab_attribute) (AB_RESULT, attr_bits); + MIO_NAME (ab_attribute) (AB_RESULT, attr_bits); /* We deliberately don't preserve the "entry" flag. */ if (attr->data) - MIO_NAME(ab_attribute) (AB_DATA, attr_bits); + MIO_NAME (ab_attribute) (AB_DATA, attr_bits); if (attr->in_namelist) - MIO_NAME(ab_attribute) (AB_IN_NAMELIST, attr_bits); + MIO_NAME (ab_attribute) (AB_IN_NAMELIST, attr_bits); if (attr->in_common) - MIO_NAME(ab_attribute) (AB_IN_COMMON, attr_bits); + MIO_NAME (ab_attribute) (AB_IN_COMMON, attr_bits); if (attr->function) - MIO_NAME(ab_attribute) (AB_FUNCTION, attr_bits); + MIO_NAME (ab_attribute) (AB_FUNCTION, attr_bits); if (attr->subroutine) - MIO_NAME(ab_attribute) (AB_SUBROUTINE, attr_bits); + MIO_NAME (ab_attribute) (AB_SUBROUTINE, attr_bits); if (attr->generic) - MIO_NAME(ab_attribute) (AB_GENERIC, attr_bits); + MIO_NAME (ab_attribute) (AB_GENERIC, attr_bits); if (attr->sequence) - MIO_NAME(ab_attribute) (AB_SEQUENCE, attr_bits); + MIO_NAME (ab_attribute) (AB_SEQUENCE, attr_bits); if (attr->elemental) - MIO_NAME(ab_attribute) (AB_ELEMENTAL, attr_bits); + MIO_NAME (ab_attribute) (AB_ELEMENTAL, attr_bits); if (attr->pure) - MIO_NAME(ab_attribute) (AB_PURE, attr_bits); + MIO_NAME (ab_attribute) (AB_PURE, attr_bits); if (attr->recursive) - MIO_NAME(ab_attribute) (AB_RECURSIVE, attr_bits); + MIO_NAME (ab_attribute) (AB_RECURSIVE, attr_bits); if (attr->always_explicit) - MIO_NAME(ab_attribute) (AB_ALWAYS_EXPLICIT, attr_bits); + MIO_NAME (ab_attribute) (AB_ALWAYS_EXPLICIT, attr_bits); if (attr->cray_pointer) - MIO_NAME(ab_attribute) (AB_CRAY_POINTER, attr_bits); + MIO_NAME (ab_attribute) (AB_CRAY_POINTER, attr_bits); if (attr->cray_pointee) - MIO_NAME(ab_attribute) (AB_CRAY_POINTEE, attr_bits); + MIO_NAME (ab_attribute) (AB_CRAY_POINTEE, attr_bits); if (attr->alloc_comp) - MIO_NAME(ab_attribute) (AB_ALLOC_COMP, attr_bits); + MIO_NAME (ab_attribute) (AB_ALLOC_COMP, attr_bits); mio_rparen (); } else { - for (;;) { t = parse_atom (); @@ -1712,9 +1700,9 @@ mio_symbol_attribute (symbol_attribute * attr) case AB_RECURSIVE: attr->recursive = 1; break; - case AB_ALWAYS_EXPLICIT: - attr->always_explicit = 1; - break; + case AB_ALWAYS_EXPLICIT: + attr->always_explicit = 1; + break; case AB_CRAY_POINTER: attr->cray_pointer = 1; break; @@ -1744,7 +1732,7 @@ static const mstring bt_types[] = { static void -mio_charlen (gfc_charlen ** clp) +mio_charlen (gfc_charlen **clp) { gfc_charlen *cl; @@ -1758,7 +1746,6 @@ mio_charlen (gfc_charlen ** clp) } else { - if (peek_atom () != ATOM_RPAREN) { cl = gfc_get_charlen (); @@ -1779,7 +1766,7 @@ mio_charlen (gfc_charlen ** clp) within the namespace and corresponds to an illegal fortran name. */ static gfc_symtree * -get_unique_symtree (gfc_namespace * ns) +get_unique_symtree (gfc_namespace *ns) { char name[GFC_MAX_SYMBOL_LEN + 1]; static int serial = 0; @@ -1794,18 +1781,16 @@ get_unique_symtree (gfc_namespace * ns) static int check_unique_name (const char *name) { - return *name == '@'; } static void -mio_typespec (gfc_typespec * ts) +mio_typespec (gfc_typespec *ts) { - mio_lparen (); - ts->type = MIO_NAME(bt) (ts->type, bt_types); + ts->type = MIO_NAME (bt) (ts->type, bt_types); if (ts->type != BT_DERIVED) mio_integer (&ts->kind); @@ -1828,7 +1813,7 @@ static const mstring array_spec_types[] = { static void -mio_array_spec (gfc_array_spec ** asp) +mio_array_spec (gfc_array_spec **asp) { gfc_array_spec *as; int i; @@ -1853,7 +1838,7 @@ mio_array_spec (gfc_array_spec ** asp) } mio_integer (&as->rank); - as->type = MIO_NAME(array_type) (as->type, array_spec_types); + as->type = MIO_NAME (array_type) (as->type, array_spec_types); for (i = 0; i < as->rank; i++) { @@ -1879,13 +1864,14 @@ static const mstring array_ref_types[] = { minit (NULL, -1) }; + static void -mio_array_ref (gfc_array_ref * ar) +mio_array_ref (gfc_array_ref *ar) { int i; mio_lparen (); - ar->type = MIO_NAME(ar_type) (ar->type, array_ref_types); + ar->type = MIO_NAME (ar_type) (ar->type, array_ref_types); mio_integer (&ar->dimen); switch (ar->type) @@ -1976,7 +1962,7 @@ mio_pointer_ref (void *gp) the namespace and is not loaded again. */ static void -mio_component_ref (gfc_component ** cp, gfc_symbol * sym) +mio_component_ref (gfc_component **cp, gfc_symbol *sym) { char name[GFC_MAX_SYMBOL_LEN + 1]; gfc_component *q; @@ -2020,7 +2006,7 @@ mio_component_ref (gfc_component ** cp, gfc_symbol * sym) static void -mio_component (gfc_component * c) +mio_component (gfc_component *c) { pointer_info *p; int n; @@ -2056,7 +2042,7 @@ mio_component (gfc_component * c) static void -mio_component_list (gfc_component ** cp) +mio_component_list (gfc_component **cp) { gfc_component *c, *tail; @@ -2069,7 +2055,6 @@ mio_component_list (gfc_component ** cp) } else { - *cp = NULL; tail = NULL; @@ -2095,9 +2080,8 @@ mio_component_list (gfc_component ** cp) static void -mio_actual_arg (gfc_actual_arglist * a) +mio_actual_arg (gfc_actual_arglist *a) { - mio_lparen (); mio_pool_string (&a->name); mio_expr (&a->expr); @@ -2106,7 +2090,7 @@ mio_actual_arg (gfc_actual_arglist * a) static void -mio_actual_arglist (gfc_actual_arglist ** ap) +mio_actual_arglist (gfc_actual_arglist **ap) { gfc_actual_arglist *a, *tail; @@ -2146,7 +2130,7 @@ mio_actual_arglist (gfc_actual_arglist ** ap) /* Read and write formal argument lists. */ static void -mio_formal_arglist (gfc_symbol * sym) +mio_formal_arglist (gfc_symbol *sym) { gfc_formal_arglist *f, *tail; @@ -2183,7 +2167,7 @@ mio_formal_arglist (gfc_symbol * sym) /* Save or restore a reference to a symbol node. */ void -mio_symbol_ref (gfc_symbol ** symp) +mio_symbol_ref (gfc_symbol **symp) { pointer_info *p; @@ -2207,7 +2191,7 @@ mio_symbol_ref (gfc_symbol ** symp) /* Save or restore a reference to a symtree node. */ static void -mio_symtree_ref (gfc_symtree ** stp) +mio_symtree_ref (gfc_symtree **stp) { pointer_info *p; fixup_t *f; @@ -2224,29 +2208,30 @@ mio_symtree_ref (gfc_symtree ** stp) return; if (p->type == P_UNKNOWN) - p->type = P_SYMBOL; + p->type = P_SYMBOL; if (p->u.rsym.state == UNUSED) p->u.rsym.state = NEEDED; if (p->u.rsym.symtree != NULL) - { - *stp = p->u.rsym.symtree; - } + { + *stp = p->u.rsym.symtree; + } else - { - f = gfc_getmem (sizeof (fixup_t)); + { + f = gfc_getmem (sizeof (fixup_t)); - f->next = p->u.rsym.stfixup; - p->u.rsym.stfixup = f; + f->next = p->u.rsym.stfixup; + p->u.rsym.stfixup = f; - f->pointer = (void **)stp; - } + f->pointer = (void **)stp; + } } } + static void -mio_iterator (gfc_iterator ** ip) +mio_iterator (gfc_iterator **ip) { gfc_iterator *iter; @@ -2280,9 +2265,8 @@ done: } - static void -mio_constructor (gfc_constructor ** cp) +mio_constructor (gfc_constructor **cp) { gfc_constructor *c, *tail; @@ -2300,7 +2284,6 @@ mio_constructor (gfc_constructor ** cp) } else { - *cp = NULL; tail = NULL; @@ -2326,7 +2309,6 @@ mio_constructor (gfc_constructor ** cp) } - static const mstring ref_types[] = { minit ("ARRAY", REF_ARRAY), minit ("COMPONENT", REF_COMPONENT), @@ -2336,14 +2318,14 @@ static const mstring ref_types[] = { static void -mio_ref (gfc_ref ** rp) +mio_ref (gfc_ref **rp) { gfc_ref *r; mio_lparen (); r = *rp; - r->type = MIO_NAME(ref_type) (r->type, ref_types); + r->type = MIO_NAME (ref_type) (r->type, ref_types); switch (r->type) { @@ -2368,7 +2350,7 @@ mio_ref (gfc_ref ** rp) static void -mio_ref_list (gfc_ref ** rp) +mio_ref_list (gfc_ref **rp) { gfc_ref *ref, *head, *tail; @@ -2406,7 +2388,7 @@ mio_ref_list (gfc_ref ** rp) /* Read and write an integer value. */ static void -mio_gmp_integer (mpz_t * integer) +mio_gmp_integer (mpz_t *integer) { char *p; @@ -2420,7 +2402,6 @@ mio_gmp_integer (mpz_t * integer) bad_module ("Error converting integer"); gfc_free (atom_string); - } else { @@ -2432,7 +2413,7 @@ mio_gmp_integer (mpz_t * integer) static void -mio_gmp_real (mpfr_t * real) +mio_gmp_real (mpfr_t *real) { mp_exp_t exponent; char *p; @@ -2445,7 +2426,6 @@ mio_gmp_real (mpfr_t * real) mpfr_init (*real); mpfr_set_str (*real, atom_string, 16, GFC_RND_MODE); gfc_free (atom_string); - } else { @@ -2473,7 +2453,7 @@ mio_gmp_real (mpfr_t * real) /* Save and restore the shape of an array constructor. */ static void -mio_shape (mpz_t ** pshape, int rank) +mio_shape (mpz_t **pshape, int rank) { mpz_t *shape; atom_type t; @@ -2573,13 +2553,13 @@ fix_mio_expr (gfc_expr *e) yet. If so, the latter should be written. */ if (e->symtree->n.sym && check_unique_name(e->symtree->name)) ns_st = gfc_find_symtree (gfc_current_ns->sym_root, - e->symtree->n.sym->name); + e->symtree->n.sym->name); /* On the other hand, if the existing symbol is the module name or the new symbol is a dummy argument, do not do the promotion. */ if (ns_st && ns_st->n.sym - && ns_st->n.sym->attr.flavor != FL_MODULE - && !e->symtree->n.sym->attr.dummy) + && ns_st->n.sym->attr.flavor != FL_MODULE + && !e->symtree->n.sym->attr.dummy) e->symtree = ns_st; } else if (e->expr_type == EXPR_FUNCTION && e->value.function.name) @@ -2588,8 +2568,8 @@ fix_mio_expr (gfc_expr *e) expression, in one use associated module, can fail to be coupled to its symtree when used in a specification expression in another module. */ - fname = e->value.function.esym ? e->value.function.esym->name : - e->value.function.isym->name; + fname = e->value.function.esym ? e->value.function.esym->name + : e->value.function.isym->name; e->symtree = gfc_find_symtree (gfc_current_ns->sym_root, fname); } } @@ -2599,7 +2579,7 @@ fix_mio_expr (gfc_expr *e) NULL expression. */ static void -mio_expr (gfc_expr ** ep) +mio_expr (gfc_expr **ep) { gfc_expr *e; atom_type t; @@ -2616,8 +2596,7 @@ mio_expr (gfc_expr ** ep) } e = *ep; - MIO_NAME(expr_t) (e->expr_type, expr_types); - + MIO_NAME (expr_t) (e->expr_type, expr_types); } else { @@ -2645,7 +2624,7 @@ mio_expr (gfc_expr ** ep) { case EXPR_OP: e->value.op.operator - = MIO_NAME(gfc_intrinsic_op) (e->value.op.operator, intrinsics); + = MIO_NAME (gfc_intrinsic_op) (e->value.op.operator, intrinsics); switch (e->value.op.operator) { @@ -2696,7 +2675,6 @@ mio_expr (gfc_expr ** ep) mio_symbol_ref (&e->value.function.esym); else write_atom (ATOM_STRING, e->value.function.isym->name); - } else { @@ -2723,8 +2701,8 @@ mio_expr (gfc_expr ** ep) break; case EXPR_SUBSTRING: - e->value.character.string = (char *) - mio_allocated_string (e->value.character.string); + e->value.character.string + = (char *) mio_allocated_string (e->value.character.string); mio_ref_list (&e->ref); break; @@ -2742,12 +2720,12 @@ mio_expr (gfc_expr ** ep) break; case BT_REAL: - gfc_set_model_kind (e->ts.kind); + gfc_set_model_kind (e->ts.kind); mio_gmp_real (&e->value.real); break; case BT_COMPLEX: - gfc_set_model_kind (e->ts.kind); + gfc_set_model_kind (e->ts.kind); mio_gmp_real (&e->value.complex.r); mio_gmp_real (&e->value.complex.i); break; @@ -2758,8 +2736,8 @@ mio_expr (gfc_expr ** ep) case BT_CHARACTER: mio_integer (&e->value.character.length); - e->value.character.string = (char *) - mio_allocated_string (e->value.character.string); + e->value.character.string + = (char *) mio_allocated_string (e->value.character.string); break; default: @@ -2779,7 +2757,7 @@ mio_expr (gfc_expr ** ep) /* Read and write namelists */ static void -mio_namelist (gfc_symbol * sym) +mio_namelist (gfc_symbol *sym) { gfc_namelist *n, *m; const char *check_name; @@ -2800,9 +2778,8 @@ mio_namelist (gfc_symbol * sym) { check_name = find_use_name (sym->name); if (check_name && strcmp (check_name, sym->name) != 0) - gfc_error("Namelist %s cannot be renamed by USE" - " association to %s", - sym->name, check_name); + gfc_error ("Namelist %s cannot be renamed by USE " + "association to %s", sym->name, check_name); } m = NULL; @@ -2831,7 +2808,7 @@ mio_namelist (gfc_symbol * sym) be done later when all symbols have been loaded. */ static void -mio_interface_rest (gfc_interface ** ip) +mio_interface_rest (gfc_interface **ip) { gfc_interface *tail, *p; @@ -2843,7 +2820,6 @@ mio_interface_rest (gfc_interface ** ip) } else { - if (*ip == NULL) tail = NULL; else @@ -2878,9 +2854,8 @@ mio_interface_rest (gfc_interface ** ip) /* Save/restore a nameless operator interface. */ static void -mio_interface (gfc_interface ** ip) +mio_interface (gfc_interface **ip) { - mio_lparen (); mio_interface_rest (ip); } @@ -2890,20 +2865,17 @@ mio_interface (gfc_interface ** ip) static void mio_symbol_interface (const char **name, const char **module, - gfc_interface ** ip) + gfc_interface **ip) { - mio_lparen (); - mio_pool_string (name); mio_pool_string (module); - mio_interface_rest (ip); } static void -mio_namespace_ref (gfc_namespace ** nsp) +mio_namespace_ref (gfc_namespace **nsp) { gfc_namespace *ns; pointer_info *p; @@ -2915,7 +2887,7 @@ mio_namespace_ref (gfc_namespace ** nsp) if (iomode == IO_INPUT && p->integer != 0) { - ns = (gfc_namespace *)p->u.pointer; + ns = (gfc_namespace *) p->u.pointer; if (ns == NULL) { ns = gfc_get_namespace (NULL, 0); @@ -2927,12 +2899,11 @@ mio_namespace_ref (gfc_namespace ** nsp) } -/* Unlike most other routines, the address of the symbol node is - already fixed on input and the name/module has already been filled - in. */ +/* Unlike most other routines, the address of the symbol node is already + fixed on input and the name/module has already been filled in. */ static void -mio_symbol (gfc_symbol * sym) +mio_symbol (gfc_symbol *sym) { gfc_formal_arglist *formal; @@ -2985,8 +2956,8 @@ mio_symbol (gfc_symbol * sym) mio_component_list (&sym->components); if (sym->components != NULL) - sym->component_access = - MIO_NAME(gfc_access) (sym->component_access, access_types); + sym->component_access + = MIO_NAME (gfc_access) (sym->component_access, access_types); mio_namelist (sym); mio_rparen (); @@ -3096,7 +3067,7 @@ load_generic_interfaces (void) if (p == NULL || gfc_find_symbol (p, NULL, 0, &sym)) { while (parse_atom () != ATOM_RPAREN); - continue; + continue; } if (sym == NULL) @@ -3139,9 +3110,9 @@ load_generic_interfaces (void) /* Load common blocks. */ static void -load_commons(void) +load_commons (void) { - char name[GFC_MAX_SYMBOL_LEN+1]; + char name[GFC_MAX_SYMBOL_LEN + 1]; gfc_common_head *p; mio_lparen (); @@ -3162,45 +3133,46 @@ load_commons(void) p->threadprivate = 1; p->use_assoc = 1; - mio_rparen(); + mio_rparen (); } - mio_rparen(); + mio_rparen (); } + /* load_equiv()-- Load equivalences. The flag in_load_equiv informs mio_expr_ref of this so that unused variables are not loaded and so that the expression can be safely freed.*/ static void -load_equiv(void) +load_equiv (void) { gfc_equiv *head, *tail, *end, *eq; bool unused; - mio_lparen(); + mio_lparen (); in_load_equiv = true; end = gfc_current_ns->equiv; - while(end != NULL && end->next != NULL) + while (end != NULL && end->next != NULL) end = end->next; - while(peek_atom() != ATOM_RPAREN) { - mio_lparen(); + while (peek_atom() != ATOM_RPAREN) { + mio_lparen (); head = tail = NULL; - while(peek_atom() != ATOM_RPAREN) + while(peek_atom () != ATOM_RPAREN) { if (head == NULL) - head = tail = gfc_get_equiv(); + head = tail = gfc_get_equiv (); else { - tail->eq = gfc_get_equiv(); + tail->eq = gfc_get_equiv (); tail = tail->eq; } - mio_pool_string(&tail->module); - mio_expr(&tail->expr); + mio_pool_string (&tail->module); + mio_expr (&tail->expr); } /* Unused variables have no symtree. */ @@ -3232,10 +3204,10 @@ load_equiv(void) if (head != NULL) end = head; - mio_rparen(); + mio_rparen (); } - mio_rparen(); + mio_rparen (); in_load_equiv = false; } @@ -3244,7 +3216,7 @@ load_equiv(void) traversal, because the act of loading can alter the tree. */ static int -load_needed (pointer_info * p) +load_needed (pointer_info *p) { gfc_namespace *ns; pointer_info *q; @@ -3300,7 +3272,7 @@ load_needed (pointer_info * p) read. */ static void -read_cleanup (pointer_info * p) +read_cleanup (pointer_info *p) { gfc_symtree *st; pointer_info *q; @@ -3387,8 +3359,7 @@ read_module (void) sym = find_true_name (info->u.rsym.true_name, info->u.rsym.module); if (sym == NULL - || (sym->attr.flavor == FL_VARIABLE - && info->u.rsym.ns !=1)) + || (sym->attr.flavor == FL_VARIABLE && info->u.rsym.ns !=1)) continue; info->u.rsym.state = USED; @@ -3438,9 +3409,11 @@ read_module (void) } else { - /* Create a symtree node in the current namespace for this symbol. */ - st = check_unique_name (p) ? get_unique_symtree (gfc_current_ns) : - gfc_new_symtree (&gfc_current_ns->sym_root, p); + /* Create a symtree node in the current namespace for this + symbol. */ + st = check_unique_name (p) + ? get_unique_symtree (gfc_current_ns) + : gfc_new_symtree (&gfc_current_ns->sym_root, p); st->ambiguous = ambiguous; @@ -3449,10 +3422,9 @@ read_module (void) /* Create a symbol node if it doesn't already exist. */ if (sym == NULL) { - sym = info->u.rsym.sym = - gfc_new_symbol (info->u.rsym.true_name, - gfc_current_ns); - + info->u.rsym.sym = gfc_new_symbol (info->u.rsym.true_name, + gfc_current_ns); + sym = info->u.rsym.sym; sym->module = gfc_get_string (info->u.rsym.module); } @@ -3463,7 +3435,7 @@ read_module (void) info->u.rsym.symtree = st; if (info->u.rsym.state == UNUSED) - info->u.rsym.state = NEEDED; + info->u.rsym.state = NEEDED; info->u.rsym.referenced = 1; } } @@ -3508,7 +3480,7 @@ read_module (void) load_generic_interfaces (); load_commons (); - load_equiv(); + load_equiv (); /* At this point, we read those symbols that are needed but haven't been loaded yet. If one symbol requires another, the other gets @@ -3516,8 +3488,7 @@ read_module (void) while (load_needed (pi_root)); - /* Make sure all elements of the rename-list were found in the - module. */ + /* Make sure all elements of the rename-list were found in the module. */ for (u = gfc_rename_list; u; u = u->next) { @@ -3533,15 +3504,14 @@ read_module (void) if (u->operator == INTRINSIC_USER) { - gfc_error - ("User operator '%s' referenced at %L not found in module '%s'", - u->use_name, &u->where, module_name); + gfc_error ("User operator '%s' referenced at %L not found " + "in module '%s'", u->use_name, &u->where, module_name); continue; } - gfc_error - ("Intrinsic operator '%s' referenced at %L not found in module " - "'%s'", gfc_op2string (u->operator), &u->where, module_name); + gfc_error ("Intrinsic operator '%s' referenced at %L not found " + "in module '%s'", gfc_op2string (u->operator), &u->where, + module_name); } gfc_check_interfaces (gfc_current_ns); @@ -3562,7 +3532,6 @@ read_module (void) bool gfc_check_access (gfc_access specific_access, gfc_access default_access) { - if (specific_access == ACCESS_PUBLIC) return TRUE; if (specific_access == ACCESS_PRIVATE) @@ -3584,23 +3553,23 @@ write_common (gfc_symtree *st) if (st == NULL) return; - write_common(st->left); - write_common(st->right); + write_common (st->left); + write_common (st->right); - mio_lparen(); + mio_lparen (); /* Write the unmangled name. */ name = st->n.common->name; - mio_pool_string(&name); + mio_pool_string (&name); p = st->n.common; - mio_symbol_ref(&p->head); + mio_symbol_ref (&p->head); flags = p->saved ? 1 : 0; if (p->threadprivate) flags |= 2; - mio_integer(&flags); + mio_integer (&flags); - mio_rparen(); + mio_rparen (); } /* Write the blank common block to the module */ @@ -3614,47 +3583,49 @@ write_blank_common (void) if (gfc_current_ns->blank_common.head == NULL) return; - mio_lparen(); + mio_lparen (); - mio_pool_string(&name); + mio_pool_string (&name); - mio_symbol_ref(&gfc_current_ns->blank_common.head); + mio_symbol_ref (&gfc_current_ns->blank_common.head); saved = gfc_current_ns->blank_common.saved; - mio_integer(&saved); + mio_integer (&saved); - mio_rparen(); + mio_rparen (); } + /* Write equivalences to the module. */ static void -write_equiv(void) +write_equiv (void) { gfc_equiv *eq, *e; int num; num = 0; - for(eq=gfc_current_ns->equiv; eq; eq=eq->next) + for (eq = gfc_current_ns->equiv; eq; eq = eq->next) { - mio_lparen(); + mio_lparen (); - for(e=eq; e; e=e->eq) + for (e = eq; e; e = e->eq) { if (e->module == NULL) - e->module = gfc_get_string("%s.eq.%d", module_name, num); - mio_allocated_string(e->module); - mio_expr(&e->expr); + e->module = gfc_get_string ("%s.eq.%d", module_name, num); + mio_allocated_string (e->module); + mio_expr (&e->expr); } num++; - mio_rparen(); + mio_rparen (); } } + /* Write a symbol to the module. */ static void -write_symbol (int n, gfc_symbol * sym) +write_symbol (int n, gfc_symbol *sym) { if (sym->attr.flavor == FL_UNKNOWN || sym->attr.flavor == FL_LABEL) @@ -3676,7 +3647,7 @@ write_symbol (int n, gfc_symbol * sym) according to the access specification. */ static void -write_symbol0 (gfc_symtree * st) +write_symbol0 (gfc_symtree *st) { gfc_symbol *sym; pointer_info *p; @@ -3720,9 +3691,8 @@ write_symbol0 (gfc_symtree * st) symbol was written and pass that information upwards. */ static int -write_symbol1 (pointer_info * p) +write_symbol1 (pointer_info *p) { - if (p == NULL) return 0; @@ -3744,7 +3714,7 @@ write_symbol1 (pointer_info * p) /* Write operator interfaces associated with a symbol. */ static void -write_operator (gfc_user_op * uop) +write_operator (gfc_user_op *uop) { static char nullstring[] = ""; const char *p = nullstring; @@ -3760,9 +3730,8 @@ write_operator (gfc_user_op * uop) /* Write generic interfaces associated with a symbol. */ static void -write_generic (gfc_symbol * sym) +write_generic (gfc_symbol *sym) { - if (sym->generic == NULL || !gfc_check_access (sym->attr.access, sym->ns->default_access)) return; @@ -3775,7 +3744,7 @@ write_generic (gfc_symbol * sym) static void -write_symtree (gfc_symtree * st) +write_symtree (gfc_symtree *st) { gfc_symbol *sym; pointer_info *p; @@ -3840,10 +3809,11 @@ write_module (void) write_char ('\n'); write_char ('\n'); - mio_lparen(); - write_equiv(); - mio_rparen(); - write_char('\n'); write_char('\n'); + mio_lparen (); + write_equiv (); + mio_rparen (); + write_char ('\n'); + write_char ('\n'); /* Write symbol information. First we traverse all symbols in the primary namespace, writing those that need to be written. @@ -3935,8 +3905,8 @@ gfc_dump_module (const char *name, int dump_flag) static void create_int_parameter (const char *name, int value, const char *modname) { - gfc_symtree * tmp_symtree; - gfc_symbol * sym; + gfc_symtree *tmp_symtree; + gfc_symbol *sym; tmp_symtree = gfc_find_symtree (gfc_current_ns->sym_root, name); if (tmp_symtree != NULL) @@ -3958,7 +3928,9 @@ create_int_parameter (const char *name, int value, const char *modname) sym->attr.use_assoc = 1; } + /* USE the ISO_FORTRAN_ENV intrinsic module. */ + static void use_iso_fortran_env_module (void) { @@ -4063,6 +4035,7 @@ use_iso_fortran_env_module (void) } } + /* Process a USE directive. */ void @@ -4073,8 +4046,8 @@ gfc_use_module (void) int c, line, start; gfc_symtree *mod_symtree; - filename = (char *) alloca(strlen(module_name) + strlen(MODULE_EXTENSION) - + 1); + filename = (char *) alloca (strlen (module_name) + strlen (MODULE_EXTENSION) + + 1); strcpy (filename, module_name); strcat (filename, MODULE_EXTENSION); @@ -4089,18 +4062,18 @@ gfc_use_module (void) if (module_fp == NULL && !specified_nonint) { if (strcmp (module_name, "iso_fortran_env") == 0 - && gfc_notify_std (GFC_STD_F2003, "Fortran 2003: " - "ISO_FORTRAN_ENV intrinsic module at %C") != FAILURE) + && gfc_notify_std (GFC_STD_F2003, "Fortran 2003: ISO_FORTRAN_ENV " + "intrinsic module at %C") != FAILURE) { - use_iso_fortran_env_module (); - return; + use_iso_fortran_env_module (); + return; } module_fp = gfc_open_intrinsic_module (filename); if (module_fp == NULL && specified_int) gfc_fatal_error ("Can't find an intrinsic module named '%s' at %C", - module_name); + module_name); } if (module_fp == NULL) @@ -4131,9 +4104,9 @@ gfc_use_module (void) if (start++ < 2) parse_name (c); if ((start == 1 && strcmp (atom_name, "GFORTRAN") != 0) - || (start == 2 && strcmp (atom_name, " module") != 0)) + || (start == 2 && strcmp (atom_name, " module") != 0)) gfc_fatal_error ("File '%s' opened at %C is not a GFORTRAN module " - "file", filename); + "file", filename); if (c == '\n') line++; @@ -4162,7 +4135,6 @@ gfc_use_module (void) void gfc_module_init_2 (void) { - last_atom = ATOM_LPAREN; } @@ -4170,6 +4142,5 @@ gfc_module_init_2 (void) void gfc_module_done_2 (void) { - free_rename (); } |