From 0d95286fa914943fefb3e1a64ad2b8e7c8df1acb Mon Sep 17 00:00:00 2001 From: ghazi Date: Thu, 13 Sep 2001 14:37:29 +0000 Subject: [PATCH] * c-parse.in (yyerror): Const-ification and/or static-ization. * c-typeck.c (push_member_name): Likewise. * collect2.c (main): Likewise. * dbxout.c (dbxout_parms): Likewise. * diagnostic.c (format_with_decl): Likewise. * dwarf2out.c (output_ranges): Likewise. * dwarfout.c (fundamental_type_code): Likewise. * except.c (dw2_output_call_site_table): Likewise. * gcc.c (do_spec_1): Likewise. * genopinit.c (optabs): Likewise. * objc/objc-act.c (synth_id_with_class_suffix, start_class, gen_declaration_1, handle_impent): Likewise. * protoize.c (default_include, in_system_include_dir, abspath): Likewise. * sched-vis.c (visualize_stall_cycles): Likewise. * sdbout.c (plain_type_1, sdbout_end_function, sdbout_end_epilogue): Likewise. * varasm.c (decode_reg_name): Likewise. * 1750a.c (mod_regno_adjust): Likewise. * alpha.c (alpha_write_one_linkage, unicosmk_output_default_externs): Likewise. * arm.c (arm_condition_codes): Likewise. * arm.h (arm_condition_codes): Likewise. * avr.c (output_movsisf, encode_section_info): Likewise. * darwin.h (GEN_BINDER_NAME_FOR_STUB, GEN_SYMBOL_NAME_FOR_SYMBOL): Likewise. * i386.c (hi_reg_name, qi_reg_name, qi_high_reg_name): Likewise. * i386.h (hi_reg_name, qi_reg_name, qi_high_reg_name): Likewise. * m88k.c (output_function_profiler): Likewise. * mips.c (mips_output_conditional_branch): Likewise. * ns32k.c (ns32k_out_reg_names): Likewise. * ns32k.h (ns32k_out_reg_names): Likewise. * pj.c (pj_output_rval): Likewise. * rs6000.c (GEN_LOCAL_LABEL_FOR_SYMBOL): Likewise. * sparc.c (sparc_flat_function_prologue, sparc_flat_function_epilogue): Likewise. cp: * decl.c (warn_extern_redeclared_static, cp_make_fname_decl): Const-ification. * pt.c (tsubst_decl): Likewise. f: * bad.c (ffebad_finish): Const-ification and/or static-ization. * intrin.c (ffeintrin_cmp_name_): Likewise. * stc.c (ffestc_R904): Likewise. java: * expr.c (expand_invoke): Const-ification. * parse.y (patch_method_invocation): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@45581 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 40 ++++++++++++++++++++++++++++++++++++++++ gcc/c-parse.in | 2 +- gcc/c-typeck.c | 2 +- gcc/collect2.c | 16 ++++++++-------- gcc/config/1750a/1750a.c | 2 +- gcc/config/alpha/alpha.c | 4 ++-- gcc/config/arm/arm.c | 2 +- gcc/config/arm/arm.h | 1 - gcc/config/avr/avr.c | 4 ++-- gcc/config/darwin.h | 4 ++-- gcc/config/i386/i386.c | 6 +++--- gcc/config/i386/i386.h | 3 --- gcc/config/m88k/m88k.c | 2 +- gcc/config/mips/mips.c | 4 ++-- gcc/config/ns32k/ns32k.c | 2 +- gcc/config/ns32k/ns32k.h | 1 - gcc/config/pj/pj.c | 2 +- gcc/config/rs6000/rs6000.c | 2 +- gcc/config/sparc/sparc.c | 4 ++-- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/decl.c | 6 +++--- gcc/cp/pt.c | 2 +- gcc/dbxout.c | 2 +- gcc/diagnostic.c | 2 +- gcc/dwarf2out.c | 2 +- gcc/dwarfout.c | 4 ++-- gcc/except.c | 2 +- gcc/f/ChangeLog | 6 ++++++ gcc/f/bad.c | 2 +- gcc/f/intrin.c | 6 +++--- gcc/f/stc.c | 39 +++++++++++++-------------------------- gcc/gcc.c | 2 +- gcc/genopinit.c | 2 +- gcc/java/ChangeLog | 5 +++++ gcc/java/expr.c | 2 +- gcc/java/parse.y | 14 +++++++------- gcc/objc/objc-act.c | 16 ++++++++-------- gcc/protoize.c | 6 +++--- gcc/sched-vis.c | 2 +- gcc/sdbout.c | 4 ++-- gcc/varasm.c | 2 +- 41 files changed, 138 insertions(+), 99 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5b6feb5..f135bd0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,43 @@ +2001-09-13 Kaveh R. Ghazi + + * c-parse.in (yyerror): Const-ification and/or static-ization. + * c-typeck.c (push_member_name): Likewise. + * collect2.c (main): Likewise. + * dbxout.c (dbxout_parms): Likewise. + * diagnostic.c (format_with_decl): Likewise. + * dwarf2out.c (output_ranges): Likewise. + * dwarfout.c (fundamental_type_code): Likewise. + * except.c (dw2_output_call_site_table): Likewise. + * gcc.c (do_spec_1): Likewise. + * genopinit.c (optabs): Likewise. + * objc/objc-act.c (synth_id_with_class_suffix, start_class, + gen_declaration_1, handle_impent): Likewise. + * protoize.c (default_include, in_system_include_dir, abspath): + Likewise. + * sched-vis.c (visualize_stall_cycles): Likewise. + * sdbout.c (plain_type_1, sdbout_end_function, + sdbout_end_epilogue): Likewise. + * varasm.c (decode_reg_name): Likewise. + + * 1750a.c (mod_regno_adjust): Likewise. + * alpha.c (alpha_write_one_linkage, + unicosmk_output_default_externs): Likewise. + * arm.c (arm_condition_codes): Likewise. + * arm.h (arm_condition_codes): Likewise. + * avr.c (output_movsisf, encode_section_info): Likewise. + * darwin.h (GEN_BINDER_NAME_FOR_STUB, GEN_SYMBOL_NAME_FOR_SYMBOL): + Likewise. + * i386.c (hi_reg_name, qi_reg_name, qi_high_reg_name): Likewise. + * i386.h (hi_reg_name, qi_reg_name, qi_high_reg_name): Likewise. + * m88k.c (output_function_profiler): Likewise. + * mips.c (mips_output_conditional_branch): Likewise. + * ns32k.c (ns32k_out_reg_names): Likewise. + * ns32k.h (ns32k_out_reg_names): Likewise. + * pj.c (pj_output_rval): Likewise. + * rs6000.c (GEN_LOCAL_LABEL_FOR_SYMBOL): Likewise. + * sparc.c (sparc_flat_function_prologue, + sparc_flat_function_epilogue): Likewise. + 2001-09-13 Markus Werle Gerald Pfeifer diff --git a/gcc/c-parse.in b/gcc/c-parse.in index f629c18..b8871c5 100644 --- a/gcc/c-parse.in +++ b/gcc/c-parse.in @@ -3615,7 +3615,7 @@ yyerror (msgid) else if (last_token == CPP_CHAR || last_token == CPP_WCHAR) { unsigned int val = TREE_INT_CST_LOW (yylval.ttype); - const char *ell = (last_token == CPP_CHAR) ? "" : "L"; + const char *const ell = (last_token == CPP_CHAR) ? "" : "L"; if (val <= UCHAR_MAX && ISGRAPH (val)) error ("%s before %s'%c'", string, ell, val); else diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 444a104..9d2c8f4 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -4507,7 +4507,7 @@ push_member_name (decl) tree decl; { - const char *string + const char *const string = DECL_NAME (decl) ? IDENTIFIER_POINTER (DECL_NAME (decl)) : ""; PUSH_SPELLING (SPELLING_MEMBER, string, u.s); } diff --git a/gcc/collect2.c b/gcc/collect2.c index 44f7e3a..4877790 100644 --- a/gcc/collect2.c +++ b/gcc/collect2.c @@ -796,21 +796,21 @@ main (argc, argv) int argc; char *argv[]; { - const char *const ld_suffix = "ld"; + static const char *const ld_suffix = "ld"; const char *full_ld_suffix = ld_suffix; - const char *const real_ld_suffix = "real-ld"; - const char *const collect_ld_suffix = "collect-ld"; - const char *const nm_suffix = "nm"; + static const char *const real_ld_suffix = "real-ld"; + static const char *const collect_ld_suffix = "collect-ld"; + static const char *const nm_suffix = "nm"; const char *full_nm_suffix = nm_suffix; - const char *const gnm_suffix = "gnm"; + static const char *const gnm_suffix = "gnm"; const char *full_gnm_suffix = gnm_suffix; #ifdef LDD_SUFFIX - const char *const ldd_suffix = LDD_SUFFIX; + static const char *const ldd_suffix = LDD_SUFFIX; const char *full_ldd_suffix = ldd_suffix; #endif - const char *const strip_suffix = "strip"; + static const char *const strip_suffix = "strip"; const char *full_strip_suffix = strip_suffix; - const char *const gstrip_suffix = "gstrip"; + static const char *const gstrip_suffix = "gstrip"; const char *full_gstrip_suffix = gstrip_suffix; const char *arg; FILE *outf; diff --git a/gcc/config/1750a/1750a.c b/gcc/config/1750a/1750a.c index c1412bf..4856de2 100644 --- a/gcc/config/1750a/1750a.c +++ b/gcc/config/1750a/1750a.c @@ -304,7 +304,7 @@ mod_regno_adjust (instr, op) rtx *op; { static char outstr[40]; - const char *r = (!strncmp (instr, "dvr", 3) ? "r" : ""); + const char *const r = (!strncmp (instr, "dvr", 3) ? "r" : ""); int modregno_gcc = REGNO (op[3]), modregno_1750 = REGNO (op[0]) + 1; if (modregno_gcc == modregno_1750 diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c index 9fd33a0..d2d90d9 100644 --- a/gcc/config/alpha/alpha.c +++ b/gcc/config/alpha/alpha.c @@ -7795,7 +7795,7 @@ alpha_write_one_linkage (node, data) splay_tree_node node; void *data; { - const char *name = (const char *) node->key; + const char *const name = (const char *) node->key; struct alpha_links *links = (struct alpha_links *) node->value; FILE *stream = (FILE *) data; @@ -8498,7 +8498,7 @@ static void unicosmk_output_default_externs (file) FILE *file; { - static const char *externs[] = + static const char *const externs[] = { "__T3E_MISMATCH" }; int i; diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 4445583..1ad558e 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -283,7 +283,7 @@ rtx arm_target_insn; int arm_target_label; /* The condition codes of the ARM, and the inverse function. */ -const char *const arm_condition_codes[] = +static const char *const arm_condition_codes[] = { "eq", "ne", "cs", "cc", "mi", "pl", "vs", "vc", "hi", "ls", "ge", "lt", "gt", "le", "al", "nv" diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h index a3cc4f3..aa1c177 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -61,7 +61,6 @@ typedef enum arm_cond_code arm_cc; extern arm_cc arm_current_cc; -extern const char *const arm_condition_codes[]; #define ARM_INVERSE_CONDITION_CODE(X) ((arm_cc) (((int)X) ^ 1)) diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index a6cb331..5e9c172 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -2363,7 +2363,7 @@ output_movsisf(insn, operands, l) if (GET_CODE (src) == CONST_INT) { - const char *clr_op0 = + const char *const clr_op0 = AVR_ENHANCED ? (AS1 (clr,%A0) CR_TAB AS1 (clr,%B0) CR_TAB AS2 (movw,%C0,%A0)) @@ -4756,7 +4756,7 @@ encode_section_info (decl) && TREE_CODE (decl) == VAR_DECL && avr_progmem_p (decl)) { - const char *const dsec = ".progmem.data"; + static const char *const dsec = ".progmem.data"; DECL_SECTION_NAME (decl) = build_string (strlen (dsec), dsec); TREE_READONLY (decl) = 1; } diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h index 72c689b..54b669a 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -719,7 +719,7 @@ enum machopic_addr_class { #define GEN_BINDER_NAME_FOR_STUB(BUF,STUB,STUB_LENGTH) \ do { \ - const char *stub_ = (STUB); \ + const char *const stub_ = (STUB); \ char *buffer_ = (BUF); \ strcpy (buffer_, stub_); \ if (stub_[0] == '"') \ @@ -734,7 +734,7 @@ enum machopic_addr_class { #define GEN_SYMBOL_NAME_FOR_SYMBOL(BUF,SYMBOL,SYMBOL_LENGTH) \ do { \ - const char *symbol_ = (SYMBOL); \ + const char *const symbol_ = (SYMBOL); \ char *buffer_ = (BUF); \ if (name_needs_quotes (symbol_) && symbol_[0] != '"') \ { \ diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 81058ac..6caf854 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -361,9 +361,9 @@ static int use_fast_prologue_epilogue; #define AT_BP(mode) (gen_rtx_MEM ((mode), hard_frame_pointer_rtx)) -const char * const hi_reg_name[] = HI_REGISTER_NAMES; -const char * const qi_reg_name[] = QI_REGISTER_NAMES; -const char * const qi_high_reg_name[] = QI_HIGH_REGISTER_NAMES; +static const char *const hi_reg_name[] = HI_REGISTER_NAMES; /* names for 16 bit regs */ +static const char *const qi_reg_name[] = QI_REGISTER_NAMES; /* names for 8 bit regs (low) */ +static const char *const qi_high_reg_name[] = QI_HIGH_REGISTER_NAMES; /* names for 8 bit regs (high) */ /* Array of the smallest class containing reg number REGNO, indexed by REGNO. Used by REGNO_REG_CLASS in i386.h. */ diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index eb544c7..1a1715e 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -3095,9 +3095,6 @@ extern const char *ix86_branch_cost_string; /* values 1-5: see jump.c */ extern int ix86_regparm; /* ix86_regparm_string as a number */ extern int ix86_preferred_stack_boundary; /* preferred stack boundary alignment in bits */ extern int ix86_branch_cost; /* values 1-5: see jump.c */ -extern const char * const hi_reg_name[]; /* names for 16 bit regs */ -extern const char * const qi_reg_name[]; /* names for 8 bit regs (low) */ -extern const char * const qi_high_reg_name[]; /* names for 8 bit regs (high) */ extern enum reg_class const regclass_map[]; /* smalled class containing REGNO */ extern struct rtx_def *ix86_compare_op0; /* operand 0 for comparisons */ extern struct rtx_def *ix86_compare_op1; /* operand 1 for comparisons */ diff --git a/gcc/config/m88k/m88k.c b/gcc/config/m88k/m88k.c index 994994b..1de96f2 100644 --- a/gcc/config/m88k/m88k.c +++ b/gcc/config/m88k/m88k.c @@ -2407,7 +2407,7 @@ output_function_profiler (file, labelno, name, savep) { char label[256]; char dbi[256]; - const char *temp = (savep ? reg_names[2] : reg_names[10]); + const char *const temp = (savep ? reg_names[2] : reg_names[10]); /* Remember to update FUNCTION_PROFILER_LENGTH. */ diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index 5ac7be1..483cc23 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -9548,7 +9548,7 @@ mips_output_conditional_branch (insn, would otherwise; that way we skip the annulled instruction in the delay slot. */ - const char *target + const char *const target = ((mips_branch_likely || length == 16) ? ".+16" : ".+12"); char *c; @@ -9625,7 +9625,7 @@ mips_output_conditional_branch (insn, anything. */ /* The target of the reversed branch. */ - const char *target + const char *const target = ((mips_branch_likely || length == 20) ? ".+20" : ".+16"); const char *at_register = mips_reg_names[ASSEMBLER_SCRATCH_REGNUM]; const char *gp_register = mips_reg_names[PIC_OFFSET_TABLE_REGNUM]; diff --git a/gcc/config/ns32k/ns32k.c b/gcc/config/ns32k/ns32k.c index 9ad3b0c..b6bd0da 100644 --- a/gcc/config/ns32k/ns32k.c +++ b/gcc/config/ns32k/ns32k.c @@ -59,7 +59,7 @@ enum reg_class regclass_map[FIRST_PSEUDO_REGISTER] = FRAME_POINTER_REG, STACK_POINTER_REG }; -const char *const ns32k_out_reg_names[] = OUTPUT_REGISTER_NAMES; +static const char *const ns32k_out_reg_names[] = OUTPUT_REGISTER_NAMES; static rtx gen_indexed_expr PARAMS ((rtx, rtx, rtx)); static const char *singlemove_string PARAMS ((rtx *)); diff --git a/gcc/config/ns32k/ns32k.h b/gcc/config/ns32k/ns32k.h index 58937d1..0037920 100644 --- a/gcc/config/ns32k/ns32k.h +++ b/gcc/config/ns32k/ns32k.h @@ -1441,7 +1441,6 @@ do { \ #define PRINT_OPERAND_ADDRESS(FILE, ADDR) print_operand_address(FILE, ADDR) extern unsigned int ns32k_reg_class_contents[N_REG_CLASSES][1]; -extern const char *const ns32k_out_reg_names[]; extern enum reg_class regclass_map[]; /* smallest class containing REGNO */ /* diff --git a/gcc/config/pj/pj.c b/gcc/config/pj/pj.c index 18525ce..6536627 100644 --- a/gcc/config/pj/pj.c +++ b/gcc/config/pj/pj.c @@ -400,7 +400,7 @@ pj_output_rval (op, mode, outer_op) } else if (tab && tab->handlers[mode].insn_code != CODE_FOR_nothing) { - const char *template = + const char *const template = (const char *) insn_data[tab->handlers[mode].insn_code].output; if (code == NEG) pj_printf (template, 0, XEXP (op, 0)); diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 896842c..0fc0446 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -8616,7 +8616,7 @@ output_call (insn, call_dest, operand_number) #define GEN_LOCAL_LABEL_FOR_SYMBOL(BUF,SYMBOL,LENGTH,N) \ do { \ - const char *symbol_ = (SYMBOL); \ + const char *const symbol_ = (SYMBOL); \ char *buffer_ = (BUF); \ if (symbol_[0] == '"') \ { \ diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index 3b11a3f..27cd5b3 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -6702,7 +6702,7 @@ sparc_flat_function_prologue (file, size) { unsigned int reg_offset = current_frame_info.reg_offset; const char *const fp_str = reg_names[FRAME_POINTER_REGNUM]; - const char *const t1_str = "%g1"; + static const char *const t1_str = "%g1"; /* Things get a little tricky if local variables take up more than ~4096 bytes and outgoing arguments take up more than ~4096 bytes. When that @@ -6887,7 +6887,7 @@ sparc_flat_function_epilogue (file, size) unsigned HOST_WIDE_INT size1; const char *const sp_str = reg_names[STACK_POINTER_REGNUM]; const char *const fp_str = reg_names[FRAME_POINTER_REGNUM]; - const char *const t1_str = "%g1"; + static const char *const t1_str = "%g1"; /* In the reload sequence, we don't need to fill the load delay slots for most of the loads, also see if we can fill the final diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f5ce21f..ef48dc3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2001-09-13 Kaveh R. Ghazi + + * decl.c (warn_extern_redeclared_static, cp_make_fname_decl): + Const-ification. + * pt.c (tsubst_decl): Likewise. + 2001-09-12 Kaveh R. Ghazi * decl2.c (lang_f_options): Const-ification. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 9020bb3..9244272 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -3028,9 +3028,9 @@ static void warn_extern_redeclared_static (newdecl, olddecl) tree newdecl, olddecl; { - static const char *explicit_extern_static_warning + static const char *const explicit_extern_static_warning = "`%D' was declared `extern' and later `static'"; - static const char *implicit_extern_static_warning + static const char *const implicit_extern_static_warning = "`%D' was declared implicitly `extern' and later `static'"; tree name; @@ -6574,7 +6574,7 @@ cp_make_fname_decl (id, type_dep) tree id; int type_dep; { - const char *name = (type_dep && processing_template_decl + const char *const name = (type_dep && processing_template_decl ? NULL : fname_as_string (type_dep)); tree init = cp_fname_init (name); tree decl = build_decl (VAR_DECL, id, TREE_TYPE (init)); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 960ef44..05ce365 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -5992,7 +5992,7 @@ tsubst_decl (t, args, type) /* For __PRETTY_FUNCTION__ we have to adjust the initializer. */ if (DECL_PRETTY_FUNCTION_P (r)) { - const char *name = (*decl_printable_name) + const char *const name = (*decl_printable_name) (current_function_decl, 2); DECL_INITIAL (r) = cp_fname_init (name); TREE_TYPE (r) = TREE_TYPE (DECL_INITIAL (r)); diff --git a/gcc/dbxout.c b/gcc/dbxout.c index 4e7f70d..bfb6b0e 100644 --- a/gcc/dbxout.c +++ b/gcc/dbxout.c @@ -2566,7 +2566,7 @@ dbxout_parms (parms) living on the stack. DECL_RTL looks like (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it could look like (MEM (MEM (REG))). */ - const char *decl_name = (DECL_NAME (parms) + const char *const decl_name = (DECL_NAME (parms) ? IDENTIFIER_POINTER (DECL_NAME (parms)) : "(anon)"); if (GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 0)) == REG) diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index 700dd31..d0ad847 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -866,7 +866,7 @@ format_with_decl (buffer, decl) if (*p == '%') /* Print the name. */ { - const char *n = (DECL_NAME (decl) + const char *const n = (DECL_NAME (decl) ? (*decl_printable_name) (decl, 2) : _("((anonymous))")); output_add_string (buffer, n); diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index d61f77f..ca8a736 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -6508,7 +6508,7 @@ static void output_ranges () { register unsigned i; - const char *const start_fmt = "Offset 0x%x"; + static const char *const start_fmt = "Offset 0x%x"; const char *fmt = start_fmt; for (i = 0; i < ranges_table_in_use; ++i) diff --git a/gcc/dwarfout.c b/gcc/dwarfout.c index cdff117..d51d575 100644 --- a/gcc/dwarfout.c +++ b/gcc/dwarfout.c @@ -1849,7 +1849,7 @@ fundamental_type_code (type) && DECL_NAME (TYPE_NAME (type)) != 0 && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE) { - const char *name = + const char *const name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))); if (!strcmp (name, "unsigned char")) @@ -1908,7 +1908,7 @@ fundamental_type_code (type) && DECL_NAME (TYPE_NAME (type)) != 0 && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE) { - const char *name = + const char *const name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))); /* Note that here we can run afowl of a serious bug in "classic" diff --git a/gcc/except.c b/gcc/except.c index 9aad8f5..90423a7 100644 --- a/gcc/except.c +++ b/gcc/except.c @@ -3409,7 +3409,7 @@ sjlj_size_of_call_site_table () static void dw2_output_call_site_table () { - const char *function_start_lab + const char *const function_start_lab = IDENTIFIER_POINTER (current_function_func_begin_label); int n = cfun->eh->call_site_data_used; int i; diff --git a/gcc/f/ChangeLog b/gcc/f/ChangeLog index 5c6f349..666001d 100644 --- a/gcc/f/ChangeLog +++ b/gcc/f/ChangeLog @@ -1,3 +1,9 @@ +Thu Sep 13 10:33:27 2001 Kaveh R. Ghazi + + * bad.c (ffebad_finish): Const-ification and/or static-ization. + * intrin.c (ffeintrin_cmp_name_): Likewise. + * stc.c (ffestc_R904): Likewise. + Wed Sep 12 12:09:04 2001 Kaveh R. Ghazi * bld.c (ffebld_op_string_): Const-ification. diff --git a/gcc/f/bad.c b/gcc/f/bad.c index 930daf9..0ecaf74 100644 --- a/gcc/f/bad.c +++ b/gcc/f/bad.c @@ -349,7 +349,7 @@ void ffebad_finish () { #define MAX_SPACES 132 - static const char *spaces + static const char *const spaces = "...>\ \040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\ \040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\ diff --git a/gcc/f/intrin.c b/gcc/f/intrin.c index 0bc6d0e..31ebd96 100644 --- a/gcc/f/intrin.c +++ b/gcc/f/intrin.c @@ -1165,9 +1165,9 @@ ffeintrin_check_any_ (ffebld arglist) static int ffeintrin_cmp_name_ (const void *name, const void *intrinsic) { - const char *uc = ((const struct _ffeintrin_name_ *) intrinsic)->name_uc; - const char *lc = ((const struct _ffeintrin_name_ *) intrinsic)->name_lc; - const char *ic = ((const struct _ffeintrin_name_ *) intrinsic)->name_ic; + const char *const uc = ((const struct _ffeintrin_name_ *) intrinsic)->name_uc; + const char *const lc = ((const struct _ffeintrin_name_ *) intrinsic)->name_lc; + const char *const ic = ((const struct _ffeintrin_name_ *) intrinsic)->name_ic; return ffesrc_strcmp_2c (ffe_case_intrin (), name, uc, lc, ic); } diff --git a/gcc/f/stc.c b/gcc/f/stc.c index 8a7efa6..1f17766 100644 --- a/gcc/f/stc.c +++ b/gcc/f/stc.c @@ -10203,8 +10203,7 @@ ffestc_R904 () { int i; int expect_file; - const char *const status_strs[] - = + static const char *const status_strs[] = { "New", "Old", @@ -10212,29 +10211,25 @@ ffestc_R904 () "Scratch", "Unknown" }; - const char *const access_strs[] - = + static const char *const access_strs[] = { "Append", "Direct", "Keyed", "Sequential" }; - const char *const blank_strs[] - = + static const char *const blank_strs[] = { "Null", "Zero" }; - const char *const carriagecontrol_strs[] - = + static const char *const carriagecontrol_strs[] = { "Fortran", "List", "None" }; - const char *const dispose_strs[] - = + static const char *const dispose_strs[] = { "Delete", "Keep", @@ -10244,42 +10239,36 @@ ffestc_R904 () "Submit", "Submit/Delete" }; - const char *const form_strs[] - = + static const char *const form_strs[] = { "Formatted", "Unformatted" }; - const char *const organization_strs[] - = + static const char *const organization_strs[] = { "Indexed", "Relative", "Sequential" }; - const char *const position_strs[] - = + static const char *const position_strs[] = { "Append", "AsIs", "Rewind" }; - const char *const action_strs[] - = + static const char *const action_strs[] = { "Read", "ReadWrite", "Write" }; - const char *const delim_strs[] - = + static const char *const delim_strs[] = { "Apostrophe", "None", "Quote" }; - const char *const recordtype_strs[] - = + static const char *const recordtype_strs[] = { "Fixed", "Segmented", @@ -10288,8 +10277,7 @@ ffestc_R904 () "Stream_LF", "Variable" }; - const char *const pad_strs[] - = + static const char *const pad_strs[] = { "No", "Yes" @@ -10458,8 +10446,7 @@ ffestc_R904 () void ffestc_R907 () { - const char *const status_strs[] - = + static const char *const status_strs[] = { "Delete", "Keep", diff --git a/gcc/gcc.c b/gcc/gcc.c index 99a6c3d..9b6c1e5 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -4580,7 +4580,7 @@ do_spec_1 (spec, inswitch, soft_matched_part) case 'C': { - const char* spec + const char *const spec = (input_file_compiler->cpp_spec ? input_file_compiler->cpp_spec : cpp_spec); diff --git a/gcc/genopinit.c b/gcc/genopinit.c index ad17d10..3907b20 100644 --- a/gcc/genopinit.c +++ b/gcc/genopinit.c @@ -56,7 +56,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA used for comparisons. In that case, $c and $C are the lower-case and upper-case forms of the comparison, respectively. */ -const char * const optabs[] = +static const char * const optabs[] = { "extendtab[$B][$A][0] = CODE_FOR_$(extend$a$b2$)", "extendtab[$B][$A][1] = CODE_FOR_$(zero_extend$a$b2$)", "fixtab[$A][$B][0] = CODE_FOR_$(fix$F$a$I$b2$)", diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index ba4a3b2..95aafb3 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,8 @@ +2001-09-13 Kaveh R. Ghazi + + * expr.c (expand_invoke): Const-ification. + * parse.y (patch_method_invocation): Likewise. + 2001-09-12 Kaveh R. Ghazi * gjavah.c (cxx_keywords): Const-ification. diff --git a/gcc/java/expr.c b/gcc/java/expr.c index d1cc19e..ff0a327 100644 --- a/gcc/java/expr.c +++ b/gcc/java/expr.c @@ -1916,7 +1916,7 @@ expand_invoke (opcode, method_ref_index, nargs) tree method_name = COMPONENT_REF_NAME (¤t_jcf->cpool, method_ref_index); tree self_type = get_class_constant (current_jcf, COMPONENT_REF_CLASS_INDEX(¤t_jcf->cpool, method_ref_index)); - const char *self_name + const char *const self_name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (self_type))); tree call, func, method, arg_list, method_type; tree check = NULL_TREE; diff --git a/gcc/java/parse.y b/gcc/java/parse.y index 62f231c..ee528dc 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -10308,15 +10308,15 @@ patch_method_invocation (patch, primary, where, from_super, /* Calls to clone() on array types are permitted as a special-case. */ && !is_array_clone_call) { - const char *fct_name = IDENTIFIER_POINTER (DECL_NAME (list)); - const char *access = + const char *const fct_name = IDENTIFIER_POINTER (DECL_NAME (list)); + const char *const access = java_accstring_lookup (get_access_flags_from_decl (list)); - const char *klass = + const char *const klass = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (list)))); - const char *refklass = + const char *const refklass = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))); - const char *what = (DECL_CONSTRUCTOR_P (list) - ? "constructor" : "method"); + const char *const what = (DECL_CONSTRUCTOR_P (list) + ? "constructor" : "method"); /* FIXME: WFL yields the wrong message here but I don't know what else to use. */ parse_error_context (wfl, @@ -14828,7 +14828,7 @@ array_constructor_check_entry (type, entry) /* Check and report errors */ if (!new_value) { - const char *msg = (!valid_cast_to_p (type_value, type) ? + const char *const msg = (!valid_cast_to_p (type_value, type) ? "Can't" : "Explicit cast needed to"); if (!array_type_string) array_type_string = xstrdup (lang_printable_name (type, 1)); diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 358d0ea..1a2cd91 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -4618,7 +4618,7 @@ synth_id_with_class_suffix (preamble, ctxt) if (TREE_CODE (ctxt) == CLASS_IMPLEMENTATION_TYPE || TREE_CODE (ctxt) == CLASS_INTERFACE_TYPE) { - const char *class_name + const char *const class_name = IDENTIFIER_POINTER (CLASS_NAME (implementation_context)); string = (char *) alloca (strlen (preamble) + strlen (class_name) + 3); sprintf (string, "%s_%s", preamble, @@ -4628,9 +4628,9 @@ synth_id_with_class_suffix (preamble, ctxt) || TREE_CODE (ctxt) == CATEGORY_INTERFACE_TYPE) { /* We have a category. */ - const char *class_name + const char *const class_name = IDENTIFIER_POINTER (CLASS_NAME (implementation_context)); - const char *class_super_name + const char *const class_super_name = IDENTIFIER_POINTER (CLASS_SUPER_NAME (implementation_context)); string = (char *) alloca (strlen (preamble) + strlen (class_name) @@ -6252,7 +6252,7 @@ start_class (code, class_name, super_name, protocol_list) && (super_name != CLASS_SUPER_NAME (implementation_template))) { tree previous_name = CLASS_SUPER_NAME (implementation_template); - const char *name = + const char *const name = previous_name ? IDENTIFIER_POINTER (previous_name) : ""; error ("conflicting super class name `%s'", IDENTIFIER_POINTER (super_name)); @@ -8046,7 +8046,7 @@ gen_declaration_1 (atype_or_adecl, buf) || TREE_CODE (atype_or_adecl) == PARM_DECL || TREE_CODE (atype_or_adecl) == FUNCTION_DECL) { - const char *decl_name = + const char *const decl_name = (DECL_NAME (atype_or_adecl) ? IDENTIFIER_POINTER (DECL_NAME (atype_or_adecl)) : ""); @@ -8506,7 +8506,7 @@ handle_impent (impent) if (TREE_CODE (impent->imp_context) == CLASS_IMPLEMENTATION_TYPE) { - const char *class_name = + const char *const class_name = IDENTIFIER_POINTER (CLASS_NAME (impent->imp_context)); string = (char *) alloca (strlen (class_name) + 30); @@ -8516,9 +8516,9 @@ handle_impent (impent) } else if (TREE_CODE (impent->imp_context) == CATEGORY_IMPLEMENTATION_TYPE) { - const char *class_name = + const char *const class_name = IDENTIFIER_POINTER (CLASS_NAME (impent->imp_context)); - const char *class_super_name = + const char *const class_super_name = IDENTIFIER_POINTER (CLASS_SUPER_NAME (impent->imp_context)); string = (char *) alloca (strlen (class_name) diff --git a/gcc/protoize.c b/gcc/protoize.c index 63b6935..a0c1d19 100644 --- a/gcc/protoize.c +++ b/gcc/protoize.c @@ -205,7 +205,7 @@ static const int hash_mask = (HASH_TABLE_SIZE - 1); #define LOCAL_INCLUDE_DIR "/usr/local/include" #endif -struct default_include { const char *const fname; +static const struct default_include { const char *const fname; const char *const component; int x1, x2; } include_defaults[] #ifdef INCLUDE_DEFAULTS @@ -743,7 +743,7 @@ static int in_system_include_dir (path) const char *path; { - struct default_include *p; + const struct default_include *p; if (! is_abspath (path)) abort (); /* Must be an absolutized filename. */ @@ -1195,7 +1195,7 @@ abspath (cwd, rel_filename) const char *rel_filename; { /* Setup the current working directory as needed. */ - const char *cwd2 = (cwd) ? cwd : cwd_buffer; + const char *const cwd2 = (cwd) ? cwd : cwd_buffer; char *const abs_buffer = (char *) alloca (strlen (cwd2) + strlen (rel_filename) + 2); char *endp = abs_buffer; diff --git a/gcc/sched-vis.c b/gcc/sched-vis.c index 95aa8af..75007ef 100644 --- a/gcc/sched-vis.c +++ b/gcc/sched-vis.c @@ -905,7 +905,7 @@ void visualize_stall_cycles (stalls) int stalls; { - const char *const prefix = ";; "; + static const char *const prefix = ";; "; const char *suffix = "\n"; char *p; diff --git a/gcc/sdbout.c b/gcc/sdbout.c index 556423e..2b7280e 100644 --- a/gcc/sdbout.c +++ b/gcc/sdbout.c @@ -516,7 +516,7 @@ plain_type_1 (type, level) && DECL_NAME (TYPE_NAME (type)) != 0 && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE) { - const char *name + const char *const name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))); if (!strcmp (name, "char")) @@ -1679,7 +1679,7 @@ sdbout_end_function (line) static void sdbout_end_epilogue () { - const char *name + const char *const name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl)); #ifdef PUT_SDB_EPILOGUE_END diff --git a/gcc/varasm.c b/gcc/varasm.c index b4d4d6d..f00b596 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -747,7 +747,7 @@ decode_reg_name (asmspec) #ifdef ADDITIONAL_REGISTER_NAMES { - static struct { const char *const name; int number; } table[] + static const struct { const char *const name; const int number; } table[] = ADDITIONAL_REGISTER_NAMES; for (i = 0; i < (int) ARRAY_SIZE (table); i++) -- 2.7.4