| Index: gcc/gcc/c-pretty-print.c
|
| diff --git a/gcc/gcc/c-pretty-print.c b/gcc/gcc/c-pretty-print.c
|
| index ebfb8851ccf0bcad41b15a829bc1cc981d8c79fc..12f1841dd16860f4bf2592e3154fdcdc3907917c 100644
|
| --- a/gcc/gcc/c-pretty-print.c
|
| +++ b/gcc/gcc/c-pretty-print.c
|
| @@ -1,5 +1,5 @@
|
| /* Subroutines common to both C and C++ pretty-printers.
|
| - Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
|
| + Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
|
| Free Software Foundation, Inc.
|
| Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
|
|
|
| @@ -25,11 +25,16 @@ along with GCC; see the file COPYING3. If not see
|
| #include "tm.h"
|
| #include "real.h"
|
| #include "fixed-value.h"
|
| +#include "intl.h"
|
| #include "c-pretty-print.h"
|
| #include "c-tree.h"
|
| #include "tree-iterator.h"
|
| #include "diagnostic.h"
|
|
|
| +/* Translate if being used for diagnostics, but not for dump files or
|
| + __PRETTY_FUNCTION. */
|
| +#define M_(msgid) (pp_translate_identifiers (pp) ? _(msgid) : (msgid))
|
| +
|
| /* The pretty-printer code is primarily designed to closely follow
|
| (GNU) C and C++ grammars. That is to be contrasted with spaghetti
|
| codes we used to have in the past. Following a structured
|
| @@ -177,7 +182,7 @@ pp_c_cv_qualifier (c_pretty_printer *pp, const char *cv)
|
| logic in the C++ pretty-printer. */
|
| if (p != NULL && (*p == '*' || *p == '&'))
|
| pp_c_whitespace (pp);
|
| - pp_c_identifier (pp, cv);
|
| + pp_c_ws_string (pp, cv);
|
| }
|
|
|
| /* Pretty-print T using the type-cast notation '( type-name )'. */
|
| @@ -220,7 +225,11 @@ pp_c_space_for_pointer_operator (c_pretty_printer *pp, tree t)
|
| const
|
| restrict -- C99
|
| __restrict__ -- GNU C
|
| - volatile */
|
| + address-space-qualifier -- GNU C
|
| + volatile
|
| +
|
| + address-space-qualifier:
|
| + identifier -- GNU C */
|
|
|
| void
|
| pp_c_type_qualifier_list (c_pretty_printer *pp, tree t)
|
| @@ -240,6 +249,12 @@ pp_c_type_qualifier_list (c_pretty_printer *pp, tree t)
|
| pp_c_cv_qualifier (pp, "volatile");
|
| if (qualifiers & TYPE_QUAL_RESTRICT)
|
| pp_c_cv_qualifier (pp, flag_isoc99 ? "restrict" : "__restrict__");
|
| +
|
| + if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (t)))
|
| + {
|
| + const char *as = c_addr_space_name (TYPE_ADDR_SPACE (t));
|
| + pp_c_identifier (pp, as);
|
| + }
|
| }
|
|
|
| /* pointer:
|
| @@ -306,7 +321,7 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t)
|
| switch (code)
|
| {
|
| case ERROR_MARK:
|
| - pp_c_identifier (pp, "<type-error>");
|
| + pp_c_ws_string (pp, M_("<type-error>"));
|
| break;
|
|
|
| case IDENTIFIER_NODE:
|
| @@ -345,14 +360,14 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t)
|
| {
|
| case INTEGER_TYPE:
|
| pp_string (pp, (TYPE_UNSIGNED (t)
|
| - ? "<unnamed-unsigned:"
|
| - : "<unnamed-signed:"));
|
| + ? M_("<unnamed-unsigned:")
|
| + : M_("<unnamed-signed:")));
|
| break;
|
| case REAL_TYPE:
|
| - pp_string (pp, "<unnamed-float:");
|
| + pp_string (pp, M_("<unnamed-float:"));
|
| break;
|
| case FIXED_POINT_TYPE:
|
| - pp_string (pp, "<unnamed-fixed:");
|
| + pp_string (pp, M_("<unnamed-fixed:"));
|
| break;
|
| default:
|
| gcc_unreachable ();
|
| @@ -367,25 +382,25 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t)
|
| if (DECL_NAME (t))
|
| pp_id_expression (pp, t);
|
| else
|
| - pp_c_identifier (pp, "<typedef-error>");
|
| + pp_c_ws_string (pp, M_("<typedef-error>"));
|
| break;
|
|
|
| case UNION_TYPE:
|
| case RECORD_TYPE:
|
| case ENUMERAL_TYPE:
|
| if (code == UNION_TYPE)
|
| - pp_c_identifier (pp, "union");
|
| + pp_c_ws_string (pp, "union");
|
| else if (code == RECORD_TYPE)
|
| - pp_c_identifier (pp, "struct");
|
| + pp_c_ws_string (pp, "struct");
|
| else if (code == ENUMERAL_TYPE)
|
| - pp_c_identifier (pp, "enum");
|
| + pp_c_ws_string (pp, "enum");
|
| else
|
| - pp_c_identifier (pp, "<tag-error>");
|
| + pp_c_ws_string (pp, M_("<tag-error>"));
|
|
|
| if (TYPE_NAME (t))
|
| pp_id_expression (pp, TYPE_NAME (t));
|
| else
|
| - pp_c_identifier (pp, "<anonymous>");
|
| + pp_c_ws_string (pp, M_("<anonymous>"));
|
| break;
|
|
|
| default:
|
| @@ -439,11 +454,17 @@ pp_c_specifier_qualifier_list (c_pretty_printer *pp, tree t)
|
|
|
| case VECTOR_TYPE:
|
| case COMPLEX_TYPE:
|
| - pp_c_specifier_qualifier_list (pp, TREE_TYPE (t));
|
| if (code == COMPLEX_TYPE)
|
| - pp_c_identifier (pp, flag_isoc99 ? "_Complex" : "__complex__");
|
| + pp_c_ws_string (pp, flag_isoc99 ? "_Complex" : "__complex__");
|
| else if (code == VECTOR_TYPE)
|
| - pp_c_identifier (pp, "__vector__");
|
| + {
|
| + pp_c_ws_string (pp, "__vector");
|
| + pp_c_left_paren (pp);
|
| + pp_wide_integer (pp, TYPE_VECTOR_SUBPARTS (t));
|
| + pp_c_right_paren (pp);
|
| + pp_c_whitespace (pp);
|
| + }
|
| + pp_c_specifier_qualifier_list (pp, TREE_TYPE (t));
|
| break;
|
|
|
| default:
|
| @@ -471,7 +492,7 @@ pp_c_parameter_type_list (c_pretty_printer *pp, tree t)
|
| tree parms = want_parm_decl ? DECL_ARGUMENTS (t) : TYPE_ARG_TYPES (t);
|
| pp_c_left_paren (pp);
|
| if (parms == void_list_node)
|
| - pp_c_identifier (pp, "void");
|
| + pp_c_ws_string (pp, "void");
|
| else
|
| {
|
| bool first = true;
|
| @@ -587,13 +608,13 @@ void
|
| pp_c_storage_class_specifier (c_pretty_printer *pp, tree t)
|
| {
|
| if (TREE_CODE (t) == TYPE_DECL)
|
| - pp_c_identifier (pp, "typedef");
|
| + pp_c_ws_string (pp, "typedef");
|
| else if (DECL_P (t))
|
| {
|
| if (DECL_REGISTER (t))
|
| - pp_c_identifier (pp, "register");
|
| + pp_c_ws_string (pp, "register");
|
| else if (TREE_STATIC (t) && TREE_CODE (t) == VAR_DECL)
|
| - pp_c_identifier (pp, "static");
|
| + pp_c_ws_string (pp, "static");
|
| }
|
| }
|
|
|
| @@ -604,7 +625,7 @@ void
|
| pp_c_function_specifier (c_pretty_printer *pp, tree t)
|
| {
|
| if (TREE_CODE (t) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (t))
|
| - pp_c_identifier (pp, "inline");
|
| + pp_c_ws_string (pp, "inline");
|
| }
|
|
|
| /* declaration-specifiers:
|
| @@ -733,7 +754,7 @@ pp_c_attributes (c_pretty_printer *pp, tree attributes)
|
| if (attributes == NULL_TREE)
|
| return;
|
|
|
| - pp_c_identifier (pp, "__attribute__");
|
| + pp_c_ws_string (pp, "__attribute__");
|
| pp_c_left_paren (pp);
|
| pp_c_left_paren (pp);
|
| for (; attributes != NULL_TREE; attributes = TREE_CHAIN (attributes))
|
| @@ -832,7 +853,7 @@ pp_c_integer_constant (c_pretty_printer *pp, tree i)
|
| high = ~high + !low;
|
| low = -low;
|
| }
|
| - sprintf (pp_buffer (pp)->digit_buffer, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
|
| + sprintf (pp_buffer (pp)->digit_buffer, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
|
| (unsigned HOST_WIDE_INT) high, (unsigned HOST_WIDE_INT) low);
|
| pp_string (pp, pp_buffer (pp)->digit_buffer);
|
| }
|
| @@ -869,18 +890,18 @@ pp_c_bool_constant (c_pretty_printer *pp, tree b)
|
| if (b == boolean_false_node)
|
| {
|
| if (c_dialect_cxx ())
|
| - pp_c_identifier (pp, "false");
|
| + pp_c_ws_string (pp, "false");
|
| else if (flag_isoc99)
|
| - pp_c_identifier (pp, "_False");
|
| + pp_c_ws_string (pp, "_False");
|
| else
|
| pp_unsupported_tree (pp, b);
|
| }
|
| else if (b == boolean_true_node)
|
| {
|
| if (c_dialect_cxx ())
|
| - pp_c_identifier (pp, "true");
|
| + pp_c_ws_string (pp, "true");
|
| else if (flag_isoc99)
|
| - pp_c_identifier (pp, "_True");
|
| + pp_c_ws_string (pp, "_True");
|
| else
|
| pp_unsupported_tree (pp, b);
|
| }
|
| @@ -1069,7 +1090,20 @@ pp_c_constant (c_pretty_printer *pp, tree e)
|
| }
|
| }
|
|
|
| -/* Pretty-print an IDENTIFIER_NODE, preceded by whitespace is necessary. */
|
| +/* Pretty-print a string such as an identifier, without changing its
|
| + encoding, preceded by whitespace is necessary. */
|
| +
|
| +void
|
| +pp_c_ws_string (c_pretty_printer *pp, const char *str)
|
| +{
|
| + pp_c_maybe_whitespace (pp);
|
| + pp_string (pp, str);
|
| + pp_base (pp)->padding = pp_before;
|
| +}
|
| +
|
| +/* Pretty-print an IDENTIFIER_NODE, which may contain UTF-8 sequences
|
| + that need converting to the locale encoding, preceded by whitespace
|
| + is necessary. */
|
|
|
| void
|
| pp_c_identifier (c_pretty_printer *pp, const char *id)
|
| @@ -1105,11 +1139,11 @@ pp_c_primary_expression (c_pretty_printer *pp, tree e)
|
| break;
|
|
|
| case ERROR_MARK:
|
| - pp_c_identifier (pp, "<erroneous-expression>");
|
| + pp_c_ws_string (pp, M_("<erroneous-expression>"));
|
| break;
|
|
|
| case RESULT_DECL:
|
| - pp_c_identifier (pp, "<return-value>");
|
| + pp_c_ws_string (pp, M_("<return-value>"));
|
| break;
|
|
|
| case INTEGER_CST:
|
| @@ -1120,7 +1154,7 @@ pp_c_primary_expression (c_pretty_printer *pp, tree e)
|
| break;
|
|
|
| case TARGET_EXPR:
|
| - pp_c_identifier (pp, "__builtin_memcpy");
|
| + pp_c_ws_string (pp, "__builtin_memcpy");
|
| pp_c_left_paren (pp);
|
| pp_ampersand (pp);
|
| pp_primary_expression (pp, TREE_OPERAND (e, 0));
|
| @@ -1338,7 +1372,7 @@ pp_c_postfix_expression (c_pretty_printer *pp, tree e)
|
| case POSTINCREMENT_EXPR:
|
| case POSTDECREMENT_EXPR:
|
| pp_postfix_expression (pp, TREE_OPERAND (e, 0));
|
| - pp_identifier (pp, code == POSTINCREMENT_EXPR ? "++" : "--");
|
| + pp_string (pp, code == POSTINCREMENT_EXPR ? "++" : "--");
|
| break;
|
|
|
| case ARRAY_REF:
|
| @@ -1365,49 +1399,49 @@ pp_c_postfix_expression (c_pretty_printer *pp, tree e)
|
| }
|
|
|
| case UNORDERED_EXPR:
|
| - pp_c_identifier (pp, flag_isoc99
|
| + pp_c_ws_string (pp, flag_isoc99
|
| ? "isunordered"
|
| : "__builtin_isunordered");
|
| goto two_args_fun;
|
|
|
| case ORDERED_EXPR:
|
| - pp_c_identifier (pp, flag_isoc99
|
| + pp_c_ws_string (pp, flag_isoc99
|
| ? "!isunordered"
|
| : "!__builtin_isunordered");
|
| goto two_args_fun;
|
|
|
| case UNLT_EXPR:
|
| - pp_c_identifier (pp, flag_isoc99
|
| + pp_c_ws_string (pp, flag_isoc99
|
| ? "!isgreaterequal"
|
| : "!__builtin_isgreaterequal");
|
| goto two_args_fun;
|
|
|
| case UNLE_EXPR:
|
| - pp_c_identifier (pp, flag_isoc99
|
| + pp_c_ws_string (pp, flag_isoc99
|
| ? "!isgreater"
|
| : "!__builtin_isgreater");
|
| goto two_args_fun;
|
|
|
| case UNGT_EXPR:
|
| - pp_c_identifier (pp, flag_isoc99
|
| + pp_c_ws_string (pp, flag_isoc99
|
| ? "!islessequal"
|
| : "!__builtin_islessequal");
|
| goto two_args_fun;
|
|
|
| case UNGE_EXPR:
|
| - pp_c_identifier (pp, flag_isoc99
|
| + pp_c_ws_string (pp, flag_isoc99
|
| ? "!isless"
|
| : "!__builtin_isless");
|
| goto two_args_fun;
|
|
|
| case UNEQ_EXPR:
|
| - pp_c_identifier (pp, flag_isoc99
|
| + pp_c_ws_string (pp, flag_isoc99
|
| ? "!islessgreater"
|
| : "!__builtin_islessgreater");
|
| goto two_args_fun;
|
|
|
| case LTGT_EXPR:
|
| - pp_c_identifier (pp, flag_isoc99
|
| + pp_c_ws_string (pp, flag_isoc99
|
| ? "islessgreater"
|
| : "__builtin_islessgreater");
|
| goto two_args_fun;
|
| @@ -1421,7 +1455,7 @@ pp_c_postfix_expression (c_pretty_printer *pp, tree e)
|
| break;
|
|
|
| case ABS_EXPR:
|
| - pp_c_identifier (pp, "__builtin_abs");
|
| + pp_c_ws_string (pp, "__builtin_abs");
|
| pp_c_left_paren (pp);
|
| pp_expression (pp, TREE_OPERAND (e, 0));
|
| pp_c_right_paren (pp);
|
| @@ -1491,7 +1525,7 @@ pp_c_postfix_expression (c_pretty_printer *pp, tree e)
|
| break;
|
|
|
| case VA_ARG_EXPR:
|
| - pp_c_identifier (pp, "__builtin_va_arg");
|
| + pp_c_ws_string (pp, "__builtin_va_arg");
|
| pp_c_left_paren (pp);
|
| pp_assignment_expression (pp, TREE_OPERAND (e, 0));
|
| pp_separate_with (pp, ',');
|
| @@ -1580,7 +1614,7 @@ pp_c_unary_expression (c_pretty_printer *pp, tree e)
|
| {
|
| case PREINCREMENT_EXPR:
|
| case PREDECREMENT_EXPR:
|
| - pp_identifier (pp, code == PREINCREMENT_EXPR ? "++" : "--");
|
| + pp_string (pp, code == PREINCREMENT_EXPR ? "++" : "--");
|
| pp_c_unary_expression (pp, TREE_OPERAND (e, 0));
|
| break;
|
|
|
| @@ -1606,7 +1640,7 @@ pp_c_unary_expression (c_pretty_printer *pp, tree e)
|
|
|
| case REALPART_EXPR:
|
| case IMAGPART_EXPR:
|
| - pp_c_identifier (pp, code == REALPART_EXPR ? "__real__" : "__imag__");
|
| + pp_c_ws_string (pp, code == REALPART_EXPR ? "__real__" : "__imag__");
|
| pp_c_whitespace (pp);
|
| pp_unary_expression (pp, TREE_OPERAND (e, 0));
|
| break;
|
| @@ -1717,7 +1751,7 @@ pp_c_shift_expression (c_pretty_printer *pp, tree e)
|
| case RSHIFT_EXPR:
|
| pp_c_shift_expression (pp, TREE_OPERAND (e, 0));
|
| pp_c_whitespace (pp);
|
| - pp_identifier (pp, code == LSHIFT_EXPR ? "<<" : ">>");
|
| + pp_string (pp, code == LSHIFT_EXPR ? "<<" : ">>");
|
| pp_c_whitespace (pp);
|
| pp_c_additive_expression (pp, TREE_OPERAND (e, 1));
|
| break;
|
| @@ -1751,9 +1785,9 @@ pp_c_relational_expression (c_pretty_printer *pp, tree e)
|
| else if (code == GT_EXPR)
|
| pp_greater (pp);
|
| else if (code == LE_EXPR)
|
| - pp_identifier (pp, "<=");
|
| + pp_string (pp, "<=");
|
| else if (code == GE_EXPR)
|
| - pp_identifier (pp, ">=");
|
| + pp_string (pp, ">=");
|
| pp_c_whitespace (pp);
|
| pp_c_shift_expression (pp, TREE_OPERAND (e, 1));
|
| break;
|
| @@ -1779,7 +1813,7 @@ pp_c_equality_expression (c_pretty_printer *pp, tree e)
|
| case NE_EXPR:
|
| pp_c_equality_expression (pp, TREE_OPERAND (e, 0));
|
| pp_c_whitespace (pp);
|
| - pp_identifier (pp, code == EQ_EXPR ? "==" : "!=");
|
| + pp_string (pp, code == EQ_EXPR ? "==" : "!=");
|
| pp_c_whitespace (pp);
|
| pp_c_relational_expression (pp, TREE_OPERAND (e, 1));
|
| break;
|
| @@ -1863,7 +1897,7 @@ pp_c_logical_and_expression (c_pretty_printer *pp, tree e)
|
| {
|
| pp_c_logical_and_expression (pp, TREE_OPERAND (e, 0));
|
| pp_c_whitespace (pp);
|
| - pp_identifier (pp, "&&");
|
| + pp_string (pp, "&&");
|
| pp_c_whitespace (pp);
|
| pp_c_inclusive_or_expression (pp, TREE_OPERAND (e, 1));
|
| }
|
| @@ -1883,7 +1917,7 @@ pp_c_logical_or_expression (c_pretty_printer *pp, tree e)
|
| {
|
| pp_c_logical_or_expression (pp, TREE_OPERAND (e, 0));
|
| pp_c_whitespace (pp);
|
| - pp_identifier (pp, "||");
|
| + pp_string (pp, "||");
|
| pp_c_whitespace (pp);
|
| pp_c_logical_and_expression (pp, TREE_OPERAND (e, 1));
|
| }
|
| @@ -1925,7 +1959,7 @@ pp_c_conditional_expression (c_pretty_printer *pp, tree e)
|
| static void
|
| pp_c_assignment_expression (c_pretty_printer *pp, tree e)
|
| {
|
| - if (TREE_CODE (e) == MODIFY_EXPR
|
| + if (TREE_CODE (e) == MODIFY_EXPR
|
| || TREE_CODE (e) == INIT_EXPR)
|
| {
|
| pp_c_unary_expression (pp, TREE_OPERAND (e, 0));
|
| @@ -2217,7 +2251,7 @@ pp_c_tree_decl_identifier (c_pretty_printer *pp, tree t)
|
| else
|
| {
|
| static char xname[8];
|
| - sprintf (xname, "<U%4x>", ((unsigned)((unsigned long)(t) & 0xffff)));
|
| + sprintf (xname, "<U%4x>", ((unsigned)((uintptr_t)(t) & 0xffff)));
|
| name = xname;
|
| }
|
|
|
|
|