From fa40aa121c3dd227bff080afa7a2f6e24b6c0c80 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Fri, 18 Aug 2000 09:15:51 +0000 Subject: cp-tree.h (enum_name_string): Remove prototype. * cp-tree.h (enum_name_string): Remove prototype. (report_case_error): Remove prototype. * cp/typeck2.c (enum_name_string): Remove. (report_case_error): Remove. * error.c (dump_expr): Deal with enum values directly. Correctly negate integer constant. From-SVN: r35774 --- gcc/cp/error.c | 64 ++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 22 deletions(-) (limited to 'gcc/cp/error.c') diff --git a/gcc/cp/error.c b/gcc/cp/error.c index fb8ff38..b8063b3 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -1469,8 +1469,23 @@ dump_expr (t, flags) /* If it's an enum, output its tag, rather than its value. */ if (TREE_CODE (type) == ENUMERAL_TYPE) { - const char *p = enum_name_string (t, type); - OB_PUTCP (p); + tree values = TYPE_VALUES (type); + + for (; values; + values = TREE_CHAIN (values)) + if (tree_int_cst_equal (TREE_VALUE (values), t)) + break; + + if (values) + OB_PUTID (TREE_PURPOSE (values)); + else + { + /* Value must have been cast. */ + OB_PUTC ('('); + dump_type (type, flags); + OB_PUTC (')'); + goto do_int; + } } else if (type == boolean_type_node) { @@ -1485,30 +1500,35 @@ dump_expr (t, flags) dump_char (tree_low_cst (t, 0)); OB_PUTC ('\''); } - else if ((unsigned HOST_WIDE_INT) TREE_INT_CST_HIGH (t) - != (TREE_INT_CST_LOW (t) >> (HOST_BITS_PER_WIDE_INT - 1))) + else { - tree val = t; - - if (tree_int_cst_sgn (val) < 0) + do_int: + if ((unsigned HOST_WIDE_INT) TREE_INT_CST_HIGH (t) + != (TREE_INT_CST_LOW (t) >> (HOST_BITS_PER_WIDE_INT - 1))) { - OB_PUTC ('-'); - val = build_int_2 (~TREE_INT_CST_LOW (val), - -TREE_INT_CST_HIGH (val)); + tree val = t; + + if (tree_int_cst_sgn (val) < 0) + { + OB_PUTC ('-'); + val = build_int_2 (-TREE_INT_CST_LOW (val), + ~TREE_INT_CST_HIGH (val) + + !TREE_INT_CST_LOW (val)); + } + /* Would "%x%0*x" or "%x%*0x" get zero-padding on all + systems? */ + { + static char format[10]; /* "%x%09999x\0" */ + if (!format[0]) + sprintf (format, "%%x%%0%dx", HOST_BITS_PER_INT / 4); + sprintf (digit_buffer, format, TREE_INT_CST_HIGH (val), + TREE_INT_CST_LOW (val)); + OB_PUTCP (digit_buffer); + } } - /* Would "%x%0*x" or "%x%*0x" get zero-padding on all - systems? */ - { - static char format[10]; /* "%x%09999x\0" */ - if (!format[0]) - sprintf (format, "%%x%%0%dx", HOST_BITS_PER_INT / 4); - sprintf (digit_buffer, format, TREE_INT_CST_HIGH (val), - TREE_INT_CST_LOW (val)); - OB_PUTCP (digit_buffer); - } + else + OB_PUTI (TREE_INT_CST_LOW (t)); } - else - OB_PUTI (TREE_INT_CST_LOW (t)); } break; -- cgit v1.1