diff options
author | Tobias Schlüter <tobias.schlueter@physik.uni-muenchen.de> | 2005-02-23 23:14:12 +0100 |
---|---|---|
committer | Tobias Schlüter <tobi@gcc.gnu.org> | 2005-02-23 23:14:12 +0100 |
commit | e9444bd5ee3a3fa264e5f8541cb6b01507c813fa (patch) | |
tree | 94405864274f14b88cb5fd2d24eba85e42579556 /gcc/fortran/intrinsic.c | |
parent | 58b03ab29f5bad84af12b599a1791c65c2d01405 (diff) | |
download | gcc-e9444bd5ee3a3fa264e5f8541cb6b01507c813fa.tar.gz |
gfortran.h (gfc_component, [...]): Make 'name' a 'const char *'.
* gfortran.h (gfc_component, gfc_actual_arglist, gfc_user_op): Make
'name' a 'const char *'.
(gfc_symbol): Likewise, also for 'module'.
(gfc_symtree): Make 'name' a 'const char *'.
(gfc_intrinsic_sym): Likewise, also for 'lib_name'.
(gfc_get_gsymbol, gfc_find_gsymbol): Add 'const' qualifier to
'char *' argument.
(gfc_intrinsic_symbol): Use 'gfc_get_string' instead of 'strcpy' to
initialize 'SYM->module'.
* check.c (gfc_check_minloc_maxloc, check_reduction): Check for NULL
pointer instead of empty string.
* dump-parse-tree.c (gfc_show_actual_arglist): Likewise.
* interface.c (gfc_compare_types): Adapt check to account for possible
NULL pointer.
(compare_actual_formal): Check for NULL pointer instead of empty
string.
* intrinsic.c (gfc_current_intrinsic, gfc_current_intrinsic_arg):
Add 'const' qualifier.
(conv_name): Return a heap allocated string.
(find_conv): Add 'const' qualifier to 'target'.
(add_sym): Use 'gfc_get_string' instead of 'strcpy'.
(make_generic): Check for NULL pointer instead of emptystring.
(make_alias): Use 'gfc_get_string' instead of 'strcpy'.
(add_conv): No need to strcpy result from 'conv_name'.
(sort_actual): Check for NULL pointer instead of emptystring.
* intrinsic.h (gfc_current_intrinsic, gfc_current_intrinsic_arg):
Adapt prototype.
* module.c (compare_true_names): Compare pointers instead of strings
for 'module' member.
(find_true_name): Initialize string fields with gfc_get_string.
(mio_pool_string): New function.
(mio_internal_string): Adapt comment.
(mio_component_ref, mio_component, mio_actual_arg): Use
'mio_pool_string' instead of 'mio_internal_string'.
(mio_symbol_interface): Add 'const' qualifier to string arguments.
Add level of indirection. Use 'mio_pool_string' instead of
'mio_internal_string'.
(load_needed, read_module): Use 'gfc_get_string' instead of 'strcpy'.
(write_common, write_symbol): Use 'mio_pool_string' instead of
'mio_internal_string'.
(write_symbol0, write_symbol1): Likewise, also check for NULL pointer
instead of empty string.
(write_operator, write_generic): Pass correct type variable to
'mio_symbol_interface'.
(write_symtree): Use 'mio_pool_string' instead of
'mio_internal_string'.
* primary.c (match_keyword_arg): Adapt check to possible
case of NULL pointer. Use 'gfc_get_string' instead of 'strcpy'.
* symbol.c (gfc_add_component, gfc_new_symtree, delete_symtree,
gfc_get_uop, gfc_new_symbol): Use 'gfc_get_string' instead of
'strcpy'.
(ambiguous_symbol): Check for NULL pointer instead of empty string.
(gfc_find_gsymbol, gfc_get_gsymbol): Add 'const' qualifier on string
arguments.
* trans-array.c (gfc_trans_auto_array_allocation): Check for NULL
pointer instead of empty string.
* trans-decl.c (gfc_sym_mangled_identifier,
gfc_sym_mangled_function_id, gfc_finish_var_decl, gfc_get_symbol_decl,
gfc_get_symbol_decl): Likewise.
* trans-io.c (gfc_new_nml_name_expr): Add 'const' qualifier to
argument. Copy string instead of pointing to it.
From-SVN: r95472
Diffstat (limited to 'gcc/fortran/intrinsic.c')
-rw-r--r-- | gcc/fortran/intrinsic.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/gcc/fortran/intrinsic.c b/gcc/fortran/intrinsic.c index f9642c78ac8..ebf5cb2edda 100644 --- a/gcc/fortran/intrinsic.c +++ b/gcc/fortran/intrinsic.c @@ -37,7 +37,8 @@ int gfc_init_expr = 0; /* Pointers to an intrinsic function and its argument names that are being checked. */ -char *gfc_current_intrinsic, *gfc_current_intrinsic_arg[MAX_INTRINSIC_ARGS]; +const char *gfc_current_intrinsic; +const char *gfc_current_intrinsic_arg[MAX_INTRINSIC_ARGS]; locus *gfc_current_intrinsic_where; static gfc_intrinsic_sym *functions, *subroutines, *conversion, *next_sym; @@ -107,7 +108,7 @@ gfc_get_intrinsic_sub_symbol (const char * name) /* Return a pointer to the name of a conversion function given two typespecs. */ -static char * +static const char * conv_name (gfc_typespec * from, gfc_typespec * to) { static char name[30]; @@ -115,7 +116,7 @@ conv_name (gfc_typespec * from, gfc_typespec * to) sprintf (name, "__convert_%c%d_%c%d", gfc_type_letter (from->type), from->kind, gfc_type_letter (to->type), to->kind); - return name; + return gfc_get_string (name); } @@ -127,7 +128,7 @@ static gfc_intrinsic_sym * find_conv (gfc_typespec * from, gfc_typespec * to) { gfc_intrinsic_sym *sym; - char *target; + const char *target; int i; target = conv_name (from, to); @@ -213,7 +214,7 @@ add_sym (const char *name, int elemental, int actual_ok ATTRIBUTE_UNUSED, bt type, int kind, int standard, gfc_check_f check, gfc_simplify_f simplify, gfc_resolve_f resolve, ...) { - + char buf[GFC_MAX_SYMBOL_LEN + 11]; /* 10 for '_gfortran_', 1 for '\0' */ int optional, first_flag; va_list argp; @@ -233,10 +234,11 @@ add_sym (const char *name, int elemental, int actual_ok ATTRIBUTE_UNUSED, break; case SZ_NOTHING: - strcpy (next_sym->name, name); + next_sym->name = gfc_get_string (name); - strcpy (next_sym->lib_name, "_gfortran_"); - strcat (next_sym->lib_name, name); + strcpy (buf, "_gfortran_"); + strcat (buf, name); + next_sym->lib_name = gfc_get_string (buf); next_sym->elemental = elemental; next_sym->ts.type = type; @@ -785,11 +787,11 @@ make_generic (const char *name, gfc_generic_isym_id generic_id, int standard) g->generic = 1; g->specific = 1; g->generic_id = generic_id; - if ((g + 1)->name[0] != '\0') + if ((g + 1)->name != NULL) g->specific_head = g + 1; g++; - while (g->name[0] != '\0') + while (g->name != NULL) { g->next = g + 1; g->specific = 1; @@ -828,7 +830,7 @@ make_alias (const char *name, int standard) case SZ_NOTHING: next_sym[0] = next_sym[-1]; - strcpy (next_sym->name, name); + next_sym->name = gfc_get_string (name); next_sym++; break; @@ -2152,8 +2154,8 @@ add_conv (bt from_type, int from_kind, bt to_type, int to_kind, sym = conversion + nconv; - strcpy (sym->name, conv_name (&from, &to)); - strcpy (sym->lib_name, sym->name); + sym->name = conv_name (&from, &to); + sym->lib_name = sym->name; sym->simplify.cc = simplify; sym->elemental = 1; sym->ts = to; @@ -2359,7 +2361,7 @@ sort_actual (const char *name, gfc_actual_arglist ** ap, if (a == NULL) goto optional; - if (a->name[0] != '\0') + if (a->name != NULL) goto keywords; f->actual = a; |