aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-pretty-print.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2009-05-01 15:09:20 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2009-05-01 15:09:20 +0100
commitb02cec6ee663faf0f8b84d22a23d87a47d0d48c7 (patch)
treec73f9284b0b73f23edef3b10866ccd576c4ddca5 /gcc/c-pretty-print.c
parent3b0249cbff2a0a1edd3a9437df014738a616141d (diff)
downloadgcc-b02cec6ee663faf0f8b84d22a23d87a47d0d48c7.zip
gcc-b02cec6ee663faf0f8b84d22a23d87a47d0d48c7.tar.gz
gcc-b02cec6ee663faf0f8b84d22a23d87a47d0d48c7.tar.bz2
c-objc-common.c (c_tree_printer): Print identifiers with pp_identifier, not pp_string.
* c-objc-common.c (c_tree_printer): Print identifiers with pp_identifier, not pp_string. Mark "({anonymous})" for translation. * c-pretty-print.c (pp_c_ws_string): New. (pp_c_cv_qualifier, pp_c_type_specifier, pp_c_specifier_qualifier_list, pp_c_parameter_type_list, pp_c_storage_class_specifier, pp_c_function_specifier, pp_c_attributes, pp_c_bool_constant, pp_c_constant, pp_c_primary_expression, pp_c_postfix_expression, pp_c_unary_expression, pp_c_shift_expression, pp_c_relational_expression, pp_c_equality_expression, pp_c_logical_and_expression, pp_c_logical_or_expression): Mostly use pp_string and pp_c_ws_string in place of pp_identifier and pp_c_identifier for non-identifiers. Mark English strings for translation. * c-pretty-print.h (pp_c_ws_string): Declare. cp: * cxx-pretty-print.c (is_destructor_name, pp_cxx_unqualified_id, pp_cxx_template_keyword_if_needed, pp_cxx_postfix_expression, pp_cxx_new_expression, pp_cxx_delete_expression, pp_cxx_unary_expression, pp_cxx_assignment_operator, pp_cxx_assignment_expression, pp_cxx_expression, pp_cxx_function_specifier, pp_cxx_decl_specifier_seq, pp_cxx_simple_type_specifier, pp_cxx_type_specifier_seq, pp_cxx_exception_specification, pp_cxx_direct_declarator, pp_cxx_ctor_initializer, pp_cxx_type_id, pp_cxx_statement, pp_cxx_namespace_alias_definition, pp_cxx_template_parameter, pp_cxx_canonical_template_parameter, pp_cxx_template_declaration, pp_cxx_declaration, pp_cxx_typeid_expression, pp_cxx_va_arg_expression, pp_cxx_offsetof_expression, pp_cxx_trait_expression): Mostly use pp_string and pp_cxx_ws_string in place of pp_identifier and pp_cxx_identifier for non-identifiers. Mark English strings for translation. * cxx-pretty-print.h (pp_cxx_ws_string): Define. * error.c (dump_template_parameter, dump_template_bindings, dump_type, dump_aggr_type, dump_type_prefix, dump_simple_decl, dump_decl, dump_template_decl, dump_function_decl, dump_parameters, dump_exception_spec, dump_template_parms, dump_expr, dump_binary_op, dump_unary_op, op_to_string, assop_to_string, args_to_string, cp_print_error_function, print_instantiation_full_context, print_instantiation_partial_context): Mostly use pp_string and pp_cxx_ws_string in place of pp_identifier and pp_cxx_identifier for non-identifiers. Mark English strings for translation. (dump_global_iord): Mark strings for translation; use longer strings instead of substituting single words. (function_category): Return a format string marked for translation, not a single word or phrase to substitute in a longer phrase. From-SVN: r147033
Diffstat (limited to 'gcc/c-pretty-print.c')
-rw-r--r--gcc/c-pretty-print.c108
1 files changed, 61 insertions, 47 deletions
diff --git a/gcc/c-pretty-print.c b/gcc/c-pretty-print.c
index ebfb885..efd15ac 100644
--- a/gcc/c-pretty-print.c
+++ b/gcc/c-pretty-print.c
@@ -25,6 +25,7 @@ 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"
@@ -177,7 +178,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 )'. */
@@ -306,7 +307,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, _("<type-error>"));
break;
case IDENTIFIER_NODE:
@@ -345,14 +346,14 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t)
{
case INTEGER_TYPE:
pp_string (pp, (TYPE_UNSIGNED (t)
- ? "<unnamed-unsigned:"
- : "<unnamed-signed:"));
+ ? _("<unnamed-unsigned:")
+ : _("<unnamed-signed:")));
break;
case REAL_TYPE:
- pp_string (pp, "<unnamed-float:");
+ pp_string (pp, _("<unnamed-float:"));
break;
case FIXED_POINT_TYPE:
- pp_string (pp, "<unnamed-fixed:");
+ pp_string (pp, _("<unnamed-fixed:"));
break;
default:
gcc_unreachable ();
@@ -367,25 +368,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, _("<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, _("<tag-error>"));
if (TYPE_NAME (t))
pp_id_expression (pp, TYPE_NAME (t));
else
- pp_c_identifier (pp, "<anonymous>");
+ pp_c_ws_string (pp, _("<anonymous>"));
break;
default:
@@ -441,9 +442,9 @@ pp_c_specifier_qualifier_list (c_pretty_printer *pp, tree t)
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__");
break;
default:
@@ -471,7 +472,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 +588,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 +605,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 +734,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))
@@ -869,18 +870,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 +1070,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 +1119,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, _("<erroneous-expression>"));
break;
case RESULT_DECL:
- pp_c_identifier (pp, "<return-value>");
+ pp_c_ws_string (pp, _("<return-value>"));
break;
case INTEGER_CST:
@@ -1120,7 +1134,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 +1352,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 +1379,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 +1435,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 +1505,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 +1594,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 +1620,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 +1731,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 +1765,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 +1793,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 +1877,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 +1897,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));
}