diff options
author | Zack Weinberg <zack@wolery.cumb.org> | 2000-05-09 19:56:01 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2000-05-09 19:56:01 +0000 |
commit | 3b304f5b7d7e2140665ee8bac980e800ade8c04b (patch) | |
tree | 11478b672b9b1d6e7c70820a940f550161e9a1a5 /gcc/gcc.c | |
parent | aa9e158d7ac4e85cede46a969c62cc7dada16060 (diff) | |
download | gcc-3b304f5b7d7e2140665ee8bac980e800ade8c04b.zip gcc-3b304f5b7d7e2140665ee8bac980e800ade8c04b.tar.gz gcc-3b304f5b7d7e2140665ee8bac980e800ade8c04b.tar.bz2 |
top level:
* Makefile.in (WARN_CFLAGS): Add -Wwrite-strings.
(tree.o): Depend on output.h.
* c-decl.c (pending_invalid_xref_file,
current_function_prototype_file): Constify.
(pushdecl): Constify a local char *.
(define_label): Constify filename parameter.
* c-lex.c (init_parse): Constify parameter and return value.
* c-typeck.c (c_expand_asm_operands): Constify filename parameter.
* c-tree.h: Update prototypes.
* c-parse.in: Constify filename member of %union, and if_stmt_file.
* c-parse.y, c-parse.c, c-parse.h, objc/objc-parse.y,
objc/objc-parse.c: Regenerate.
* dwarfout.c (dwarfout_init): Constify main_input_filename parameter.
* dwarfout.h: Update prototypes.
* expr.c (expand_expr): Constify a local char *.
* flags.h: Constify main_input_filename.
* function.c (expand_function_end): Constify filename parameter.
* genrecog.c (make_insn_sequence): Use a character array for
c_test_pos.
(main): Remove unused variables.
* input.h: Constify input_filename, main_input_filename, and
file_stack.name. Update prototypes.
* output.h: Declare first_global_object_name and
weak_global_object_name here, as const char *.
* stmt.c (expand_asm_operands): Constify filename parameter.
* toplev.c (compile_file, push_srcloc, debug_start_source_file):
Constify filename parameter.
(input_filename, main_input_filename): Constify.
* toplev.h: Update prototypes.
* tree.c: Include output.h. Don't declare
first_global_object_name or weak_global_object_name. Clean up string
bashing in get_file_function_name_long.
* tree.h (struct tree_decl): Constify filename member.
(input_filename): Constify.
Update prototypes.
* varasm.c (first_global_object_name, weak_global_object_name):
Constify.
(assemble_start_function, assemble_variable): Clean up string bashing.
* gcc.c: Constify all spec-related strings initialized,
transitively, from string constants. Constify all strings
and string variables related to multilibs.
(set_spec, read_specs): Cast argument to free to PTR.
(used_arg): Do not modify multilib_matches. Use strncmp plus
length comparison to compare multilib switches.
* genmultilib: Constify everything declared in multilib.h.
ch:
* ch-tree.h: Update prototypes. Remove prototypes for
functions declared elsewhere.
* decl.c (define_label): Constify filename parameter.
* grant.c (globalize_decl, set_default_grant_file): Constify
local char * variables. Don't declare
first_global_object_name or asm_out_file.
* lang.c (chill_real_input_filename): Constify.
* lex.c (init_parse): Constify parameter and return value.
* parse.c: Don't declare input_filename.
(ch_expand_asm_operands): Constify filename parameter.
(parse_multi_dimension_case_action): Constify local char *.
* satisfy.c (safe_satisfy_decl): Constify local char *.
cp:
* cp-tree.h: Constify tree_srcloc.filename, tinst_level.file,
and pending_inline.filename. Update prototypes.
* decl.c (define_label): Constify filename parameter.
* decl2.c (warn_if_unknown_interface): Constify local char *.
* input.c Constify input_source.filename. Don't declare
input_filename or lineno. Constify filename parameter to feed_input.
* lex.c (init_parse): Constify parameter and return value.
(cp_pragma_interface, cp_pragma_implementation): Constify
filename argument.
(reinit_parse_for_method, reinit_parse_for_block,
reinit_parse_for_expr, feed_defarg, handle_cp_pragma):
Constify local char *.
* pt.c: Don't declare lineno or input_filename.
(print_template_context, tsubst_friend_function, tsubst_decl,
tsubst, instantiate_decl): Constify local char *.
* semantics.c (expand_body): Constify local char *.
* tree.c (build_srcloc): Constify filename parameter.
* typeck.c (c_expand_asm_operands): Constify filename
parameter.
f:
* com.c (ffecom_subscript_check_): Constify array_name
parameter. Clean up string bashing.
(ffecom_arrayref_, ffecom_char_args_x_): Constify array_name
parameter.
(ffecom_do_entry_, ffecom_gen_sfuncdef_, ffecom_start_progunit_,
ffecom_sym_transform_, ffecom_sym_transform_assign_): Constify
local char *.
(init_parse): Constify parameter and return value.
* lex.c: Include dwarfout.h instead of prototyping dwarfout_*
functions here.
(ffelex_file_pop_, ffelex_file_push_): Constify filename parameter.
(ffelex_hash_, ffelex_include_): Constify local char *.
* std.c (ffestd_exec_end): Constify local char *.
* where.c (ffewhere_file_new): Constify filename parameter.
* where.h: Update prototypes.
java:
* check_init.c (check_init): Constify local char *.
* class.c (push_class): Constify local char *.
* java_tree.h: Update prototypes.
* jcf-io.c (open_class): Constify filename parameter and
return value.
(find_class): Remove redundant string copy. Cast return from
open_class.
* jcf-parse.c (read_class, parse_class_file, yyparse):
Constify local char *.
* jcf-write.c (generate_bytecode_insns, generate_classfile):
Constify local char *.
* jcf.h (JCF): Constify filename and classname.
(JCF_FINISH): Cast args to FREE to char * when appropriate.
* lang.c (init_parse): Constify parameter and return value.
* lex.c (java_get_line_col): Constify filename parameter.
* parse.h: Constify parser_ctxt.filename. Update prototypes.
* parse.y (java_parser_context_suspend,
issue_warning_error_from_context, safe_layout_class): Constify
local char *.
* parse.c: Regenerate.
From-SVN: r33804
Diffstat (limited to 'gcc/gcc.c')
-rw-r--r-- | gcc/gcc.c | 112 |
1 files changed, 55 insertions, 57 deletions
@@ -146,11 +146,11 @@ static int save_temps_flag; /* The compiler version. */ -static char *compiler_version; +static const char *compiler_version; /* The target version specified with -V */ -static char *spec_version = DEFAULT_TARGET_VERSION; +static const char *spec_version = DEFAULT_TARGET_VERSION; /* The target machine specified with -b. */ @@ -160,9 +160,9 @@ static const char *spec_machine = DEFAULT_TARGET_MACHINE; When -b is used, the value comes from the `specs' file. */ #ifdef CROSS_COMPILE -static char *cross_compile = "1"; +static const char *cross_compile = "1"; #else -static char *cross_compile = "0"; +static const char *cross_compile = "0"; #endif /* The number of errors that have occurred; the link phase will not be @@ -493,29 +493,29 @@ proper position among the other output files. */ #define LINKER_NAME "collect2" #endif -static char *cpp_spec = CPP_SPEC; -static char *cpp_predefines = CPP_PREDEFINES; -static char *cc1_spec = CC1_SPEC; -static char *cc1plus_spec = CC1PLUS_SPEC; -static char *signed_char_spec = SIGNED_CHAR_SPEC; -static char *asm_spec = ASM_SPEC; -static char *asm_final_spec = ASM_FINAL_SPEC; -static char *link_spec = LINK_SPEC; -static char *lib_spec = LIB_SPEC; -static char *libgcc_spec = LIBGCC_SPEC; -static char *endfile_spec = ENDFILE_SPEC; -static char *startfile_spec = STARTFILE_SPEC; -static char *switches_need_spaces = SWITCHES_NEED_SPACES; -static char *linker_name_spec = LINKER_NAME; +static const char *cpp_spec = CPP_SPEC; +static const char *cpp_predefines = CPP_PREDEFINES; +static const char *cc1_spec = CC1_SPEC; +static const char *cc1plus_spec = CC1PLUS_SPEC; +static const char *signed_char_spec = SIGNED_CHAR_SPEC; +static const char *asm_spec = ASM_SPEC; +static const char *asm_final_spec = ASM_FINAL_SPEC; +static const char *link_spec = LINK_SPEC; +static const char *lib_spec = LIB_SPEC; +static const char *libgcc_spec = LIBGCC_SPEC; +static const char *endfile_spec = ENDFILE_SPEC; +static const char *startfile_spec = STARTFILE_SPEC; +static const char *switches_need_spaces = SWITCHES_NEED_SPACES; +static const char *linker_name_spec = LINKER_NAME; /* Some compilers have limits on line lengths, and the multilib_select and/or multilib_matches strings can be very long, so we build them at run time. */ static struct obstack multilib_obstack; -static char *multilib_select; -static char *multilib_matches; -static char *multilib_defaults; -static char *multilib_exclusions; +static const char *multilib_select; +static const char *multilib_matches; +static const char *multilib_defaults; +static const char *multilib_exclusions; #include "multilib.h" /* Check whether a particular argument is a default argument. */ @@ -1119,12 +1119,12 @@ struct spec_list { /* The following 2 fields must be first */ /* to allow EXTRA_SPECS to be initialized */ - char *name; /* name of the spec. */ - char *ptr; /* available ptr if no static pointer */ + const char *name; /* name of the spec. */ + const char *ptr; /* available ptr if no static pointer */ /* The following fields are not initialized */ /* by EXTRA_SPECS */ - char **ptr_spec; /* pointer to the spec itself. */ + const char **ptr_spec; /* pointer to the spec itself. */ struct spec_list *next; /* Next spec in linked list. */ int name_len; /* length of the name */ int alloc_p; /* whether string was allocated */ @@ -1164,8 +1164,8 @@ static struct spec_list static_specs[] = That is all that the EXTRA_SPECS macro gives us. */ struct spec_list_1 { - char *name; - char *ptr; + const char *name; + const char *ptr; }; static struct spec_list_1 extra_specs_1[] = { EXTRA_SPECS }; @@ -1230,7 +1230,7 @@ set_spec (name, spec) const char *spec; { struct spec_list *sl; - char *old_spec; + const char *old_spec; int name_len = strlen (name); int i; @@ -1278,7 +1278,7 @@ set_spec (name, spec) /* Free the old spec. */ if (old_spec && sl->alloc_p) - free (old_spec); + free ((PTR) old_spec); sl->alloc_p = 1; } @@ -1413,7 +1413,7 @@ static const char *tooldir_prefix; #ifndef STANDARD_BINDIR_PREFIX #define STANDARD_BINDIR_PREFIX "/usr/local/bin" #endif -static char *standard_bindir_prefix = STANDARD_BINDIR_PREFIX; +static const char *standard_bindir_prefix = STANDARD_BINDIR_PREFIX; /* Subdirectory to use for locating libraries. Set by set_multilib_dir based on the compilation options. */ @@ -1657,7 +1657,7 @@ read_specs (filename, main_p) set_spec (p2, *(sl->ptr_spec)); if (sl->alloc_p) - free (*(sl->ptr_spec)); + free ((PTR) *(sl->ptr_spec)); *(sl->ptr_spec) = ""; sl->alloc_p = 0; @@ -4291,7 +4291,7 @@ do_spec_1 (spec, inswitch, soft_matched_part) { char *x = (char *) alloca (strlen (cpp_predefines) + 1); char *buf = x; - char *y; + const char *y; /* Copy all of the -D options in CPP_PREDEFINES into BUF. */ y = cpp_predefines; @@ -4321,7 +4321,7 @@ do_spec_1 (spec, inswitch, soft_matched_part) { char *x = (char *) alloca (strlen (cpp_predefines) * 4 + 1); char *buf = x; - char *y; + const char *y; /* Copy all of CPP_PREDEFINES into BUF, but force them all into the reserved name space if they @@ -4567,8 +4567,8 @@ do_spec_1 (spec, inswitch, soft_matched_part) case 'v': { int c1 = *p++; /* Select first or second version number. */ - char *v = compiler_version; - char *q; + const char *v = compiler_version; + const char *q; static const char zeroc = '0'; /* The format of the version string is @@ -5172,7 +5172,7 @@ main (argc, argv) /* Build multilib_select, et. al from the separate lines that make up each multilib selection. */ { - char **q = multilib_raw; + const char *const *q = multilib_raw; int need_space; obstack_init (&multilib_obstack); @@ -5948,8 +5948,8 @@ used_arg (p, len) { struct mswitchstr { - char *str; - char *replace; + const char *str; + const char *replace; int len; int rep_len; }; @@ -5961,7 +5961,7 @@ used_arg (p, len) if (!mswitches) { struct mswitchstr *matches; - char *q; + const char *q; int cnt = 0; /* Break multilib_matches into the component strings of string and replacement @@ -5982,7 +5982,6 @@ used_arg (p, len) abort (); q++; } - *q = '\0'; matches[i].len = q - matches[i].str; matches[i].replace = ++q; @@ -5994,9 +5993,7 @@ used_arg (p, len) } matches[i].rep_len = q - matches[i].replace; i++; - if (*q == ';') - *q++ = '\0'; - else + if (*q != ';') break; } @@ -6011,7 +6008,8 @@ used_arg (p, len) { int xlen = strlen (switches[i].part1); for (j = 0; j < cnt; j++) - if (xlen == matches[j].len && ! strcmp (switches[i].part1, matches[j].str)) + if (xlen == matches[j].len + && ! strncmp (switches[i].part1, matches[j].str, xlen)) { mswitches[n_mswitches].str = matches[j].replace; mswitches[n_mswitches].len = matches[j].rep_len; @@ -6035,7 +6033,7 @@ default_arg (p, len) const char *p; int len; { - char *start, *end; + const char *start, *end; for (start = multilib_defaults; *start != '\0'; start = end+1) { @@ -6072,9 +6070,9 @@ default_arg (p, len) static void set_multilib_dir () { - char *p; + const char *p; unsigned int this_path_len; - char *this_path, *this_arg; + const char *this_path, *this_arg; int not_arg; int ok; @@ -6229,8 +6227,8 @@ set_multilib_dir () static void print_multilib_info () { - char *p = multilib_select; - char *last_path = 0, *this_path; + const char *p = multilib_select; + const char *last_path = 0, *this_path; int skip; unsigned int last_path_len = 0; @@ -6257,8 +6255,8 @@ print_multilib_info () with the '!' in either list. If any of the exclusion rules match all of its options with the select rule, we skip it. */ { - char *e = multilib_exclusions; - char *this_arg; + const char *e = multilib_exclusions; + const char *this_arg; while (*e != '\0') { @@ -6273,7 +6271,7 @@ print_multilib_info () /* Check the arguments. */ while (*e != ';') { - char *q; + const char *q; int mp = 0; if (*e == '\0') @@ -6297,7 +6295,7 @@ print_multilib_info () q = p + 1; while (*q != ';') { - char *arg; + const char *arg; int len = e - this_arg; if (*q == '\0') @@ -6356,12 +6354,12 @@ print_multilib_info () this one which does not require that default argument. */ if (! skip) { - char *q; + const char *q; q = p + 1; while (*q != ';') { - char *arg; + const char *arg; if (*q == '\0') abort (); @@ -6392,7 +6390,7 @@ print_multilib_info () if (! skip) { - char *p1; + const char *p1; for (p1 = last_path; p1 < p; p1++) putchar (*p1); @@ -6437,7 +6435,7 @@ print_multilib_info () if (multilib_extra && *multilib_extra) { int print_at = TRUE; - char *q; + const char *q; for (q = multilib_extra; *q != '\0'; q++) { |