aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorPaulo Matos <pmatos@broadcom.com>2013-10-16 10:09:17 +0000
committerPaulo Matos <pmatos@gcc.gnu.org>2013-10-16 12:09:17 +0200
commit5806f4814cd8cd4b6677bde313bd26d5b29ed073 (patch)
tree18b9fdf2590d9183a3aedbda66687c9d2c9b31c8 /gcc/tree.c
parent82c9df56ca621a73781b266d02b589d68a2acf8d (diff)
downloadgcc-5806f4814cd8cd4b6677bde313bd26d5b29ed073.zip
gcc-5806f4814cd8cd4b6677bde313bd26d5b29ed073.tar.gz
gcc-5806f4814cd8cd4b6677bde313bd26d5b29ed073.tar.bz2
tree-core.h (tree_code_name): Remove.
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. From-SVN: r203695
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c65
1 files changed, 39 insertions, 26 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 8b7490d..f1dddb7 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"