From 741ac903839251f16d331f4d1c11f444eaec684f Mon Sep 17 00:00:00 2001 From: "Kaveh R. Ghazi" Date: Wed, 25 Jul 2007 19:06:06 +0000 Subject: [PATCH] c-common.c (fname_as_string, [...]): Constify. * c-common.c (fname_as_string, c_type_hash): Constify. * c-typeck.c (free_all_tagged_tu_seen_up_to): Likewise. * cgraph.c (edge_hash, edge_eq): Likewise. * dwarf2out.c (decl_die_table_eq, decl_loc_table_eq): Likewise. * emit-rtl.c (mem_attrs_htab_eq, reg_attrs_htab_hash, reg_attrs_htab_eq): Likewise. * except.c (t2r_eq, t2r_hash, ttypes_filter_eq, ehl_hash, ehl_eq): Likewise. * genautomata.c (const_reserv_sets_t, const_unit_decl_t, const_decl_t, const_state_t, const_automata_list_el_t): New. (first_out_arc, DECL_UNIT, DECL_BYPASS, DECL_AUTOMATON, DECL_EXCL, DECL_PRESENCE, DECL_ABSENCE, DECL_RESERV, DECL_INSN_RESERV, automaton_decl_hash, automaton_decl_eq_p, insn_decl_hash, insn_decl_eq_p, decl_hash, decl_eq_p, alt_state_cmp, reserv_sets_cmp, reserv_sets_eq, state_hash, state_eq_p, automata_list_hash, automata_list_eq_p, compare_states_for_equiv, compare_max_occ_cycle_nums, out_state_arcs_num, compare_transition_els_num, units_cmp, state_reservs_cmp): Constify. * genmodes.c (cmp_modes): Likewise. * ggc-common.c (saving_htab_hash, saving_htab_eq): Likewise. * gimplify.c (compare_case_labels): Likewise. * ipa-type-escape.c (get_name_of_type, type_brand_s): Likewise. * loop-unroll.c (si_info_hash, ve_info_hash): Likewise. * matrix-reorg.c (mtt_info_hash): Likewise. * postreload-gcse.c (hash_expr_for_htab, expr_equiv_p): Likewise. * rtl-factoring.c (const_p_hash_bucket, const_p_hash_elem): New. (htab_hash_bucket, htab_hash_elem): Constify. * tree-browser.c (TB_parent_eq): Likewise. * tree-scalar-evolution.c (hash_scev_info): Likewise. * tree-ssa-alias.c (sort_tags_by_id): Likewise. * tree-ssa-coalesce.c (const_coalesce_pair_p): New. (coalesce_pair_map_hash, coalesce_pair_map_eq, compare_pairs): Constify. * tree-ssa-dom.c (avail_expr_hash, avail_expr_eq): Likewise. * tree-ssa-pre.c (const_expr_pred_trans_t): New. (expr_pred_trans_hash, expr_pred_trans_eq): Constify. * tree-ssa-sccvn.c (const_vn_binary_op_t, const_vn_unary_op_t, const_vn_phi_t, const_vn_reference_op_t, const_vn_reference_t): New. (vn_reference_op_eq, vn_reference_hash, vn_reference_eq, vn_unary_op_hash, vn_unary_op_eq, vn_binary_op_hash, vn_binary_op_eq, vn_phi_hash, vn_phi_eq): Constify. * tree-ssa-threadupdate.c (redirection_data_hash, redirection_data_eq): Likewise. * tree-ssa-uncprop.c (equiv_hash, equiv_eq): Likewise. * tree-ssa.c (var_ann_eq): Likewise. * tree-vrp.c (compare_case_labels): Likewise. * tree.c (int_cst_hash_hash, int_cst_hash_eq, tree_map_base_marked_p, type_hash_marked_p, tree_check_failed, tree_not_check_failed, tree_class_check_failed, tree_range_check_failed, tree_not_class_check_failed, omp_clause_check_failed, omp_clause_range_check_failed, tree_contains_struct_check_failed, tree_operand_check_failed): Likewise. * tree.h (tree_contains_struct_check_failed, tree_check_failed, tree_not_check_failed, tree_class_check_failed, tree_range_check_failed, tree_not_class_check_failed, tree_operand_check_failed, omp_clause_operand_check_failed, tree_operand_length): Likewise. * var-tracking.c (const_variable): New. (variable_htab_hash, variable_htab_eq): Constify. * varasm.c (const_desc_hash): Likewise. cp: * decl.c (typename_hash, typename_compare): Constify. * mangle.c (hash_type, compare_type): Likewise. * pt.c (eq_local_specializations, hash_local_specialization): Likewise. * tree.c (cplus_array_hash, cplus_array_compare, list_hash_eq, list_hash): Likewise. * typeck2.c (pat_compare): Likewise. fortran: * gfortran.h (generate_isocbinding_symbol): Constify. * symbol.c (gen_special_c_interop_ptr, gen_cptr_param, generate_isocbinding_symbol): Likewise. java: * class.c (java_treetreehash_hash, java_treetreehash_compare): Constify. * expr.c (type_assertion_eq): Likewise. * jcf-io.c (compare_path): Likewise. * jcf-parse.c (cmpstringp): Likewise. * verify-impl.c (get_one_type, compute_argument_types, compute_return_type): Likewise. objc: * objc-act.c (volatilized_hash, volatilized_eq, string_hash, string_eq): Constify. From-SVN: r126925 --- gcc/ChangeLog | 66 +++++++++++++++++++ gcc/c-common.c | 4 +- gcc/c-typeck.c | 4 +- gcc/cgraph.c | 4 +- gcc/cp/ChangeLog | 10 +++ gcc/cp/decl.c | 9 +-- gcc/cp/mangle.c | 4 +- gcc/cp/pt.c | 4 +- gcc/cp/tree.c | 12 ++-- gcc/cp/typeck2.c | 4 +- gcc/dwarf2out.c | 4 +- gcc/emit-rtl.c | 10 +-- gcc/except.c | 20 +++--- gcc/fortran/ChangeLog | 6 ++ gcc/fortran/gfortran.h | 2 +- gcc/fortran/symbol.c | 12 ++-- gcc/genautomata.c | 127 +++++++++++++++++++----------------- gcc/genmodes.c | 4 +- gcc/ggc-common.c | 4 +- gcc/gimplify.c | 4 +- gcc/ipa-type-escape.c | 14 ++-- gcc/java/ChangeLog | 10 +++ gcc/java/class.c | 8 ++- gcc/java/expr.c | 4 +- gcc/java/jcf-io.c | 2 +- gcc/java/jcf-parse.c | 2 +- gcc/java/verify-impl.c | 8 +-- gcc/loop-unroll.c | 4 +- gcc/matrix-reorg.c | 2 +- gcc/objc/ChangeLog | 5 ++ gcc/objc/objc-act.c | 12 ++-- gcc/postreload-gcse.c | 6 +- gcc/rtl-factoring.c | 6 +- gcc/tree-browser.c | 4 +- gcc/tree-scalar-evolution.c | 2 +- gcc/tree-ssa-alias.c | 4 +- gcc/tree-ssa-coalesce.c | 12 ++-- gcc/tree-ssa-dom.c | 16 ++--- gcc/tree-ssa-pre.c | 7 +- gcc/tree-ssa-sccvn.c | 33 ++++++---- gcc/tree-ssa-threadupdate.c | 6 +- gcc/tree-ssa-uncprop.c | 6 +- gcc/tree-ssa.c | 2 +- gcc/tree-vrp.c | 4 +- gcc/tree.c | 39 +++++------ gcc/tree.h | 20 +++--- gcc/var-tracking.c | 7 +- gcc/varasm.c | 2 +- 48 files changed, 339 insertions(+), 222 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ba929443a22..6b01c6a3f17 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,69 @@ +2007-07-25 Kaveh R. Ghazi + + * c-common.c (fname_as_string, c_type_hash): Constify. + * c-typeck.c (free_all_tagged_tu_seen_up_to): Likewise. + * cgraph.c (edge_hash, edge_eq): Likewise. + * dwarf2out.c (decl_die_table_eq, decl_loc_table_eq): Likewise. + * emit-rtl.c (mem_attrs_htab_eq, reg_attrs_htab_hash, + reg_attrs_htab_eq): Likewise. + * except.c (t2r_eq, t2r_hash, ttypes_filter_eq, ehl_hash, ehl_eq): + Likewise. + * genautomata.c (const_reserv_sets_t, const_unit_decl_t, + const_decl_t, const_state_t, const_automata_list_el_t): New. + (first_out_arc, DECL_UNIT, DECL_BYPASS, DECL_AUTOMATON, DECL_EXCL, + DECL_PRESENCE, DECL_ABSENCE, DECL_RESERV, DECL_INSN_RESERV, + automaton_decl_hash, automaton_decl_eq_p, insn_decl_hash, + insn_decl_eq_p, decl_hash, decl_eq_p, alt_state_cmp, + reserv_sets_cmp, reserv_sets_eq, state_hash, state_eq_p, + automata_list_hash, automata_list_eq_p, compare_states_for_equiv, + compare_max_occ_cycle_nums, out_state_arcs_num, + compare_transition_els_num, units_cmp, state_reservs_cmp): + Constify. + * genmodes.c (cmp_modes): Likewise. + * ggc-common.c (saving_htab_hash, saving_htab_eq): Likewise. + * gimplify.c (compare_case_labels): Likewise. + * ipa-type-escape.c (get_name_of_type, type_brand_s): Likewise. + * loop-unroll.c (si_info_hash, ve_info_hash): Likewise. + * matrix-reorg.c (mtt_info_hash): Likewise. + * postreload-gcse.c (hash_expr_for_htab, expr_equiv_p): Likewise. + * rtl-factoring.c (const_p_hash_bucket, const_p_hash_elem): New. + (htab_hash_bucket, htab_hash_elem): Constify. + * tree-browser.c (TB_parent_eq): Likewise. + * tree-scalar-evolution.c (hash_scev_info): Likewise. + * tree-ssa-alias.c (sort_tags_by_id): Likewise. + * tree-ssa-coalesce.c (const_coalesce_pair_p): New. + (coalesce_pair_map_hash, coalesce_pair_map_eq, compare_pairs): + Constify. + * tree-ssa-dom.c (avail_expr_hash, avail_expr_eq): Likewise. + * tree-ssa-pre.c (const_expr_pred_trans_t): New. + (expr_pred_trans_hash, expr_pred_trans_eq): Constify. + * tree-ssa-sccvn.c (const_vn_binary_op_t, const_vn_unary_op_t, + const_vn_phi_t, const_vn_reference_op_t, const_vn_reference_t): + New. + (vn_reference_op_eq, vn_reference_hash, vn_reference_eq, + vn_unary_op_hash, vn_unary_op_eq, vn_binary_op_hash, + vn_binary_op_eq, vn_phi_hash, vn_phi_eq): Constify. + * tree-ssa-threadupdate.c (redirection_data_hash, + redirection_data_eq): Likewise. + * tree-ssa-uncprop.c (equiv_hash, equiv_eq): Likewise. + * tree-ssa.c (var_ann_eq): Likewise. + * tree-vrp.c (compare_case_labels): Likewise. + * tree.c (int_cst_hash_hash, int_cst_hash_eq, + tree_map_base_marked_p, type_hash_marked_p, tree_check_failed, + tree_not_check_failed, tree_class_check_failed, + tree_range_check_failed, tree_not_class_check_failed, + omp_clause_check_failed, omp_clause_range_check_failed, + tree_contains_struct_check_failed, tree_operand_check_failed): + Likewise. + * tree.h (tree_contains_struct_check_failed, tree_check_failed, + tree_not_check_failed, tree_class_check_failed, + tree_range_check_failed, tree_not_class_check_failed, + tree_operand_check_failed, omp_clause_operand_check_failed, + tree_operand_length): Likewise. + * var-tracking.c (const_variable): New. + (variable_htab_hash, variable_htab_eq): Constify. + * varasm.c (const_desc_hash): Likewise. + 2007-07-25 Kaveh R. Ghazi * expr.c (handled_component_p): Constify. diff --git a/gcc/c-common.c b/gcc/c-common.c index c9874d23ccd..764a50f011e 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -780,7 +780,7 @@ fname_as_string (int pretty_p) if (cpp_interpret_string (parse_in, &strname, 1, &cstr, false)) { XDELETEVEC (namep); - return (char *) cstr.text; + return (const char *) cstr.text; } } else @@ -3011,7 +3011,7 @@ c_type_hash (const void *p) { int i = 0; int shift, size; - tree t = (tree) p; + const_tree const t = (const_tree) p; tree t2; switch (TREE_CODE (t)) { diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index f4b5560eed3..cb1f23b4643 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -1024,8 +1024,8 @@ free_all_tagged_tu_seen_up_to (const struct tagged_tu_seen_cache *tu_til) const struct tagged_tu_seen_cache *tu = tagged_tu_seen_base; while (tu != tu_til) { - const struct tagged_tu_seen_cache *tu1 - = (const struct tagged_tu_seen_cache*)tu; + const struct tagged_tu_seen_cache *const tu1 + = (const struct tagged_tu_seen_cache *) tu; tu = tu1->next; free ((void *)tu1); } diff --git a/gcc/cgraph.c b/gcc/cgraph.c index 87114e2ff13..422f4425e06 100644 --- a/gcc/cgraph.c +++ b/gcc/cgraph.c @@ -246,7 +246,7 @@ cgraph_node_for_asm (tree asmname) static hashval_t edge_hash (const void *x) { - return htab_hash_pointer (((struct cgraph_edge *) x)->call_stmt); + return htab_hash_pointer (((const struct cgraph_edge *) x)->call_stmt); } /* Return nonzero if decl_id of die_struct X is the same as UID of decl *Y. */ @@ -254,7 +254,7 @@ edge_hash (const void *x) static int edge_eq (const void *x, const void *y) { - return ((struct cgraph_edge *) x)->call_stmt == y; + return ((const struct cgraph_edge *) x)->call_stmt == y; } /* Return callgraph edge representing CALL_EXPR statement. */ diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 456e5878790..cc423ede4ed 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +2007-07-25 Kaveh R. Ghazi + + * decl.c (typename_hash, typename_compare): Constify. + * mangle.c (hash_type, compare_type): Likewise. + * pt.c (eq_local_specializations, hash_local_specialization): + Likewise. + * tree.c (cplus_array_hash, cplus_array_compare, list_hash_eq, + list_hash): Likewise. + * typeck2.c (pat_compare): Likewise. + 2007-07-24 Nathan Sidwell * method.c (implicitly_declare_fn): Increase alignment if member diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index e3c70a5c439..3262a310ca3 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -2716,7 +2716,7 @@ static hashval_t typename_hash (const void* k) { hashval_t hash; - tree t = (tree) k; + const_tree const t = (const_tree) k; hash = (htab_hash_pointer (TYPE_CONTEXT (t)) ^ htab_hash_pointer (DECL_NAME (TYPE_NAME (t)))); @@ -2738,11 +2738,8 @@ typedef struct typename_info { static int typename_compare (const void * k1, const void * k2) { - tree t1; - const typename_info *t2; - - t1 = (tree) k1; - t2 = (const typename_info *) k2; + const_tree const t1 = (const_tree) k1; + const typename_info *const t2 = (const typename_info *) k2; return (DECL_NAME (TYPE_NAME (t1)) == t2->name && TYPE_CONTEXT (t1) == t2->scope diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 5452f6cce79..d708a2bf1f7 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -2836,7 +2836,7 @@ static GTY ((param_is (union tree_node))) htab_t conv_type_names; static hashval_t hash_type (const void *val) { - return (hashval_t) TYPE_UID (TREE_TYPE ((tree) val)); + return (hashval_t) TYPE_UID (TREE_TYPE ((const_tree) val)); } /* Compare VAL1 (a node in the table) with VAL2 (a TYPE). */ @@ -2844,7 +2844,7 @@ hash_type (const void *val) static int compare_type (const void *val1, const void *val2) { - return TREE_TYPE ((tree) val1) == (tree) val2; + return TREE_TYPE ((const_tree) val1) == (const_tree) val2; } /* Return an identifier for the mangled unqualified name for a diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 86b8eee6a10..fc5af163e1c 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -1302,7 +1302,7 @@ reregister_specialization (tree spec, tree tmpl, tree new_spec) static int eq_local_specializations (const void *p1, const void *p2) { - return TREE_VALUE ((tree) p1) == (tree) p2; + return TREE_VALUE ((const_tree) p1) == (const_tree) p2; } /* Hash P1, an entry in the local specializations table. */ @@ -1310,7 +1310,7 @@ eq_local_specializations (const void *p1, const void *p2) static hashval_t hash_local_specialization (const void* p1) { - return htab_hash_pointer (TREE_VALUE ((tree) p1)); + return htab_hash_pointer (TREE_VALUE ((const_tree) p1)); } /* Like register_specialization, but for local declarations. We are diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index dceb3f9fff2..772df4cd8f8 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -489,7 +489,7 @@ static hashval_t cplus_array_hash (const void* k) { hashval_t hash; - tree t = (tree) k; + const_tree const t = (const_tree) k; hash = (htab_hash_pointer (TREE_TYPE (t)) ^ htab_hash_pointer (TYPE_DOMAIN (t))); @@ -508,8 +508,8 @@ typedef struct cplus_array_info { static int cplus_array_compare (const void * k1, const void * k2) { - tree t1 = (tree) k1; - const cplus_array_info *t2 = (const cplus_array_info*) k2; + const_tree const t1 = (const_tree) k1; + const cplus_array_info *const t2 = (const cplus_array_info*) k2; if (!comptypes (TREE_TYPE (t1), t2->type, COMPARE_STRUCTURAL)) return 0; @@ -967,8 +967,8 @@ struct list_proxy static int list_hash_eq (const void* entry, const void* data) { - tree t = (tree) entry; - struct list_proxy *proxy = (struct list_proxy *) data; + const_tree const t = (const_tree) entry; + const struct list_proxy *const proxy = (const struct list_proxy *) data; return (TREE_VALUE (t) == proxy->value && TREE_PURPOSE (t) == proxy->purpose @@ -1003,7 +1003,7 @@ list_hash_pieces (tree purpose, tree value, tree chain) static hashval_t list_hash (const void* p) { - tree t = (tree) p; + const_tree const t = (const_tree) p; return list_hash_pieces (TREE_PURPOSE (t), TREE_VALUE (t), TREE_CHAIN (t)); diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 14d9963f61c..10f410c8ea8 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -149,9 +149,9 @@ pat_calc_hash (const void* val) static int pat_compare (const void* val1, const void* val2) { - const struct pending_abstract_type *pat1 = + const struct pending_abstract_type *const pat1 = (const struct pending_abstract_type *) val1; - tree type2 = (tree)val2; + const_tree const type2 = (const_tree)val2; return (pat1->type == type2); } diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c index 5b67962e515..6134a9bf26a 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -5694,7 +5694,7 @@ decl_die_table_hash (const void *x) static int decl_die_table_eq (const void *x, const void *y) { - return (((const_dw_die_ref) x)->decl_id == DECL_UID ((const tree) y)); + return (((const_dw_die_ref) x)->decl_id == DECL_UID ((const_tree) y)); } /* Return the DIE associated with a given declaration. */ @@ -5719,7 +5719,7 @@ decl_loc_table_hash (const void *x) static int decl_loc_table_eq (const void *x, const void *y) { - return (((const var_loc_list *) x)->decl_id == DECL_UID ((const tree) y)); + return (((const var_loc_list *) x)->decl_id == DECL_UID ((const_tree) y)); } /* Return the var_loc list associated with a given declaration. */ diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index 06ddf52c540..e9aebe1b332 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -263,8 +263,8 @@ mem_attrs_htab_hash (const void *x) static int mem_attrs_htab_eq (const void *x, const void *y) { - mem_attrs *p = (mem_attrs *) x; - mem_attrs *q = (mem_attrs *) y; + const mem_attrs *const p = (const mem_attrs *) x; + const mem_attrs *const q = (const mem_attrs *) y; return (p->alias == q->alias && p->offset == q->offset && p->size == q->size && p->align == q->align @@ -315,7 +315,7 @@ get_mem_attrs (HOST_WIDE_INT alias, tree expr, rtx offset, rtx size, static hashval_t reg_attrs_htab_hash (const void *x) { - reg_attrs *p = (reg_attrs *) x; + const reg_attrs *const p = (const reg_attrs *) x; return ((p->offset * 1000) ^ (long) p->decl); } @@ -327,8 +327,8 @@ reg_attrs_htab_hash (const void *x) static int reg_attrs_htab_eq (const void *x, const void *y) { - reg_attrs *p = (reg_attrs *) x; - reg_attrs *q = (reg_attrs *) y; + const reg_attrs *const p = (const reg_attrs *) x; + const reg_attrs *const q = (const reg_attrs *) y; return (p->decl == q->decl && p->offset == q->offset); } diff --git a/gcc/except.c b/gcc/except.c index b360ae4ad1d..7451e51c265 100644 --- a/gcc/except.c +++ b/gcc/except.c @@ -1129,8 +1129,8 @@ eh_region_outermost (struct function *ifun, int region_a, int region_b) static int t2r_eq (const void *pentry, const void *pdata) { - tree entry = (tree) pentry; - tree data = (tree) pdata; + const_tree const entry = (const_tree) pentry; + const_tree const data = (const_tree) pdata; return TREE_PURPOSE (entry) == data; } @@ -1138,7 +1138,7 @@ t2r_eq (const void *pentry, const void *pdata) static hashval_t t2r_hash (const void *pentry) { - tree entry = (tree) pentry; + const_tree const entry = (const_tree) pentry; return TREE_HASH (TREE_PURPOSE (entry)); } @@ -1183,8 +1183,9 @@ struct ttypes_filter GTY(()) static int ttypes_filter_eq (const void *pentry, const void *pdata) { - const struct ttypes_filter *entry = (const struct ttypes_filter *) pentry; - tree data = (tree) pdata; + const struct ttypes_filter *const entry + = (const struct ttypes_filter *) pentry; + const_tree const data = (const_tree) pdata; return entry->t == data; } @@ -2131,7 +2132,8 @@ finish_eh_generation (void) static hashval_t ehl_hash (const void *pentry) { - struct ehl_map_entry *entry = (struct ehl_map_entry *) pentry; + const struct ehl_map_entry *const entry + = (const struct ehl_map_entry *) pentry; /* 2^32 * ((sqrt(5) - 1) / 2) */ const hashval_t scaled_golden_ratio = 0x9e3779b9; @@ -2141,8 +2143,10 @@ ehl_hash (const void *pentry) static int ehl_eq (const void *pentry, const void *pdata) { - struct ehl_map_entry *entry = (struct ehl_map_entry *) pentry; - struct ehl_map_entry *data = (struct ehl_map_entry *) pdata; + const struct ehl_map_entry *const entry + = (const struct ehl_map_entry *) pentry; + const struct ehl_map_entry *const data + = (const struct ehl_map_entry *) pdata; return entry->label == data->label; } diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 7050f52569a..cb7cae7968f 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2007-07-25 Kaveh R. Ghazi + + * gfortran.h (generate_isocbinding_symbol): Constify. + * symbol.c (gen_special_c_interop_ptr, gen_cptr_param, + generate_isocbinding_symbol): Likewise. + 2007-07-24 Paul Thomas PR fortran/31205 diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index f475c1e9209..a0b79e55402 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -2137,7 +2137,7 @@ try verify_c_interop_param (gfc_symbol *); try verify_bind_c_sym (gfc_symbol *, gfc_typespec *, int, gfc_common_head *); try verify_bind_c_derived_type (gfc_symbol *); try verify_com_block_vars_c_interop (gfc_common_head *); -void generate_isocbinding_symbol (const char *, iso_c_binding_symbol, char *); +void generate_isocbinding_symbol (const char *, iso_c_binding_symbol, const char *); gfc_symbol *get_iso_c_sym (gfc_symbol *, char *, char *, int); int gfc_get_sym_tree (const char *, gfc_namespace *, gfc_symtree **); int gfc_get_ha_symbol (const char *, gfc_symbol **); diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index af42e9b6146..3674b31cd32 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -3235,7 +3235,7 @@ gen_special_c_interop_ptr (int ptr_id, const char *ptr_name, current ns. */ generate_isocbinding_symbol (module_name, ptr_id == ISOCBINDING_NULL_PTR ? ISOCBINDING_PTR : ISOCBINDING_FUNPTR, - (char *) (ptr_id == ISOCBINDING_NULL_PTR + (const char *) (ptr_id == ISOCBINDING_NULL_PTR ? "_gfortran_iso_c_binding_c_ptr" : "_gfortran_iso_c_binding_c_funptr")); @@ -3356,10 +3356,10 @@ gen_cptr_param (gfc_formal_arglist **head, trying to use one of the iso_c_binding functions that need it. */ if (iso_c_sym_id == ISOCBINDING_F_PROCPOINTER) generate_isocbinding_symbol (module_name, ISOCBINDING_FUNPTR, - (char *)c_ptr_type); + (const char *)c_ptr_type); else generate_isocbinding_symbol (module_name, ISOCBINDING_PTR, - (char *)c_ptr_type); + (const char *)c_ptr_type); gfc_get_ha_symbol (c_ptr_type, &(c_ptr_sym)); } @@ -3579,9 +3579,9 @@ build_formal_args (gfc_symbol *new_proc_sym, void generate_isocbinding_symbol (const char *mod_name, iso_c_binding_symbol s, - char *local_name) + const char *local_name) { - char *name = (local_name && local_name[0]) ? local_name + const char *const name = (local_name && local_name[0]) ? local_name : c_interop_kinds_table[s].name; gfc_symtree *tmp_symtree = NULL; gfc_symbol *tmp_sym = NULL; @@ -3803,7 +3803,7 @@ generate_isocbinding_symbol (const char *mod_name, iso_c_binding_symbol s, generate_isocbinding_symbol (mod_name, s == ISOCBINDING_FUNLOC ? ISOCBINDING_FUNPTR : ISOCBINDING_PTR, - (char *)(s == ISOCBINDING_FUNLOC + (const char *)(s == ISOCBINDING_FUNLOC ? "_gfortran_iso_c_binding_c_funptr" : "_gfortran_iso_c_binding_c_ptr")); tmp_sym->ts.derived = diff --git a/gcc/genautomata.c b/gcc/genautomata.c index 5bfdf96fa43..979fad602ec 100644 --- a/gcc/genautomata.c +++ b/gcc/genautomata.c @@ -130,6 +130,7 @@ typedef unsigned HOST_WIDE_INT set_el_t; /* Reservations of function units are represented by value of the following type. */ typedef set_el_t *reserv_sets_t; +typedef const set_el_t *const_reserv_sets_t; /* The following structure describes a ticker. */ struct ticker @@ -182,17 +183,21 @@ struct state_ainsn_table; /* The following typedefs are for brevity. */ typedef struct unit_decl *unit_decl_t; +typedef const struct unit_decl *const_unit_decl_t; typedef struct decl *decl_t; +typedef const struct decl *const_decl_t; typedef struct regexp *regexp_t; typedef struct unit_set_el *unit_set_el_t; typedef struct pattern_set_el *pattern_set_el_t; typedef struct pattern_reserv *pattern_reserv_t; typedef struct alt_state *alt_state_t; typedef struct state *state_t; +typedef const struct state *const_state_t; typedef struct arc *arc_t; typedef struct ainsn *ainsn_t; typedef struct automaton *automaton_t; typedef struct automata_list_el *automata_list_el_t; +typedef const struct automata_list_el *const_automata_list_el_t; typedef struct state_ainsn_table *state_ainsn_table_t; /* Undefined position. */ @@ -228,7 +233,7 @@ static int check_presence_pattern_sets (reserv_sets_t, reserv_sets_t, int); static int check_absence_pattern_sets (reserv_sets_t, reserv_sets_t, int); -static arc_t first_out_arc (state_t); +static arc_t first_out_arc (const_state_t); static arc_t next_out_arc (arc_t); @@ -873,56 +878,56 @@ struct state_ainsn_table #if defined ENABLE_CHECKING && (GCC_VERSION >= 2007) #define DECL_UNIT(d) __extension__ \ -(({ struct decl *const _decl = (d); \ +(({ __typeof (d) const _decl = (d); \ if (_decl->mode != dm_unit) \ decl_mode_check_failed (_decl->mode, "dm_unit", \ __FILE__, __LINE__, __FUNCTION__); \ &(_decl)->decl.unit; })) #define DECL_BYPASS(d) __extension__ \ -(({ struct decl *const _decl = (d); \ +(({ __typeof (d) const _decl = (d); \ if (_decl->mode != dm_bypass) \ decl_mode_check_failed (_decl->mode, "dm_bypass", \ __FILE__, __LINE__, __FUNCTION__); \ &(_decl)->decl.bypass; })) #define DECL_AUTOMATON(d) __extension__ \ -(({ struct decl *const _decl = (d); \ +(({ __typeof (d) const _decl = (d); \ if (_decl->mode != dm_automaton) \ decl_mode_check_failed (_decl->mode, "dm_automaton", \ __FILE__, __LINE__, __FUNCTION__); \ &(_decl)->decl.automaton; })) #define DECL_EXCL(d) __extension__ \ -(({ struct decl *const _decl = (d); \ +(({ __typeof (d) const _decl = (d); \ if (_decl->mode != dm_excl) \ decl_mode_check_failed (_decl->mode, "dm_excl", \ __FILE__, __LINE__, __FUNCTION__); \ &(_decl)->decl.excl; })) #define DECL_PRESENCE(d) __extension__ \ -(({ struct decl *const _decl = (d); \ +(({ __typeof (d) const _decl = (d); \ if (_decl->mode != dm_presence) \ decl_mode_check_failed (_decl->mode, "dm_presence", \ __FILE__, __LINE__, __FUNCTION__); \ &(_decl)->decl.presence; })) #define DECL_ABSENCE(d) __extension__ \ -(({ struct decl *const _decl = (d); \ +(({ __typeof (d) const _decl = (d); \ if (_decl->mode != dm_absence) \ decl_mode_check_failed (_decl->mode, "dm_absence", \ __FILE__, __LINE__, __FUNCTION__); \ &(_decl)->decl.absence; })) #define DECL_RESERV(d) __extension__ \ -(({ struct decl *const _decl = (d); \ +(({ __typeof (d) const _decl = (d); \ if (_decl->mode != dm_reserv) \ decl_mode_check_failed (_decl->mode, "dm_reserv", \ __FILE__, __LINE__, __FUNCTION__); \ &(_decl)->decl.reserv; })) #define DECL_INSN_RESERV(d) __extension__ \ -(({ struct decl *const _decl = (d); \ +(({ __typeof (d) const _decl = (d); \ if (_decl->mode != dm_insn_reserv) \ decl_mode_check_failed (_decl->mode, "dm_insn_reserv", \ __FILE__, __LINE__, __FUNCTION__); \ @@ -1737,7 +1742,7 @@ string_hash (const char *string) static hashval_t automaton_decl_hash (const void *automaton_decl) { - const decl_t decl = (decl_t) automaton_decl; + const_decl_t const decl = (const_decl_t) automaton_decl; gcc_assert (decl->mode != dm_automaton || DECL_AUTOMATON (decl)->name); @@ -1752,8 +1757,8 @@ static int automaton_decl_eq_p (const void* automaton_decl_1, const void* automaton_decl_2) { - const decl_t decl1 = (decl_t) automaton_decl_1; - const decl_t decl2 = (decl_t) automaton_decl_2; + const_decl_t const decl1 = (const_decl_t) automaton_decl_1; + const_decl_t const decl2 = (const_decl_t) automaton_decl_2; gcc_assert (decl1->mode == dm_automaton && DECL_AUTOMATON (decl1)->name @@ -1838,7 +1843,7 @@ finish_automaton_decl_table (void) static hashval_t insn_decl_hash (const void *insn_decl) { - const decl_t decl = (decl_t) insn_decl; + const_decl_t const decl = (const_decl_t) insn_decl; gcc_assert (decl->mode == dm_insn_reserv && DECL_INSN_RESERV (decl)->name); @@ -1851,8 +1856,8 @@ insn_decl_hash (const void *insn_decl) static int insn_decl_eq_p (const void *insn_decl_1, const void *insn_decl_2) { - const decl_t decl1 = (decl_t) insn_decl_1; - const decl_t decl2 = (decl_t) insn_decl_2; + const_decl_t const decl1 = (const_decl_t) insn_decl_1; + const_decl_t const decl2 = (const_decl_t) insn_decl_2; gcc_assert (decl1->mode == dm_insn_reserv && DECL_INSN_RESERV (decl1)->name @@ -1936,7 +1941,7 @@ finish_insn_decl_table (void) static hashval_t decl_hash (const void *decl) { - const decl_t d = (const decl_t) decl; + const_decl_t const d = (const_decl_t) decl; gcc_assert ((d->mode == dm_unit && DECL_UNIT (d)->name) || (d->mode == dm_reserv && DECL_RESERV (d)->name)); @@ -1950,8 +1955,8 @@ decl_hash (const void *decl) static int decl_eq_p (const void *decl_1, const void *decl_2) { - const decl_t d1 = (const decl_t) decl_1; - const decl_t d2 = (const decl_t) decl_2; + const_decl_t const d1 = (const_decl_t) decl_1; + const_decl_t const d2 = (const_decl_t) decl_2; gcc_assert ((d1->mode == dm_unit && DECL_UNIT (d1)->name) || (d1->mode == dm_reserv && DECL_RESERV (d1)->name)); @@ -3182,11 +3187,11 @@ free_alt_states (alt_state_t alt_states_list) static int alt_state_cmp (const void *alt_state_ptr_1, const void *alt_state_ptr_2) { - if ((*(alt_state_t *) alt_state_ptr_1)->state->unique_num - == (*(alt_state_t *) alt_state_ptr_2)->state->unique_num) + if ((*(const alt_state_t *) alt_state_ptr_1)->state->unique_num + == (*(const alt_state_t *) alt_state_ptr_2)->state->unique_num) return 0; - else if ((*(alt_state_t *) alt_state_ptr_1)->state->unique_num - < (*(alt_state_t *) alt_state_ptr_2)->state->unique_num) + else if ((*(const alt_state_t *) alt_state_ptr_1)->state->unique_num + < (*(const alt_state_t *) alt_state_ptr_2)->state->unique_num) return -1; else return 1; @@ -3376,11 +3381,11 @@ reserv_sets_hash_value (reserv_sets_t reservs) /* Comparison of given reservation sets. */ static int -reserv_sets_cmp (reserv_sets_t reservs_1, reserv_sets_t reservs_2) +reserv_sets_cmp (const_reserv_sets_t reservs_1, const_reserv_sets_t reservs_2) { int reservs_num; - set_el_t *reserv_ptr_1; - set_el_t *reserv_ptr_2; + const set_el_t *reserv_ptr_1; + const set_el_t *reserv_ptr_2; gcc_assert (reservs_1 && reservs_2); reservs_num = els_in_reservs; @@ -3402,7 +3407,7 @@ reserv_sets_cmp (reserv_sets_t reservs_1, reserv_sets_t reservs_2) /* The function checks equality of the reservation sets. */ static int -reserv_sets_eq (reserv_sets_t reservs_1, reserv_sets_t reservs_2) +reserv_sets_eq (const_reserv_sets_t reservs_1, const_reserv_sets_t reservs_2) { return reserv_sets_cmp (reservs_1, reservs_2) == 0; } @@ -3654,12 +3659,12 @@ state_hash (const void *state) unsigned int hash_value; alt_state_t alt_state; - if (((state_t) state)->component_states == NULL) - hash_value = reserv_sets_hash_value (((state_t) state)->reservs); + if (((const_state_t) state)->component_states == NULL) + hash_value = reserv_sets_hash_value (((const_state_t) state)->reservs); else { hash_value = 0; - for (alt_state = ((state_t) state)->component_states; + for (alt_state = ((const_state_t) state)->component_states; alt_state != NULL; alt_state = alt_state->next_sorted_alt_state) hash_value = (((hash_value >> (sizeof (unsigned) - 1) * CHAR_BIT) @@ -3668,7 +3673,7 @@ state_hash (const void *state) } hash_value = (((hash_value >> (sizeof (unsigned) - 1) * CHAR_BIT) | (hash_value << CHAR_BIT)) - + ((state_t) state)->automaton->automaton_order_num); + + ((const_state_t) state)->automaton->automaton_order_num); return hash_value; } @@ -3679,17 +3684,17 @@ state_eq_p (const void *state_1, const void *state_2) alt_state_t alt_state_1; alt_state_t alt_state_2; - if (((state_t) state_1)->automaton != ((state_t) state_2)->automaton) + if (((const_state_t) state_1)->automaton != ((const_state_t) state_2)->automaton) return 0; - else if (((state_t) state_1)->component_states == NULL - && ((state_t) state_2)->component_states == NULL) - return reserv_sets_eq (((state_t) state_1)->reservs, - ((state_t) state_2)->reservs); - else if (((state_t) state_1)->component_states != NULL - && ((state_t) state_2)->component_states != NULL) + else if (((const_state_t) state_1)->component_states == NULL + && ((const_state_t) state_2)->component_states == NULL) + return reserv_sets_eq (((const_state_t) state_1)->reservs, + ((const_state_t) state_2)->reservs); + else if (((const_state_t) state_1)->component_states != NULL + && ((const_state_t) state_2)->component_states != NULL) { - for (alt_state_1 = ((state_t) state_1)->component_states, - alt_state_2 = ((state_t) state_2)->component_states; + for (alt_state_1 = ((const_state_t) state_1)->component_states, + alt_state_2 = ((const_state_t) state_2)->component_states; alt_state_1 != NULL && alt_state_2 != NULL; alt_state_1 = alt_state_1->next_sorted_alt_state, alt_state_2 = alt_state_2->next_sorted_alt_state) @@ -3908,7 +3913,7 @@ add_arc (state_t from_state, state_t to_state, ainsn_t ainsn) /* The function returns the first arc starting from STATE. */ static arc_t -first_out_arc (state_t state) +first_out_arc (const_state_t state) { return state->first_out_arc; } @@ -3997,10 +4002,10 @@ static hashval_t automata_list_hash (const void *automata_list) { unsigned int hash_value; - automata_list_el_t curr_automata_list_el; + const_automata_list_el_t curr_automata_list_el; hash_value = 0; - for (curr_automata_list_el = (automata_list_el_t) automata_list; + for (curr_automata_list_el = (const_automata_list_el_t) automata_list; curr_automata_list_el != NULL; curr_automata_list_el = curr_automata_list_el->next_automata_list_el) hash_value = (((hash_value >> (sizeof (unsigned) - 1) * CHAR_BIT) @@ -4013,11 +4018,11 @@ automata_list_hash (const void *automata_list) static int automata_list_eq_p (const void *automata_list_1, const void *automata_list_2) { - automata_list_el_t automata_list_el_1; - automata_list_el_t automata_list_el_2; + const_automata_list_el_t automata_list_el_1; + const_automata_list_el_t automata_list_el_2; - for (automata_list_el_1 = (automata_list_el_t) automata_list_1, - automata_list_el_2 = (automata_list_el_t) automata_list_2; + for (automata_list_el_1 = (const_automata_list_el_t) automata_list_1, + automata_list_el_2 = (const_automata_list_el_t) automata_list_2; automata_list_el_1 != NULL && automata_list_el_2 != NULL; automata_list_el_1 = automata_list_el_1->next_automata_list_el, automata_list_el_2 = automata_list_el_2->next_automata_list_el) @@ -5717,8 +5722,8 @@ static int compare_states_for_equiv (const void *state_ptr_1, const void *state_ptr_2) { - state_t s1 = *(state_t *)state_ptr_1; - state_t s2 = *(state_t *)state_ptr_2; + const_state_t const s1 = *(const_state_t const*)state_ptr_1; + const_state_t const s2 = *(const_state_t const*)state_ptr_2; unsigned int sz, si; if (s1->num_out_arcs < s2->num_out_arcs) return -1; @@ -6313,11 +6318,11 @@ static int compare_max_occ_cycle_nums (const void *unit_decl_1, const void *unit_decl_2) { - if ((DECL_UNIT (*(decl_t *) unit_decl_1)->max_occ_cycle_num) - < (DECL_UNIT (*(decl_t *) unit_decl_2)->max_occ_cycle_num)) + if ((DECL_UNIT (*(const_decl_t const*) unit_decl_1)->max_occ_cycle_num) + < (DECL_UNIT (*(const_decl_t const*) unit_decl_2)->max_occ_cycle_num)) return 1; - else if ((DECL_UNIT (*(decl_t *) unit_decl_1)->max_occ_cycle_num) - == (DECL_UNIT (*(decl_t *) unit_decl_2)->max_occ_cycle_num)) + else if ((DECL_UNIT (*(const_decl_t const*) unit_decl_1)->max_occ_cycle_num) + == (DECL_UNIT (*(const_decl_t const*) unit_decl_2)->max_occ_cycle_num)) return 0; else return -1; @@ -7226,7 +7231,7 @@ add_vect (state_ainsn_table_t tab, int vect_num, vla_hwint_t vect) /* Return number of out arcs of STATE. */ static int -out_state_arcs_num (state_t state) +out_state_arcs_num (const_state_t state) { int result; arc_t arc; @@ -7246,11 +7251,11 @@ static int compare_transition_els_num (const void *state_ptr_1, const void *state_ptr_2) { - int transition_els_num_1; - int transition_els_num_2; + const int transition_els_num_1 + = out_state_arcs_num (*(const_state_t const*) state_ptr_1); + const int transition_els_num_2 + = out_state_arcs_num (*(const_state_t const*) state_ptr_2); - transition_els_num_1 = out_state_arcs_num (*(state_t *) state_ptr_1); - transition_els_num_2 = out_state_arcs_num (*(state_t *) state_ptr_2); if (transition_els_num_1 < transition_els_num_2) return 1; else if (transition_els_num_1 == transition_els_num_2) @@ -8238,8 +8243,8 @@ output_print_reservation_func (void) static int units_cmp (const void *unit1, const void *unit2) { - const unit_decl_t u1 = *(unit_decl_t *) unit1; - const unit_decl_t u2 = *(unit_decl_t *) unit2; + const_unit_decl_t const u1 = *(const_unit_decl_t const*) unit1; + const_unit_decl_t const u2 = *(const_unit_decl_t const*) unit2; return strcmp (u1->name, u2->name); } @@ -8641,8 +8646,8 @@ output_state_arcs (state_t state) static int state_reservs_cmp (const void *reservs_ptr_1, const void *reservs_ptr_2) { - return reserv_sets_cmp (*(reserv_sets_t *) reservs_ptr_1, - *(reserv_sets_t *) reservs_ptr_2); + return reserv_sets_cmp (*(const_reserv_sets_t const*) reservs_ptr_1, + *(const_reserv_sets_t const*) reservs_ptr_2); } /* The following function is used for sorting possible cpu unit diff --git a/gcc/genmodes.c b/gcc/genmodes.c index 0a2e6f3c877..956191e8ec4 100644 --- a/gcc/genmodes.c +++ b/gcc/genmodes.c @@ -740,8 +740,8 @@ create_modes (void) static int cmp_modes (const void *a, const void *b) { - struct mode_data *m = *(struct mode_data **)a; - struct mode_data *n = *(struct mode_data **)b; + const struct mode_data *const m = *(const struct mode_data *const*)a; + const struct mode_data *const n = *(const struct mode_data *const*)b; if (m->bytesize > n->bytesize) return 1; diff --git a/gcc/ggc-common.c b/gcc/ggc-common.c index 7341e968edc..c1eabb3453f 100644 --- a/gcc/ggc-common.c +++ b/gcc/ggc-common.c @@ -305,13 +305,13 @@ gt_pch_note_reorder (void *obj, void *note_ptr_cookie, static hashval_t saving_htab_hash (const void *p) { - return POINTER_HASH (((struct ptr_data *)p)->obj); + return POINTER_HASH (((const struct ptr_data *)p)->obj); } static int saving_htab_eq (const void *p1, const void *p2) { - return ((struct ptr_data *)p1)->obj == p2; + return ((const struct ptr_data *)p1)->obj == p2; } /* Handy state for the traversal functions. */ diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 12ed309538b..47191429e72 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -1335,8 +1335,8 @@ gimplify_loop_expr (tree *expr_p, tree *pre_p) static int compare_case_labels (const void *p1, const void *p2) { - tree case1 = *(tree *)p1; - tree case2 = *(tree *)p2; + const_tree const case1 = *(const_tree const*)p1; + const_tree const case2 = *(const_tree const*)p2; return tree_int_cst_compare (CASE_LOW (case1), CASE_LOW (case2)); } diff --git a/gcc/ipa-type-escape.c b/gcc/ipa-type-escape.c index d9d464d6242..0a4464dd9ae 100644 --- a/gcc/ipa-type-escape.c +++ b/gcc/ipa-type-escape.c @@ -140,14 +140,14 @@ static unsigned int look_for_casts (tree lhs ATTRIBUTE_UNUSED, tree); static bool is_cast_from_non_pointer (tree, tree, void *); /* Get the name of TYPE or return the string "". */ -static char* +static const char* get_name_of_type (tree type) { tree name = TYPE_NAME (type); if (!name) /* Unnamed type, do what you like here. */ - return (char*)""; + return ""; /* It will be a TYPE_DECL in the case of a typedef, otherwise, an identifier_node */ @@ -157,20 +157,20 @@ get_name_of_type (tree type) IDENTIFIER_NODE. (Some decls, most often labels, may have zero as the DECL_NAME). */ if (DECL_NAME (name)) - return (char*)IDENTIFIER_POINTER (DECL_NAME (name)); + return IDENTIFIER_POINTER (DECL_NAME (name)); else /* Unnamed type, do what you like here. */ - return (char*)""; + return ""; } else if (TREE_CODE (name) == IDENTIFIER_NODE) - return (char*)IDENTIFIER_POINTER (name); + return IDENTIFIER_POINTER (name); else - return (char*)""; + return ""; } struct type_brand_s { - char* name; + const char* name; int seq; }; diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 4b1c9ec65f6..fab3bab5aa4 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,13 @@ +2007-07-25 Kaveh R. Ghazi + + * class.c (java_treetreehash_hash, java_treetreehash_compare): + Constify. + * expr.c (type_assertion_eq): Likewise. + * jcf-io.c (compare_path): Likewise. + * jcf-parse.c (cmpstringp): Likewise. + * verify-impl.c (get_one_type, compute_argument_types, + compute_return_type): Likewise. + 2007-07-16 Rainer Orth PR target/32462 diff --git a/gcc/java/class.c b/gcc/java/class.c index 90381211ed6..97d9ba12941 100644 --- a/gcc/java/class.c +++ b/gcc/java/class.c @@ -3048,15 +3048,17 @@ static int java_treetreehash_compare (const void *, const void *); static hashval_t java_treetreehash_hash (const void *k_p) { - struct treetreehash_entry *k = (struct treetreehash_entry *) k_p; + const struct treetreehash_entry *const k + = (const struct treetreehash_entry *) k_p; return JAVA_TREEHASHHASH_H (k->key); } static int java_treetreehash_compare (const void * k1_p, const void * k2_p) { - struct treetreehash_entry * k1 = (struct treetreehash_entry *) k1_p; - tree k2 = (tree) k2_p; + const struct treetreehash_entry *const k1 + = (const struct treetreehash_entry *) k1_p; + const_tree const k2 = (const_tree) k2_p; return (k1->key == k2); } diff --git a/gcc/java/expr.c b/gcc/java/expr.c index 81bf8bd085c..db15062da4b 100644 --- a/gcc/java/expr.c +++ b/gcc/java/expr.c @@ -419,8 +419,8 @@ pop_type (tree type) static int type_assertion_eq (const void * k1_p, const void * k2_p) { - type_assertion k1 = *(type_assertion *)k1_p; - type_assertion k2 = *(type_assertion *)k2_p; + const type_assertion k1 = *(const type_assertion *)k1_p; + const type_assertion k2 = *(const type_assertion *)k2_p; return (k1.assertion_code == k2.assertion_code && k1.op1 == k2.op1 && k1.op2 == k2.op2); diff --git a/gcc/java/jcf-io.c b/gcc/java/jcf-io.c index 10de9d2ef0f..3a5018ac728 100644 --- a/gcc/java/jcf-io.c +++ b/gcc/java/jcf-io.c @@ -293,7 +293,7 @@ static int compare_path (const void *key, const void *entry) { return strcmp ((const char *) key, - (*((const struct dirent **) entry))->d_name); + (*((const struct dirent *const*) entry))->d_name); } /* Returns nonzero if ENTRY names a .java or .class file. */ diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c index 9411119d0a9..196a7e99138 100644 --- a/gcc/java/jcf-parse.c +++ b/gcc/java/jcf-parse.c @@ -166,7 +166,7 @@ cmpstringp (const void *p1, const void *p2) pointers to char", but strcmp() arguments are "pointers to char", hence the following cast plus dereference */ - return strcmp(*(char **) p1, *(char **) p2); + return strcmp(*(const char *const*) p1, *(const char *const*) p2); } /* Create an array of strings, one for each source file that we've diff --git a/gcc/java/verify-impl.c b/gcc/java/verify-impl.c index 886dfe7d66c..1efcf686503 100644 --- a/gcc/java/verify-impl.c +++ b/gcc/java/verify-impl.c @@ -2078,8 +2078,8 @@ check_method_constant (int index, bool is_interface, method_name, method_signature); } -static char * -get_one_type (char *p, type *t) +static const char * +get_one_type (const char *p, type *t) { const char *start = p; vfy_jclass k; @@ -2131,7 +2131,7 @@ static void compute_argument_types (vfy_string signature, type *types) { int i; - char *p = (char *) vfy_string_bytes (signature); + const char *p = vfy_string_bytes (signature); /* Skip `('. */ ++p; @@ -2144,7 +2144,7 @@ compute_argument_types (vfy_string signature, type *types) static type compute_return_type (vfy_string signature) { - char *p = (char *) vfy_string_bytes (signature); + const char *p = vfy_string_bytes (signature); type t; while (*p != ')') ++p; diff --git a/gcc/loop-unroll.c b/gcc/loop-unroll.c index 3e20fcb4b0d..09d938550c9 100644 --- a/gcc/loop-unroll.c +++ b/gcc/loop-unroll.c @@ -1484,7 +1484,7 @@ unroll_loop_stupid (struct loop *loop) static hashval_t si_info_hash (const void *ivts) { - return (hashval_t) INSN_UID (((struct iv_to_split *) ivts)->insn); + return (hashval_t) INSN_UID (((const struct iv_to_split *) ivts)->insn); } /* An equality functions for information about insns to split. */ @@ -1503,7 +1503,7 @@ si_info_eq (const void *ivts1, const void *ivts2) static hashval_t ve_info_hash (const void *ves) { - return (hashval_t) INSN_UID (((struct var_to_expand *) ves)->insn); + return (hashval_t) INSN_UID (((const struct var_to_expand *) ves)->insn); } /* Return true if IVTS1 and IVTS2 (which are really both of type diff --git a/gcc/matrix-reorg.c b/gcc/matrix-reorg.c index 0cff06f1ee2..174dd71028d 100644 --- a/gcc/matrix-reorg.c +++ b/gcc/matrix-reorg.c @@ -390,7 +390,7 @@ static htab_t matrices_to_reorg = NULL; static hashval_t mtt_info_hash (const void *mtt) { - return htab_hash_pointer (((struct matrix_info *) mtt)->decl); + return htab_hash_pointer (((const struct matrix_info *) mtt)->decl); } /* Return true if MTT1 and MTT2 (which are really both of type diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog index eb2061a6975..fdcec9d37ac 100644 --- a/gcc/objc/ChangeLog +++ b/gcc/objc/ChangeLog @@ -1,3 +1,8 @@ +2007-07-25 Kaveh R. Ghazi + + * objc-act.c (volatilized_hash, volatilized_eq, string_hash, + string_eq): Constify. + 2007-04-04 Stuart Hastings PR 31281 diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 19475e2f8d8..3f0d6deea51 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -1321,7 +1321,7 @@ objc_xref_basetypes (tree ref, tree basetype) static hashval_t volatilized_hash (const void *ptr) { - tree typ = ((struct volatilized_type *)ptr)->type; + const_tree const typ = ((const struct volatilized_type *)ptr)->type; return htab_hash_pointer(typ); } @@ -1329,8 +1329,8 @@ volatilized_hash (const void *ptr) static int volatilized_eq (const void *ptr1, const void *ptr2) { - tree typ1 = ((struct volatilized_type *)ptr1)->type; - tree typ2 = ((struct volatilized_type *)ptr2)->type; + const_tree const typ1 = ((const struct volatilized_type *)ptr1)->type; + const_tree const typ2 = ((const struct volatilized_type *)ptr2)->type; return typ1 == typ2; } @@ -1856,7 +1856,7 @@ my_build_string_pointer (int len, const char *str) static hashval_t string_hash (const void *ptr) { - tree str = ((struct string_descriptor *)ptr)->literal; + const_tree const str = ((const struct string_descriptor *)ptr)->literal; const unsigned char *p = (const unsigned char *) TREE_STRING_POINTER (str); int i, len = TREE_STRING_LENGTH (str); hashval_t h = len; @@ -1870,8 +1870,8 @@ string_hash (const void *ptr) static int string_eq (const void *ptr1, const void *ptr2) { - tree str1 = ((struct string_descriptor *)ptr1)->literal; - tree str2 = ((struct string_descriptor *)ptr2)->literal; + const_tree const str1 = ((const struct string_descriptor *)ptr1)->literal; + const_tree const str2 = ((const struct string_descriptor *)ptr2)->literal; int len1 = TREE_STRING_LENGTH (str1); return (len1 == TREE_STRING_LENGTH (str2) diff --git a/gcc/postreload-gcse.c b/gcc/postreload-gcse.c index fdf5b04fc78..338afc7328a 100644 --- a/gcc/postreload-gcse.c +++ b/gcc/postreload-gcse.c @@ -297,7 +297,7 @@ hash_expr (rtx x, int *do_not_record_p) static hashval_t hash_expr_for_htab (const void *expp) { - struct expr *exp = (struct expr *) expp; + const struct expr *const exp = (const struct expr *) expp; return exp->hash; } @@ -307,8 +307,8 @@ hash_expr_for_htab (const void *expp) static int expr_equiv_p (const void *exp1p, const void *exp2p) { - struct expr *exp1 = (struct expr *) exp1p; - struct expr *exp2 = (struct expr *) exp2p; + const struct expr *const exp1 = (const struct expr *) exp1p; + const struct expr *const exp2 = (const struct expr *) exp2p; int equiv_p = exp_equiv_p (exp1->expr, exp2->expr, 0, true); gcc_assert (!equiv_p || exp1->hash == exp2->hash); diff --git a/gcc/rtl-factoring.c b/gcc/rtl-factoring.c index 6e37df7bced..0b58d8d3896 100644 --- a/gcc/rtl-factoring.c +++ b/gcc/rtl-factoring.c @@ -238,6 +238,7 @@ typedef struct hash_bucket_def /* List of sequence candidates. */ htab_t seq_candidates; } *p_hash_bucket; +typedef const struct hash_bucket_def *const_p_hash_bucket; /* Contains the last insn of the sequence, and its index value. */ typedef struct hash_elem_def @@ -251,6 +252,7 @@ typedef struct hash_elem_def /* The cached length of the insn. */ int length; } *p_hash_elem; +typedef const struct hash_elem_def *const_p_hash_elem; /* The list of same sequence candidates. */ static htab_t hash_buckets; @@ -1205,7 +1207,7 @@ dump_best_pattern_seq (int iter) static unsigned int htab_hash_bucket (const void *p) { - p_hash_bucket bucket = (p_hash_bucket) p; + const_p_hash_bucket bucket = (const_p_hash_bucket) p; return bucket->hash; } @@ -1235,7 +1237,7 @@ htab_del_bucket (void *p) static unsigned int htab_hash_elem (const void *p) { - p_hash_elem elem = (p_hash_elem) p; + const_p_hash_elem elem = (const_p_hash_elem) p; return htab_hash_pointer (elem->insn); } diff --git a/gcc/tree-browser.c b/gcc/tree-browser.c index 354757000c4..ab2657ed653 100644 --- a/gcc/tree-browser.c +++ b/gcc/tree-browser.c @@ -751,8 +751,8 @@ store_child_info (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED, static int TB_parent_eq (const void *p1, const void *p2) { - const_tree node = (const_tree)p2; - tree parent = (tree) p1; + const_tree const node = (const_tree)p2; + const_tree const parent = (const_tree) p1; if (p1 == NULL || p2 == NULL) return 0; diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index f9d08f38794..66fbb90e525 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -307,7 +307,7 @@ new_scev_info_str (tree var) static hashval_t hash_scev_info (const void *elt) { - return SSA_NAME_VERSION (((struct scev_info_str *) elt)->var); + return SSA_NAME_VERSION (((const struct scev_info_str *) elt)->var); } /* Compares database elements E1 and E2. */ diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index 46c17ea68b1..3829d1e24aa 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -309,8 +309,8 @@ mark_non_addressable (tree var) static int sort_tags_by_id (const void *pa, const void *pb) { - tree a = *(tree *)pa; - tree b = *(tree *)pb; + const_tree const a = *(const_tree const *)pa; + const_tree const b = *(const_tree const *)pb; return DECL_UID (a) - DECL_UID (b); } diff --git a/gcc/tree-ssa-coalesce.c b/gcc/tree-ssa-coalesce.c index 1c82c8d0b91..d50417f1463 100644 --- a/gcc/tree-ssa-coalesce.c +++ b/gcc/tree-ssa-coalesce.c @@ -48,6 +48,7 @@ typedef struct coalesce_pair int second_element; int cost; } * coalesce_pair_p; +typedef const struct coalesce_pair *const_coalesce_pair_p; typedef struct cost_one_pair_d { @@ -174,8 +175,8 @@ pop_best_coalesce (coalesce_list_p cl, int *p1, int *p2) static unsigned int coalesce_pair_map_hash (const void *pair) { - hashval_t a = (hashval_t)(((coalesce_pair_p)pair)->first_element); - hashval_t b = (hashval_t)(((coalesce_pair_p)pair)->second_element); + hashval_t a = (hashval_t)(((const_coalesce_pair_p)pair)->first_element); + hashval_t b = (hashval_t)(((const_coalesce_pair_p)pair)->second_element); return COALESCE_HASH_FN (a,b); } @@ -187,8 +188,8 @@ coalesce_pair_map_hash (const void *pair) static int coalesce_pair_map_eq (const void *pair1, const void *pair2) { - coalesce_pair_p p1 = (coalesce_pair_p) pair1; - coalesce_pair_p p2 = (coalesce_pair_p) pair2; + const_coalesce_pair_p const p1 = (const_coalesce_pair_p) pair1; + const_coalesce_pair_p const p2 = (const_coalesce_pair_p) pair2; return (p1->first_element == p2->first_element && p1->second_element == p2->second_element); @@ -314,7 +315,8 @@ add_coalesce (coalesce_list_p cl, int p1, int p2, static int compare_pairs (const void *p1, const void *p2) { - return (*(coalesce_pair_p *)p1)->cost - (*(coalesce_pair_p *)p2)->cost; + return (*(const_coalesce_pair_p const*)p1)->cost + - (*(const_coalesce_pair_p const*)p2)->cost; } diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index b0bfbba882a..fc70fb459df 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -1997,8 +1997,8 @@ lookup_avail_expr (tree stmt, bool insert) static hashval_t avail_expr_hash (const void *p) { - tree stmt = ((struct expr_hash_elt *)p)->stmt; - tree rhs = ((struct expr_hash_elt *)p)->rhs; + tree stmt = ((const struct expr_hash_elt *)p)->stmt; + tree rhs = ((const struct expr_hash_elt *)p)->rhs; tree vuse; ssa_op_iter iter; hashval_t val = 0; @@ -2033,10 +2033,10 @@ real_avail_expr_hash (const void *p) static int avail_expr_eq (const void *p1, const void *p2) { - tree stmt1 = ((struct expr_hash_elt *)p1)->stmt; - tree rhs1 = ((struct expr_hash_elt *)p1)->rhs; - tree stmt2 = ((struct expr_hash_elt *)p2)->stmt; - tree rhs2 = ((struct expr_hash_elt *)p2)->rhs; + tree stmt1 = ((const struct expr_hash_elt *)p1)->stmt; + tree rhs1 = ((const struct expr_hash_elt *)p1)->rhs; + tree stmt2 = ((const struct expr_hash_elt *)p2)->stmt; + tree rhs2 = ((const struct expr_hash_elt *)p2)->rhs; /* If they are the same physical expression, return true. */ if (rhs1 == rhs2 && stmt1 == stmt2) @@ -2052,8 +2052,8 @@ avail_expr_eq (const void *p1, const void *p2) && operand_equal_p (rhs1, rhs2, OEP_PURE_SAME)) { bool ret = compare_ssa_operands_equal (stmt1, stmt2, SSA_OP_VUSE); - gcc_assert (!ret || ((struct expr_hash_elt *)p1)->hash - == ((struct expr_hash_elt *)p2)->hash); + gcc_assert (!ret || ((const struct expr_hash_elt *)p1)->hash + == ((const struct expr_hash_elt *)p2)->hash); return ret; } diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index 792f6a7627d..ffa5453a222 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -445,13 +445,14 @@ typedef struct expr_pred_trans_d speed reasons. */ hashval_t hashcode; } *expr_pred_trans_t; +typedef const struct expr_pred_trans_d *const_expr_pred_trans_t; /* Return the hash value for a phi translation table entry. */ static hashval_t expr_pred_trans_hash (const void *p) { - const expr_pred_trans_t ve = (expr_pred_trans_t) p; + const_expr_pred_trans_t const ve = (const_expr_pred_trans_t) p; return ve->hashcode; } @@ -461,8 +462,8 @@ expr_pred_trans_hash (const void *p) static int expr_pred_trans_eq (const void *p1, const void *p2) { - const expr_pred_trans_t ve1 = (expr_pred_trans_t) p1; - const expr_pred_trans_t ve2 = (expr_pred_trans_t) p2; + const_expr_pred_trans_t const ve1 = (const_expr_pred_trans_t) p1; + const_expr_pred_trans_t const ve2 = (const_expr_pred_trans_t) p2; basic_block b1 = ve1->pred; basic_block b2 = ve2->pred; int i; diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index 589058fdc2c..145db955964 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -131,6 +131,7 @@ typedef struct vn_binary_op_s hashval_t hashcode; tree result; } *vn_binary_op_t; +typedef const struct vn_binary_op_s *const_vn_binary_op_t; /* Unary operations in the hashtable consist of a single operand, an opcode, and a type. Result is the value number of the operation, @@ -144,6 +145,7 @@ typedef struct vn_unary_op_s hashval_t hashcode; tree result; } *vn_unary_op_t; +typedef const struct vn_unary_op_s *const_vn_unary_op_t; /* Phi nodes in the hashtable consist of their non-VN_TOP phi arguments, and the basic block the phi is in. Result is the value @@ -158,6 +160,7 @@ typedef struct vn_phi_s hashval_t hashcode; tree result; } *vn_phi_t; +typedef const struct vn_phi_s *const_vn_phi_t; /* Reference operands only exist in reference operations structures. They consist of an opcode, type, and some number of operands. For @@ -174,6 +177,7 @@ typedef struct vn_reference_op_struct tree op2; } vn_reference_op_s; typedef vn_reference_op_s *vn_reference_op_t; +typedef const vn_reference_op_s *const_vn_reference_op_t; DEF_VEC_O(vn_reference_op_s); DEF_VEC_ALLOC_O(vn_reference_op_s, heap); @@ -193,6 +197,7 @@ typedef struct vn_reference_s hashval_t hashcode; tree result; } *vn_reference_t; +typedef const struct vn_reference_s *const_vn_reference_t; /* Valid hashtables storing information we have proven to be correct. */ @@ -281,8 +286,8 @@ VN_INFO_GET (tree name) static int vn_reference_op_eq (const void *p1, const void *p2) { - const vn_reference_op_t vro1 = (vn_reference_op_t) p1; - const vn_reference_op_t vro2 = (vn_reference_op_t) p2; + const_vn_reference_op_t const vro1 = (const_vn_reference_op_t) p1; + const_vn_reference_op_t const vro2 = (const_vn_reference_op_t) p2; return vro1->opcode == vro2->opcode && vro1->type == vro2->type && expressions_equal_p (vro1->op0, vro2->op0) @@ -305,7 +310,7 @@ vn_reference_op_compute_hash (const vn_reference_op_t vro1) static hashval_t vn_reference_hash (const void *p1) { - const vn_reference_t vr1 = (vn_reference_t) p1; + const_vn_reference_t const vr1 = (const_vn_reference_t) p1; return vr1->hashcode; } @@ -337,8 +342,8 @@ vn_reference_eq (const void *p1, const void *p2) int i; vn_reference_op_t vro; - const vn_reference_t vr1 = (vn_reference_t) p1; - const vn_reference_t vr2 = (vn_reference_t) p2; + const_vn_reference_t const vr1 = (const_vn_reference_t) p1; + const_vn_reference_t const vr2 = (const_vn_reference_t) p2; if (vr1->vuses == vr2->vuses && vr1->operands == vr2->operands) @@ -694,7 +699,7 @@ vn_reference_insert (tree op, tree result, VEC (tree, gc) *vuses) static hashval_t vn_unary_op_hash (const void *p1) { - const vn_unary_op_t vuo1 = (vn_unary_op_t) p1; + const_vn_unary_op_t const vuo1 = (const_vn_unary_op_t) p1; return vuo1->hashcode; } @@ -711,8 +716,8 @@ vn_unary_op_compute_hash (const vn_unary_op_t vuo1) static int vn_unary_op_eq (const void *p1, const void *p2) { - const vn_unary_op_t vuo1 = (vn_unary_op_t) p1; - const vn_unary_op_t vuo2 = (vn_unary_op_t) p2; + const_vn_unary_op_t const vuo1 = (const_vn_unary_op_t) p1; + const_vn_unary_op_t const vuo2 = (const_vn_unary_op_t) p2; return vuo1->opcode == vuo2->opcode && vuo1->type == vuo2->type && expressions_equal_p (vuo1->op0, vuo2->op0); @@ -781,7 +786,7 @@ vn_binary_op_compute_hash (const vn_binary_op_t vbo1) static hashval_t vn_binary_op_hash (const void *p1) { - const vn_binary_op_t vbo1 = (vn_binary_op_t) p1; + const_vn_binary_op_t const vbo1 = (const_vn_binary_op_t) p1; return vbo1->hashcode; } @@ -791,8 +796,8 @@ vn_binary_op_hash (const void *p1) static int vn_binary_op_eq (const void *p1, const void *p2) { - const vn_binary_op_t vbo1 = (vn_binary_op_t) p1; - const vn_binary_op_t vbo2 = (vn_binary_op_t) p2; + const_vn_binary_op_t const vbo1 = (const_vn_binary_op_t) p1; + const_vn_binary_op_t const vbo2 = (const_vn_binary_op_t) p2; return vbo1->opcode == vbo2->opcode && vbo1->type == vbo2->type && expressions_equal_p (vbo1->op0, vbo2->op0) @@ -897,7 +902,7 @@ vn_phi_compute_hash (vn_phi_t vp1) static hashval_t vn_phi_hash (const void *p1) { - const vn_phi_t vp1 = (vn_phi_t) p1; + const_vn_phi_t const vp1 = (const_vn_phi_t) p1; return vp1->hashcode; } @@ -906,8 +911,8 @@ vn_phi_hash (const void *p1) static int vn_phi_eq (const void *p1, const void *p2) { - const vn_phi_t vp1 = (vn_phi_t) p1; - const vn_phi_t vp2 = (vn_phi_t) p2; + const_vn_phi_t const vp1 = (const_vn_phi_t) p1; + const_vn_phi_t const vp2 = (const_vn_phi_t) p2; if (vp1->block == vp2->block) { diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c index 40a54370008..1a3bad74ab4 100644 --- a/gcc/tree-ssa-threadupdate.c +++ b/gcc/tree-ssa-threadupdate.c @@ -223,15 +223,15 @@ create_block_for_threading (basic_block bb, struct redirection_data *rd) static hashval_t redirection_data_hash (const void *p) { - edge e = ((struct redirection_data *)p)->outgoing_edge; + edge e = ((const struct redirection_data *)p)->outgoing_edge; return e->dest->index; } static int redirection_data_eq (const void *p1, const void *p2) { - edge e1 = ((struct redirection_data *)p1)->outgoing_edge; - edge e2 = ((struct redirection_data *)p2)->outgoing_edge; + edge e1 = ((const struct redirection_data *)p1)->outgoing_edge; + edge e2 = ((const struct redirection_data *)p2)->outgoing_edge; return e1 == e2; } diff --git a/gcc/tree-ssa-uncprop.c b/gcc/tree-ssa-uncprop.c index 2271613c3eb..f502a2e04c9 100644 --- a/gcc/tree-ssa-uncprop.c +++ b/gcc/tree-ssa-uncprop.c @@ -316,15 +316,15 @@ static void uncprop_into_successor_phis (struct dom_walk_data *, basic_block); static hashval_t equiv_hash (const void *p) { - tree value = ((struct equiv_hash_elt *)p)->value; + tree const value = ((const struct equiv_hash_elt *)p)->value; return iterative_hash_expr (value, 0); } static int equiv_eq (const void *p1, const void *p2) { - tree value1 = ((struct equiv_hash_elt *)p1)->value; - tree value2 = ((struct equiv_hash_elt *)p2)->value; + tree value1 = ((const struct equiv_hash_elt *)p1)->value; + tree value2 = ((const struct equiv_hash_elt *)p2)->value; return operand_equal_p (value1, value2, 0); } diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index 858745e683a..0075cd4b8e0 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -781,7 +781,7 @@ static int var_ann_eq (const void *va, const void *vb) { const struct static_var_ann_d *a = (const struct static_var_ann_d *) va; - tree b = (tree) vb; + const_tree const b = (const_tree) vb; return (a->uid == DECL_UID (b)); } diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 06931f1f74d..9c2272a5f61 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -3843,8 +3843,8 @@ find_conditional_asserts (basic_block bb, tree last) static int compare_case_labels (const void *p1, const void *p2) { - tree case1 = *(tree *)p1; - tree case2 = *(tree *)p2; + const_tree const case1 = *(const_tree const*)p1; + const_tree const case2 = *(const_tree const*)p2; unsigned int uid1 = DECL_UID (CASE_LABEL (case1)); unsigned int uid2 = DECL_UID (CASE_LABEL (case2)); diff --git a/gcc/tree.c b/gcc/tree.c index 8a1b242924c..2bd45b7e959 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -811,7 +811,7 @@ build_int_cst_wide_type (tree type, static hashval_t int_cst_hash_hash (const void *x) { - tree t = (tree) x; + const_tree const t = (const_tree) x; return (TREE_INT_CST_HIGH (t) ^ TREE_INT_CST_LOW (t) ^ htab_hash_pointer (TREE_TYPE (t))); @@ -823,8 +823,8 @@ int_cst_hash_hash (const void *x) static int int_cst_hash_eq (const void *x, const void *y) { - tree xt = (tree) x; - tree yt = (tree) y; + const_tree const xt = (const_tree) x; + const_tree const yt = (const_tree) y; return (TREE_TYPE (xt) == TREE_TYPE (yt) && TREE_INT_CST_HIGH (xt) == TREE_INT_CST_HIGH (yt) @@ -4263,7 +4263,7 @@ tree_map_base_hash (const void *item) int tree_map_base_marked_p (const void *p) { - return ggc_marked_p (((struct tree_map_base *) p)->from); + return ggc_marked_p (((const struct tree_map_base *) p)->from); } unsigned int @@ -4686,7 +4686,7 @@ type_hash_canon (unsigned int hashcode, tree type) static int type_hash_marked_p (const void *p) { - tree type = ((struct type_hash *) p)->type; + const_tree const type = ((const struct type_hash *) p)->type; return ggc_marked_p (type) || TYPE_SYMTAB_POINTER (type); } @@ -6707,11 +6707,11 @@ get_file_function_name (const char *type) are of the caller. */ void -tree_check_failed (const tree node, const char *file, +tree_check_failed (const_tree node, const char *file, int line, const char *function, ...) { va_list args; - char *buffer; + const char *buffer; unsigned length = 0; int code; @@ -6721,23 +6721,24 @@ tree_check_failed (const tree node, const char *file, va_end (args); if (length) { + char *tmp; va_start (args, function); length += strlen ("expected "); - buffer = alloca (length); + buffer = tmp = alloca (length); length = 0; while ((code = va_arg (args, int))) { const char *prefix = length ? " or " : "expected "; - strcpy (buffer + length, prefix); + strcpy (tmp + length, prefix); length += strlen (prefix); - strcpy (buffer + length, tree_code_name[code]); + strcpy (tmp + length, tree_code_name[code]); length += strlen (tree_code_name[code]); } va_end (args); } else - buffer = (char *)"unexpected node"; + buffer = "unexpected node"; internal_error ("tree check: %s, have %s in %s, at %s:%d", buffer, tree_code_name[TREE_CODE (node)], @@ -6749,7 +6750,7 @@ tree_check_failed (const tree node, const char *file, the caller. */ void -tree_not_check_failed (const tree node, const char *file, +tree_not_check_failed (const_tree node, const char *file, int line, const char *function, ...) { va_list args; @@ -6785,7 +6786,7 @@ tree_not_check_failed (const tree node, const char *file, code, given in CL. */ void -tree_class_check_failed (const tree node, const enum tree_code_class cl, +tree_class_check_failed (const_tree node, const enum tree_code_class cl, const char *file, int line, const char *function) { internal_error @@ -6799,7 +6800,7 @@ tree_class_check_failed (const tree node, const enum tree_code_class cl, dozen codes, use the knowledge that they're all sequential. */ void -tree_range_check_failed (const tree node, const char *file, int line, +tree_range_check_failed (const_tree node, const char *file, int line, const char *function, enum tree_code c1, enum tree_code c2) { @@ -6834,7 +6835,7 @@ tree_range_check_failed (const tree node, const char *file, int line, not have the specified code, given in CL. */ void -tree_not_class_check_failed (const tree node, const enum tree_code_class cl, +tree_not_class_check_failed (const_tree node, const enum tree_code_class cl, const char *file, int line, const char *function) { internal_error @@ -6848,7 +6849,7 @@ tree_not_class_check_failed (const tree node, const enum tree_code_class cl, /* Similar to tree_check_failed but applied to OMP_CLAUSE codes. */ void -omp_clause_check_failed (const tree node, const char *file, int line, +omp_clause_check_failed (const_tree node, const char *file, int line, const char *function, enum omp_clause_code code) { internal_error ("tree check: expected omp_clause %s, have %s in %s, at %s:%d", @@ -6860,7 +6861,7 @@ omp_clause_check_failed (const tree node, const char *file, int line, /* Similar to tree_range_check_failed but applied to OMP_CLAUSE codes. */ void -omp_clause_range_check_failed (const tree node, const char *file, int line, +omp_clause_range_check_failed (const_tree node, const char *file, int line, const char *function, enum omp_clause_code c1, enum omp_clause_code c2) { @@ -6905,7 +6906,7 @@ static const char *ts_enum_names[] = { whether CODE contains the tree structure identified by EN. */ void -tree_contains_struct_check_failed (const tree node, +tree_contains_struct_check_failed (const_tree node, const enum tree_node_structure_enum en, const char *file, int line, const char *function) @@ -6945,7 +6946,7 @@ phi_node_elt_check_failed (int idx, int len, const char *file, int line, vector of an expression node EXP. */ void -tree_operand_check_failed (int idx, tree exp, const char *file, +tree_operand_check_failed (int idx, const_tree exp, const char *file, int line, const char *function) { int code = TREE_CODE (exp); diff --git a/gcc/tree.h b/gcc/tree.h index c2dbfed3f9d..393898e0849 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -856,22 +856,22 @@ enum tree_node_structure_enum { gcc_unreachable (); \ &__t->common.type; })) -extern void tree_contains_struct_check_failed (const tree, +extern void tree_contains_struct_check_failed (const_tree, const enum tree_node_structure_enum, const char *, int, const char *) ATTRIBUTE_NORETURN; -extern void tree_check_failed (const tree, const char *, int, const char *, +extern void tree_check_failed (const_tree, const char *, int, const char *, ...) ATTRIBUTE_NORETURN; -extern void tree_not_check_failed (const tree, const char *, int, const char *, +extern void tree_not_check_failed (const_tree, const char *, int, const char *, ...) ATTRIBUTE_NORETURN; -extern void tree_class_check_failed (const tree, const enum tree_code_class, +extern void tree_class_check_failed (const_tree, const enum tree_code_class, const char *, int, const char *) ATTRIBUTE_NORETURN; -extern void tree_range_check_failed (const tree, const char *, int, +extern void tree_range_check_failed (const_tree, const char *, int, const char *, enum tree_code, enum tree_code); -extern void tree_not_class_check_failed (const tree, +extern void tree_not_class_check_failed (const_tree, const enum tree_code_class, const char *, int, const char *) ATTRIBUTE_NORETURN; @@ -881,16 +881,16 @@ extern void tree_vec_elt_check_failed (int, int, const char *, extern void phi_node_elt_check_failed (int, int, const char *, int, const char *) ATTRIBUTE_NORETURN; -extern void tree_operand_check_failed (int, tree, +extern void tree_operand_check_failed (int, const_tree, const char *, int, const char *) ATTRIBUTE_NORETURN; -extern void omp_clause_check_failed (const tree, const char *, int, +extern void omp_clause_check_failed (const_tree, const char *, int, const char *, enum omp_clause_code) ATTRIBUTE_NORETURN; extern void omp_clause_operand_check_failed (int, const_tree, const char *, int, const char *) ATTRIBUTE_NORETURN; -extern void omp_clause_range_check_failed (const tree, const char *, int, +extern void omp_clause_range_check_failed (const_tree, const char *, int, const char *, enum omp_clause_code, enum omp_clause_code) ATTRIBUTE_NORETURN; @@ -4929,7 +4929,7 @@ void init_inline_once (void); tcc_vl_exp nodes like CALL_EXPRs, this is stored in the node itself, otherwise it is looked up from the node's code. */ static inline int -tree_operand_length (tree node) +tree_operand_length (const_tree node) { if (VL_EXP_CLASS_P (node)) return VL_EXP_OPERAND_LENGTH (node); diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c index bdc173ef5a3..53671f55239 100644 --- a/gcc/var-tracking.c +++ b/gcc/var-tracking.c @@ -258,6 +258,7 @@ typedef struct variable_def /* The variable parts. */ variable_part var_part[MAX_VAR_PARTS]; } *variable; +typedef const struct variable_def *const_variable; /* Hash function for DECL for VARIABLE_HTAB. */ #define VARIABLE_HASH_VAL(decl) (DECL_UID (decl)) @@ -601,7 +602,7 @@ adjust_stack_reference (rtx mem, HOST_WIDE_INT adjustment) static hashval_t variable_htab_hash (const void *x) { - const variable v = (const variable) x; + const_variable const v = (const_variable) x; return (VARIABLE_HASH_VAL (v->decl)); } @@ -611,8 +612,8 @@ variable_htab_hash (const void *x) static int variable_htab_eq (const void *x, const void *y) { - const variable v = (const variable) x; - const tree decl = (const tree) y; + const_variable const v = (const_variable) x; + const_tree const decl = (const_tree) y; return (VARIABLE_HASH_VAL (v->decl) == VARIABLE_HASH_VAL (decl)); } diff --git a/gcc/varasm.c b/gcc/varasm.c index f367561dc12..a897687cbed 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -2734,7 +2734,7 @@ static void maybe_output_constant_def_contents (struct constant_descriptor_tree static hashval_t const_desc_hash (const void *ptr) { - return ((struct constant_descriptor_tree *)ptr)->hash; + return ((const struct constant_descriptor_tree *)ptr)->hash; } static hashval_t