diff options
author | pmatos <pmatos@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-10-16 10:09:17 +0000 |
---|---|---|
committer | pmatos <pmatos@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-10-16 10:09:17 +0000 |
commit | f3d35d4d7a9ee47e12bd0d8cc5c2c1f500ac883b (patch) | |
tree | 18b9fdf2590d9183a3aedbda66687c9d2c9b31c8 | |
parent | 548e3bb3a25a87bbb9941188a292d0f7d5895c68 (diff) | |
download | gcc-f3d35d4d7a9ee47e12bd0d8cc5c2c1f500ac883b.tar.gz |
gcc/
* tree-core.h (tree_code_name): Remove.
* tree.h (get_tree_code_name): New prototype.
* tree.c (tree_code_name): Make static.
(get_tree_code_name): New function.
(dump_tree_statistics, tree_check_failed, tree_not_check_failed,
tree_class_check_failed, tree_range_check_failed,
tree_not_class_check_failed, omp_clause_check_failed,
tree_contains_struct_check_failed, tree_operand_check_failed): Use new
wrapper get_tree_code_name instead of calling tree_code_name directly.
* tree-vrp.c (dump_asserts_for): Likewise.
* tree-dump.c (dequeue_and_dump): Likewise.
* tree-pretty-print.c (do_niy, dump_generic_node): Likewise.
* tree-pretty-print.h (pp_unsupported_tree): Likewise.
* lto-streamer-out.c (lto_write_tree, DFS_write_tree): Likewise.
* tree-ssa-dom.c (print_expr_hash_elt): Likewise.
* gimple-pretty-print.c (dump_unary_rhs, dump_binary_rhs,
dump_ternary_rhs, dump_gimple_assign, dump_gimple_cond,
dump_gimple_omp_for): Likewise.
* tree-vect-data-refs.c (vect_create_data_ref_ptr): Likewise.
* tree-ssa-pre.c (print_pre_expr): Likewise.
* ipa-prop.c (ipa_print_node_jump_functions_for_edge): Likewise.
* print-tree.c (print_node_brief, print_node): Likewise.
* gimple.c (gimple_check_failed): Likewise.
* lto-streamer.c (lto_tag_name, print_lto_report): Likewise.
* config/frv/frv.c (frv_init_cumulative_args): Likewise.
* config/mep/mep.c (mep_validate_vliw): Likewise.
* config/iq2000/iq2000.c (init_cumulative_args): Likewise.
* config/rs6000/rs6000.c (init_cumulative_args): Likewise.
gcc/cp/
* error.c (code_to_string): Use new wrapper get_tree_code_name.
* cxx-pretty-print.c (pp_cxx_assignment_operator): Likewise.
* pt.c (tsubst): Likewise.
* semantics.c (cxx_eval_constant_expression,
potential_constant_expression_1): Likewise.
* mangle.c (MANGLE_TRACE_TREE, dump_substitution_candidates,
add_substitution, find_substitution): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@203695 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 31 | ||||
-rw-r--r-- | gcc/config/frv/frv.c | 2 | ||||
-rw-r--r-- | gcc/config/iq2000/iq2000.c | 4 | ||||
-rw-r--r-- | gcc/config/mep/mep.c | 2 | ||||
-rw-r--r-- | gcc/config/rs6000/rs6000.c | 2 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/cp/cxx-pretty-print.c | 2 | ||||
-rw-r--r-- | gcc/cp/error.c | 2 | ||||
-rw-r--r-- | gcc/cp/mangle.c | 10 | ||||
-rw-r--r-- | gcc/cp/pt.c | 2 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 4 | ||||
-rw-r--r-- | gcc/gimple-pretty-print.c | 16 | ||||
-rw-r--r-- | gcc/gimple.c | 4 | ||||
-rw-r--r-- | gcc/ipa-prop.c | 3 | ||||
-rw-r--r-- | gcc/lto-streamer-out.c | 4 | ||||
-rw-r--r-- | gcc/lto-streamer.c | 4 | ||||
-rw-r--r-- | gcc/print-tree.c | 4 | ||||
-rw-r--r-- | gcc/tree-core.h | 3 | ||||
-rw-r--r-- | gcc/tree-dump.c | 2 | ||||
-rw-r--r-- | gcc/tree-pretty-print.c | 4 | ||||
-rw-r--r-- | gcc/tree-pretty-print.h | 2 | ||||
-rw-r--r-- | gcc/tree-ssa-dom.c | 6 | ||||
-rw-r--r-- | gcc/tree-ssa-pre.c | 4 | ||||
-rw-r--r-- | gcc/tree-vect-data-refs.c | 2 | ||||
-rw-r--r-- | gcc/tree-vrp.c | 2 | ||||
-rw-r--r-- | gcc/tree.c | 65 | ||||
-rw-r--r-- | gcc/tree.h | 2 |
27 files changed, 125 insertions, 73 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cbb5311a0fe..8fcc0b9f571 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,34 @@ +2013-10-16 Paulo Matos <pmatos@broadcom.com> + + * tree-core.h (tree_code_name): Remove. + * tree.h (get_tree_code_name): New prototype. + * tree.c (tree_code_name): Make static. + (get_tree_code_name): New function. + (dump_tree_statistics, tree_check_failed, tree_not_check_failed, + tree_class_check_failed, tree_range_check_failed, + tree_not_class_check_failed, omp_clause_check_failed, + tree_contains_struct_check_failed, tree_operand_check_failed): Use new + wrapper get_tree_code_name instead of calling tree_code_name directly. + * tree-vrp.c (dump_asserts_for): Likewise. + * tree-dump.c (dequeue_and_dump): Likewise. + * tree-pretty-print.c (do_niy, dump_generic_node): Likewise. + * tree-pretty-print.h (pp_unsupported_tree): Likewise. + * lto-streamer-out.c (lto_write_tree, DFS_write_tree): Likewise. + * tree-ssa-dom.c (print_expr_hash_elt): Likewise. + * gimple-pretty-print.c (dump_unary_rhs, dump_binary_rhs, + dump_ternary_rhs, dump_gimple_assign, dump_gimple_cond, + dump_gimple_omp_for): Likewise. + * tree-vect-data-refs.c (vect_create_data_ref_ptr): Likewise. + * tree-ssa-pre.c (print_pre_expr): Likewise. + * ipa-prop.c (ipa_print_node_jump_functions_for_edge): Likewise. + * print-tree.c (print_node_brief, print_node): Likewise. + * gimple.c (gimple_check_failed): Likewise. + * lto-streamer.c (lto_tag_name, print_lto_report): Likewise. + * config/frv/frv.c (frv_init_cumulative_args): Likewise. + * config/mep/mep.c (mep_validate_vliw): Likewise. + * config/iq2000/iq2000.c (init_cumulative_args): Likewise. + * config/rs6000/rs6000.c (init_cumulative_args): Likewise. + 2013-10-16 Ganesh Gopalasubramanian <Ganesh.Gopalasubramanian@amd.com> * config/i386/i386.c (ix86_option_override_internal): Enable FMA4 diff --git a/gcc/config/frv/frv.c b/gcc/config/frv/frv.c index 376a0bbe7a6..41ae2bbfff6 100644 --- a/gcc/config/frv/frv.c +++ b/gcc/config/frv/frv.c @@ -3094,7 +3094,7 @@ frv_init_cumulative_args (CUMULATIVE_ARGS *cum, { tree ret_type = TREE_TYPE (fntype); fprintf (stderr, " return=%s,", - tree_code_name[ (int)TREE_CODE (ret_type) ]); + get_tree_code_name ((int)TREE_CODE (ret_type))); } if (libname && GET_CODE (libname) == SYMBOL_REF) diff --git a/gcc/config/iq2000/iq2000.c b/gcc/config/iq2000/iq2000.c index 7e19366ae93..da6f757d6f9 100644 --- a/gcc/config/iq2000/iq2000.c +++ b/gcc/config/iq2000/iq2000.c @@ -1104,8 +1104,8 @@ init_cumulative_args (CUMULATIVE_ARGS *cum, tree fntype, tree ret_type = TREE_TYPE (fntype); fprintf (stderr, ", fntype code = %s, ret code = %s\n", - tree_code_name[(int)TREE_CODE (fntype)], - tree_code_name[(int)TREE_CODE (ret_type)]); + get_tree_code_name (TREE_CODE (fntype)), + get_tree_code_name (TREE_CODE (ret_type))); } } diff --git a/gcc/config/mep/mep.c b/gcc/config/mep/mep.c index a5b7e6c68be..d082070eef6 100644 --- a/gcc/config/mep/mep.c +++ b/gcc/config/mep/mep.c @@ -3962,7 +3962,7 @@ mep_validate_vliw (tree *node, tree name, tree args ATTRIBUTE_UNUSED, static int gave_array_note = 0; static const char * given_type = NULL; - given_type = tree_code_name[TREE_CODE (*node)]; + given_type = get_tree_code_name (TREE_CODE (*node)); if (TREE_CODE (*node) == POINTER_TYPE) given_type = "pointers"; if (TREE_CODE (*node) == ARRAY_TYPE) diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index f4b65501166..1523816fe63 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -8334,7 +8334,7 @@ init_cumulative_args (CUMULATIVE_ARGS *cum, tree fntype, { tree ret_type = TREE_TYPE (fntype); fprintf (stderr, " ret code = %s,", - tree_code_name[ (int)TREE_CODE (ret_type) ]); + get_tree_code_name (TREE_CODE (ret_type))); } if (cum->call_cookie & CALL_LONG) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ed30e1bccbb..3378d618e53 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,13 @@ +2013-10-16 Paulo Matos <pmatos@broadcom.com> + + * error.c (code_to_string): Use new wrapper get_tree_code_name. + * cxx-pretty-print.c (pp_cxx_assignment_operator): Likewise. + * pt.c (tsubst): Likewise. + * semantics.c (cxx_eval_constant_expression, + potential_constant_expression_1): Likewise. + * mangle.c (MANGLE_TRACE_TREE, dump_substitution_candidates, + add_substitution, find_substitution): Likewise. + 2013-10-15 Paolo Carlini <paolo.carlini@oracle.com> PR c++/58707 diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c index bcef8760ad7..cb97fb5d59a 100644 --- a/gcc/cp/cxx-pretty-print.c +++ b/gcc/cp/cxx-pretty-print.c @@ -971,7 +971,7 @@ pp_cxx_assignment_operator (cxx_pretty_printer *pp, tree t) break; default: - op = tree_code_name[TREE_CODE (t)]; + op = get_tree_code_name (TREE_CODE (t)); break; } diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 62e39d3bcbf..0c3cead1b27 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -2852,7 +2852,7 @@ fndecl_to_string (tree fndecl, int verbose) static const char * code_to_string (enum tree_code c) { - return tree_code_name [c]; + return get_tree_code_name (c); } const char * diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 8c11ba8d394..202fafceb03 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -69,7 +69,7 @@ along with GCC; see the file COPYING3. If not see fprintf (stderr, " %-24s: %-24s\n", (FN), (INPUT)) # define MANGLE_TRACE_TREE(FN, NODE) \ fprintf (stderr, " %-24s: %-24s (%p)\n", \ - (FN), tree_code_name[TREE_CODE (NODE)], (void *) (NODE)) + (FN), get_tree_code_name (TREE_CODE (NODE)), (void *) (NODE)) #else # define MANGLE_TRACE(FN, INPUT) # define MANGLE_TRACE_TREE(FN, NODE) @@ -329,7 +329,7 @@ dump_substitution_candidates (void) || CP_TYPE_CONST_P (el))) fprintf (stderr, "CV-"); fprintf (stderr, "%s (%s at %p)\n", - name, tree_code_name[TREE_CODE (el)], (void *) el); + name, get_tree_code_name (TREE_CODE (el)), (void *) el); } } @@ -379,13 +379,13 @@ add_substitution (tree node) if (DEBUG_MANGLE) fprintf (stderr, " ++ add_substitution (%s at %10p)\n", - tree_code_name[TREE_CODE (node)], (void *) node); + get_tree_code_name (TREE_CODE (node)), (void *) node); /* Get the canonicalized substitution candidate for NODE. */ c = canonicalize_for_substitution (node); if (DEBUG_MANGLE && c != node) fprintf (stderr, " ++ using candidate (%s at %10p)\n", - tree_code_name[TREE_CODE (node)], (void *) node); + get_tree_code_name (TREE_CODE (node)), (void *) node); node = c; #if ENABLE_CHECKING @@ -513,7 +513,7 @@ find_substitution (tree node) if (DEBUG_MANGLE) fprintf (stderr, " ++ find_substitution (%s at %p)\n", - tree_code_name[TREE_CODE (node)], (void *) node); + get_tree_code_name (TREE_CODE (node)), (void *) node); /* Obtain the canonicalized substitution representation for NODE. This is what we'll compare against. */ diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 57b3ff04feb..95d901c7385 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -12102,7 +12102,7 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) gcc_unreachable (); default: - sorry ("use of %qs in template", tree_code_name [(int) code]); + sorry ("use of %qs in template", get_tree_code_name ((int) code)); return error_mark_node; } } diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 9bfd263776e..41965b643b0 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -9656,7 +9656,7 @@ cxx_eval_constant_expression (const constexpr_call *call, tree t, default: internal_error ("unexpected expression %qE of kind %s", t, - tree_code_name[TREE_CODE (t)]); + get_tree_code_name (TREE_CODE (t))); *non_constant_p = true; break; } @@ -10417,7 +10417,7 @@ potential_constant_expression_1 (tree t, bool want_rval, tsubst_flags_t flags) if (objc_is_property_ref (t)) return false; - sorry ("unexpected AST of kind %s", tree_code_name[TREE_CODE (t)]); + sorry ("unexpected AST of kind %s", get_tree_code_name (TREE_CODE (t))); gcc_unreachable(); return false; } diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c index f0f816671ec..14fb1c8c26f 100644 --- a/gcc/gimple-pretty-print.c +++ b/gcc/gimple-pretty-print.c @@ -312,7 +312,7 @@ dump_unary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags) else { pp_left_bracket (buffer); - pp_string (buffer, tree_code_name [rhs_code]); + pp_string (buffer, get_tree_code_name (rhs_code)); pp_string (buffer, "] "); } @@ -351,7 +351,7 @@ dump_binary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags) case VEC_PACK_FIX_TRUNC_EXPR: case VEC_WIDEN_LSHIFT_HI_EXPR: case VEC_WIDEN_LSHIFT_LO_EXPR: - for (p = tree_code_name [(int) code]; *p; p++) + for (p = get_tree_code_name (code); *p; p++) pp_character (buffer, TOUPPER (*p)); pp_string (buffer, " <"); dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); @@ -397,7 +397,7 @@ dump_ternary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags) { case WIDEN_MULT_PLUS_EXPR: case WIDEN_MULT_MINUS_EXPR: - for (p = tree_code_name [(int) code]; *p; p++) + for (p = get_tree_code_name (code); *p; p++) pp_character (buffer, TOUPPER (*p)); pp_string (buffer, " <"); dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false); @@ -495,7 +495,7 @@ dump_gimple_assign (pretty_printer *buffer, gimple gs, int spc, int flags) } dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs, - tree_code_name[gimple_assign_rhs_code (gs)], + get_tree_code_name (gimple_assign_rhs_code (gs)), gimple_assign_lhs (gs), arg1, arg2, arg3); } else @@ -790,9 +790,9 @@ dump_gimple_cond (pretty_printer *buffer, gimple gs, int spc, int flags) { if (flags & TDF_RAW) dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs, - tree_code_name [gimple_cond_code (gs)], - gimple_cond_lhs (gs), gimple_cond_rhs (gs), - gimple_cond_true_label (gs), gimple_cond_false_label (gs)); + get_tree_code_name (gimple_cond_code (gs)), + gimple_cond_lhs (gs), gimple_cond_rhs (gs), + gimple_cond_true_label (gs), gimple_cond_false_label (gs)); else { if (!(flags & TDF_RHS_ONLY)) @@ -1113,7 +1113,7 @@ dump_gimple_omp_for (pretty_printer *buffer, gimple gs, int spc, int flags) gimple_omp_for_index (gs, i), gimple_omp_for_initial (gs, i), gimple_omp_for_final (gs, i), - tree_code_name[gimple_omp_for_cond (gs, i)], + get_tree_code_name (gimple_omp_for_cond (gs, i)), gimple_omp_for_incr (gs, i)); dump_gimple_fmt (buffer, spc, flags, "PRE_BODY <%S>%->", gimple_omp_for_pre_body (gs)); diff --git a/gcc/gimple.c b/gcc/gimple.c index a12dd67a118..9bc62c0026b 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -1200,10 +1200,10 @@ gimple_check_failed (const_gimple gs, const char *file, int line, { internal_error ("gimple check: expected %s(%s), have %s(%s) in %s, at %s:%d", gimple_code_name[code], - tree_code_name[subcode], + get_tree_code_name (subcode), gimple_code_name[gimple_code (gs)], gs->gsbase.subcode > 0 - ? tree_code_name[gs->gsbase.subcode] + ? get_tree_code_name ((enum tree_code) gs->gsbase.subcode) : "", function, trim_filename (file), line); } diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index 2fbc9d41541..7ec3c49e42f 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -248,8 +248,7 @@ ipa_print_node_jump_functions_for_edge (FILE *f, struct cgraph_edge *cs) fprintf (f, "PASS THROUGH: "); fprintf (f, "%d, op %s", jump_func->value.pass_through.formal_id, - tree_code_name[(int) - jump_func->value.pass_through.operation]); + get_tree_code_name(jump_func->value.pass_through.operation)); if (jump_func->value.pass_through.operation != NOP_EXPR) { fprintf (f, " "); diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c index 20d8bfa9c42..35ad1cf0c80 100644 --- a/gcc/lto-streamer-out.c +++ b/gcc/lto-streamer-out.c @@ -367,7 +367,7 @@ lto_write_tree (struct output_block *ob, tree expr, bool ref_p) { if (!lto_is_streamable (expr)) internal_error ("tree code %qs is not supported in LTO streams", - tree_code_name[TREE_CODE (expr)]); + get_tree_code_name (TREE_CODE (expr))); /* Write the header, containing everything needed to materialize EXPR on the reading side. */ @@ -1241,7 +1241,7 @@ DFS_write_tree (struct output_block *ob, sccs *from_state, if (!lto_is_streamable (t)) internal_error ("tree code %qs is not supported " "in LTO streams", - tree_code_name[TREE_CODE (t)]); + get_tree_code_name (TREE_CODE (t))); gcc_checking_assert (!streamer_handle_as_builtin_p (t)); diff --git a/gcc/lto-streamer.c b/gcc/lto-streamer.c index cdc75de9bae..f1d3b69127d 100644 --- a/gcc/lto-streamer.c +++ b/gcc/lto-streamer.c @@ -54,7 +54,7 @@ lto_tag_name (enum LTO_tags tag) { /* For tags representing tree nodes, return the name of the associated tree code. */ - return tree_code_name[lto_tag_to_tree_code (tag)]; + return get_tree_code_name (lto_tag_to_tree_code (tag)); } if (lto_tag_is_gimple_code_p (tag)) @@ -199,7 +199,7 @@ print_lto_report (const char *s) if (lto_stats.num_trees[i]) fprintf (stderr, "[%s] # of '%s' objects read: " HOST_WIDE_INT_PRINT_UNSIGNED "\n", s, - tree_code_name[i], lto_stats.num_trees[i]); + get_tree_code_name ((enum tree_code) i), lto_stats.num_trees[i]); if (flag_lto) { diff --git a/gcc/print-tree.c b/gcc/print-tree.c index 4ded0d6360a..2b9aa704bec 100644 --- a/gcc/print-tree.c +++ b/gcc/print-tree.c @@ -71,7 +71,7 @@ print_node_brief (FILE *file, const char *prefix, const_tree node, int indent) name if any. */ if (indent > 0) fprintf (file, " "); - fprintf (file, "%s <%s", prefix, tree_code_name[(int) TREE_CODE (node)]); + fprintf (file, "%s <%s", prefix, get_tree_code_name (TREE_CODE (node))); dump_addr (file, " ", node); if (tclass == tcc_declaration) @@ -247,7 +247,7 @@ print_node (FILE *file, const char *prefix, tree node, int indent) indent_to (file, indent); /* Print the slot this node is in, and its code, and address. */ - fprintf (file, "%s <%s", prefix, tree_code_name[(int) code]); + fprintf (file, "%s <%s", prefix, get_tree_code_name (code)); dump_addr (file, " ", node); /* Print the name, if any. */ diff --git a/gcc/tree-core.h b/gcc/tree-core.h index a14c7e079b3..c7fc84f87ad 100644 --- a/gcc/tree-core.h +++ b/gcc/tree-core.h @@ -1753,9 +1753,6 @@ extern const char *const tree_code_class_strings[]; /* Number of argument-words in each kind of tree-node. */ extern const unsigned char tree_code_length[]; -/* Names of tree components. */ -extern const char *const tree_code_name[]; - /* Vector of all alias pairs for global symbols. */ extern GTY(()) vec<alias_pair, va_gc> *alias_pairs; diff --git a/gcc/tree-dump.c b/gcc/tree-dump.c index 0dd97291dea..6b16caa9469 100644 --- a/gcc/tree-dump.c +++ b/gcc/tree-dump.c @@ -278,7 +278,7 @@ dequeue_and_dump (dump_info_p di) if (dni->binfo_p) code_name = "binfo"; else - code_name = tree_code_name[(int) TREE_CODE (t)]; + code_name = get_tree_code_name (TREE_CODE (t)); fprintf (di->stream, "%-16s ", code_name); di->column = 25; diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c index b10b7e254a3..f8a0342f944 100644 --- a/gcc/tree-pretty-print.c +++ b/gcc/tree-pretty-print.c @@ -59,7 +59,7 @@ do_niy (pretty_printer *buffer, const_tree node) int i, len; pp_string (buffer, "<<< Unknown tree: "); - pp_string (buffer, tree_code_name[(int) TREE_CODE (node)]); + pp_string (buffer, get_tree_code_name (TREE_CODE (node))); if (EXPR_P (node)) { @@ -2569,7 +2569,7 @@ dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags, case VEC_WIDEN_LSHIFT_HI_EXPR: case VEC_WIDEN_LSHIFT_LO_EXPR: pp_space (buffer); - for (str = tree_code_name [code]; *str; str++) + for (str = get_tree_code_name (code); *str; str++) pp_character (buffer, TOUPPER (*str)); pp_string (buffer, " < "); dump_generic_node (buffer, TREE_OPERAND (node, 0), spc, flags, false); diff --git a/gcc/tree-pretty-print.h b/gcc/tree-pretty-print.h index f70556db03d..8754b0a2195 100644 --- a/gcc/tree-pretty-print.h +++ b/gcc/tree-pretty-print.h @@ -27,7 +27,7 @@ along with GCC; see the file COPYING3. If not see #define pp_unsupported_tree(PP, T) \ pp_verbatim (PP, "#%qs not supported by %s#", \ - tree_code_name[(int) TREE_CODE (T)], __FUNCTION__) + get_tree_code_name (TREE_CODE (T)), __FUNCTION__) #define pp_ti_abstract_origin(TI) ((tree *) (TI)->x_data) diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index 6292bb0bd56..b2c7e147ef6 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -639,18 +639,18 @@ print_expr_hash_elt (FILE * stream, const struct expr_hash_elt *element) break; case EXPR_UNARY: - fprintf (stream, "%s ", tree_code_name[element->expr.ops.unary.op]); + fprintf (stream, "%s ", get_tree_code_name (element->expr.ops.unary.op)); print_generic_expr (stream, element->expr.ops.unary.opnd, 0); break; case EXPR_BINARY: print_generic_expr (stream, element->expr.ops.binary.opnd0, 0); - fprintf (stream, " %s ", tree_code_name[element->expr.ops.binary.op]); + fprintf (stream, " %s ", get_tree_code_name (element->expr.ops.binary.op)); print_generic_expr (stream, element->expr.ops.binary.opnd1, 0); break; case EXPR_TERNARY: - fprintf (stream, " %s <", tree_code_name[element->expr.ops.ternary.op]); + fprintf (stream, " %s <", get_tree_code_name (element->expr.ops.ternary.op)); print_generic_expr (stream, element->expr.ops.ternary.opnd0, 0); fputs (", ", stream); print_generic_expr (stream, element->expr.ops.ternary.opnd1, 0); diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index 946de8f3d52..4774f39ae7c 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -911,7 +911,7 @@ print_pre_expr (FILE *outfile, const pre_expr expr) { unsigned int i; vn_nary_op_t nary = PRE_EXPR_NARY (expr); - fprintf (outfile, "{%s,", tree_code_name [nary->opcode]); + fprintf (outfile, "{%s,", get_tree_code_name (nary->opcode)); for (i = 0; i < nary->length; i++) { print_generic_expr (outfile, nary->op[i], 0); @@ -936,7 +936,7 @@ print_pre_expr (FILE *outfile, const pre_expr expr) if (vro->opcode != SSA_NAME && TREE_CODE_CLASS (vro->opcode) != tcc_declaration) { - fprintf (outfile, "%s", tree_code_name [vro->opcode]); + fprintf (outfile, "%s", get_tree_code_name (vro->opcode)); if (vro->op0) { fprintf (outfile, "<"); diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c index e7b2f334401..e87e774e5e4 100644 --- a/gcc/tree-vect-data-refs.c +++ b/gcc/tree-vect-data-refs.c @@ -3754,7 +3754,7 @@ vect_create_data_ref_ptr (gimple stmt, tree aggr_type, struct loop *at_loop, tree dr_base_type = TREE_TYPE (DR_BASE_OBJECT (dr)); dump_printf_loc (MSG_NOTE, vect_location, "create %s-pointer variable to type: ", - tree_code_name[(int) TREE_CODE (aggr_type)]); + get_tree_code_name (TREE_CODE (aggr_type))); dump_generic_expr (MSG_NOTE, TDF_SLIM, aggr_type); if (TREE_CODE (dr_base_type) == ARRAY_TYPE) dump_printf (MSG_NOTE, " vectorizing an array ref: "); diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 8b6b91d2183..2bc15812e5a 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -4585,7 +4585,7 @@ dump_asserts_for (FILE *file, tree name) } fprintf (file, "\n\tPREDICATE: "); print_generic_expr (file, name, 0); - fprintf (file, " %s ", tree_code_name[(int)loc->comp_code]); + fprintf (file, " %s ", get_tree_code_name (loc->comp_code)); print_generic_expr (file, loc->val, 0); fprintf (file, "\n\n"); loc = loc->next; diff --git a/gcc/tree.c b/gcc/tree.c index 8b7490dcd98..f1dddb75de9 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -91,7 +91,7 @@ const unsigned char tree_code_length[] = { #define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME, #define END_OF_BASE_TREE_CODES "@dummy", -const char *const tree_code_name[] = { +static const char *const tree_code_name[] = { #include "all-tree.def" }; @@ -9098,7 +9098,8 @@ dump_tree_statistics (void) fprintf (stderr, "Code Nodes\n"); fprintf (stderr, "----------------------------\n"); for (i = 0; i < (int) MAX_TREE_CODES; i++) - fprintf (stderr, "%-20s %7d\n", tree_code_name[i], tree_code_counts[i]); + fprintf (stderr, "%-20s %7d\n", get_tree_code_name ((enum tree_code) i), + tree_code_counts[i]); fprintf (stderr, "----------------------------\n"); ssanames_print_statistics (); phinodes_print_statistics (); @@ -9268,11 +9269,11 @@ tree_check_failed (const_tree node, const char *file, va_list args; const char *buffer; unsigned length = 0; - int code; + enum tree_code code; va_start (args, function); - while ((code = va_arg (args, int))) - length += 4 + strlen (tree_code_name[code]); + while ((code = (enum tree_code) va_arg (args, int))) + length += 4 + strlen (get_tree_code_name (code)); va_end (args); if (length) { @@ -9281,14 +9282,14 @@ tree_check_failed (const_tree node, const char *file, length += strlen ("expected "); buffer = tmp = (char *) alloca (length); length = 0; - while ((code = va_arg (args, int))) + while ((code = (enum tree_code) va_arg (args, int))) { const char *prefix = length ? " or " : "expected "; strcpy (tmp + length, prefix); length += strlen (prefix); - strcpy (tmp + length, tree_code_name[code]); - length += strlen (tree_code_name[code]); + strcpy (tmp + length, get_tree_code_name (code)); + length += strlen (get_tree_code_name (code)); } va_end (args); } @@ -9296,7 +9297,7 @@ tree_check_failed (const_tree node, const char *file, buffer = "unexpected node"; internal_error ("tree check: %s, have %s in %s, at %s:%d", - buffer, tree_code_name[TREE_CODE (node)], + buffer, get_tree_code_name (TREE_CODE (node)), function, trim_filename (file), line); } @@ -9311,29 +9312,29 @@ tree_not_check_failed (const_tree node, const char *file, va_list args; char *buffer; unsigned length = 0; - int code; + enum tree_code code; va_start (args, function); - while ((code = va_arg (args, int))) - length += 4 + strlen (tree_code_name[code]); + while ((code = (enum tree_code) va_arg (args, int))) + length += 4 + strlen (get_tree_code_name (code)); va_end (args); va_start (args, function); buffer = (char *) alloca (length); length = 0; - while ((code = va_arg (args, int))) + while ((code = (enum tree_code) va_arg (args, int))) { if (length) { strcpy (buffer + length, " or "); length += 4; } - strcpy (buffer + length, tree_code_name[code]); - length += strlen (tree_code_name[code]); + strcpy (buffer + length, get_tree_code_name (code)); + length += strlen (get_tree_code_name (code)); } va_end (args); internal_error ("tree check: expected none of %s, have %s in %s, at %s:%d", - buffer, tree_code_name[TREE_CODE (node)], + buffer, get_tree_code_name (TREE_CODE (node)), function, trim_filename (file), line); } @@ -9348,7 +9349,7 @@ tree_class_check_failed (const_tree node, const enum tree_code_class cl, ("tree check: expected class %qs, have %qs (%s) in %s, at %s:%d", TREE_CODE_CLASS_STRING (cl), TREE_CODE_CLASS_STRING (TREE_CODE_CLASS (TREE_CODE (node))), - tree_code_name[TREE_CODE (node)], function, trim_filename (file), line); + get_tree_code_name (TREE_CODE (node)), function, trim_filename (file), line); } /* Similar to tree_check_failed, except that instead of specifying a @@ -9364,7 +9365,7 @@ tree_range_check_failed (const_tree node, const char *file, int line, unsigned int c; for (c = c1; c <= c2; ++c) - length += 4 + strlen (tree_code_name[c]); + length += 4 + strlen (get_tree_code_name ((enum tree_code) c)); length += strlen ("expected "); buffer = (char *) alloca (length); @@ -9376,12 +9377,12 @@ tree_range_check_failed (const_tree node, const char *file, int line, strcpy (buffer + length, prefix); length += strlen (prefix); - strcpy (buffer + length, tree_code_name[c]); - length += strlen (tree_code_name[c]); + strcpy (buffer + length, get_tree_code_name ((enum tree_code) c)); + length += strlen (get_tree_code_name ((enum tree_code) c)); } internal_error ("tree check: %s, have %s in %s, at %s:%d", - buffer, tree_code_name[TREE_CODE (node)], + buffer, get_tree_code_name (TREE_CODE (node)), function, trim_filename (file), line); } @@ -9397,7 +9398,7 @@ tree_not_class_check_failed (const_tree node, const enum tree_code_class cl, ("tree check: did not expect class %qs, have %qs (%s) in %s, at %s:%d", TREE_CODE_CLASS_STRING (cl), TREE_CODE_CLASS_STRING (TREE_CODE_CLASS (TREE_CODE (node))), - tree_code_name[TREE_CODE (node)], function, trim_filename (file), line); + get_tree_code_name (TREE_CODE (node)), function, trim_filename (file), line); } @@ -9408,7 +9409,7 @@ 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", - omp_clause_code_name[code], tree_code_name[TREE_CODE (node)], + omp_clause_code_name[code], get_tree_code_name (TREE_CODE (node)), function, trim_filename (file), line); } @@ -9469,7 +9470,7 @@ tree_contains_struct_check_failed (const_tree node, internal_error ("tree check: expected tree that contains %qs structure, have %qs in %s, at %s:%d", TS_ENUM_NAME (en), - tree_code_name[TREE_CODE (node)], function, trim_filename (file), line); + get_tree_code_name (TREE_CODE (node)), function, trim_filename (file), line); } @@ -9492,10 +9493,10 @@ void tree_operand_check_failed (int idx, const_tree exp, const char *file, int line, const char *function) { - int code = TREE_CODE (exp); + enum tree_code code = TREE_CODE (exp); internal_error ("tree check: accessed operand %d of %s with %d operands in %s, at %s:%d", - idx + 1, tree_code_name[code], TREE_OPERAND_LENGTH (exp), + idx + 1, get_tree_code_name (code), TREE_OPERAND_LENGTH (exp), function, trim_filename (file), line); } @@ -12407,4 +12408,16 @@ using_eh_for_cleanups_p (void) return using_eh_for_cleanups_flag; } +/* Wrapper for tree_code_name to ensure that tree code is valid */ +const char * +get_tree_code_name (enum tree_code code) +{ + const char *invalid = "<invalid tree code>"; + + if (code >= MAX_TREE_CODES) + return invalid; + + return tree_code_name[code]; +} + #include "gt-tree.h" diff --git a/gcc/tree.h b/gcc/tree.h index 6cae818af79..2b6e762cbe8 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -4593,6 +4593,8 @@ extern bool block_may_fallthru (const_tree); extern void using_eh_for_cleanups (void); extern bool using_eh_for_cleanups_p (void); +extern const char *get_tree_code_name (enum tree_code); + /* In tree-nested.c */ extern tree build_addr (tree, tree); |