aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-pretty-print.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2009-05-10 11:28:34 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2009-05-10 11:28:34 +0100
commitf41c4af3d6936f7153b65c23ba80c81f7f8c518e (patch)
treea02bdc44763aa1057cf075a959ca0e50e4188797 /gcc/c-pretty-print.c
parent082b1749a179b056f33db0e6971ad1edeca17cdc (diff)
downloadgcc-f41c4af3d6936f7153b65c23ba80c81f7f8c518e.zip
gcc-f41c4af3d6936f7153b65c23ba80c81f7f8c518e.tar.gz
gcc-f41c4af3d6936f7153b65c23ba80c81f7f8c518e.tar.bz2
pretty-print.h (struct pretty_print_info): Add translate_identifiers.
* pretty-print.h (struct pretty_print_info): Add translate_identifiers. (pp_translate_identifiers): New. (pp_identifier): Only conditionally translate identifier to locale character set. * pretty-print.c (pp_construct): Set pp_translate_identifiers. (pp_base_tree_identifier): Only conditionally translate identifier to locale character set. * c-pretty-print.c (M_): Define. (pp_c_type_specifier, pp_c_primary_expression): Mark English fragments for conditional translation with M_. * tree-pretty-print.c (maybe_init_pretty_print): Disable identifier translation. cp: * call.c (name_as_c_string): Call type_as_string_translate. Translate identifiers to locale character set. * cp-tree.h (lang_decl_name): Update prototype. (type_as_string_translate, decl_as_string_translate, cxx_printable_name_translate): Declare. * cxx-pretty-print.c (M_): Define. (pp_cxx_unqualified_id, pp_cxx_canonical_template_parameter): Mark English fragments for conditional translation with M_. * decl.c (grokdeclarator): Translate identifiers to locale character set for diagnostics. * error.c (M_): Define. (dump_template_bindings, dump_type, dump_aggr_type, dump_type_prefix, dump_global_iord, dump_simple_decl, dump_decl, dump_function_decl, dump_template_parms, dump_expr, dump_binary_op, op_to_string, assop_to_string): Mark English fragments for conditional translation with M_. (type_as_string): Disable translation of identifiers. (type_as_string_translate): New. (expr_as_string): Disable translation of identifiers. (decl_as_string): Disable translation of identifiers. (decl_as_string_translate): New. (lang_decl_name): Add parameter translate. (args_to_string): Call type_as_string_translate. (cp_print_error_function): Call cxx_printable_name_translate. (print_instantiation_full_context, print_instantiation_partial_context): Call decl_as_string_translate. * parser.c (cp_lexer_get_preprocessor_token): Use %qE for identifier in diagnostic. * tree.c (cxx_printable_name): Change to cxx_printable_name_internal. Add parameter translate. (cxx_printable_name, cxx_printable_name_translate): New wrappers round cxx_printable_name_internal. objc: * objc-act.c: Include intl.h. (objc_lookup_protocol): Use complete sentences for diagnostics with %qE for identifiers and translating results of gen_type_name_0 to locale character set. (objc_check_decl, check_protocol_recursively, lookup_and_install_protocols, objc_build_string_object, objc_get_class_reference, objc_declare_alias, objc_declare_class, objc_get_class_ivars, error_with_ivar, check_duplicates, objc_finish_message_expr, objc_build_protocol_expr, objc_build_selector_expr, build_ivar_reference, objc_add_method, add_category, add_instance_variable, objc_is_public, check_methods, check_methods_accessible, check_protocol, start_class, finish_class, start_protocol, really_start_method, get_super_receiver, objc_lookup_ivar): Use %E and %qE for identifiers in diagnostics. Translate generated text to locale character set as needed. (check_protocol, check_protocols): Change name parameter to type tree. (lang_report_error_function): Remove. From-SVN: r147333
Diffstat (limited to 'gcc/c-pretty-print.c')
-rw-r--r--gcc/c-pretty-print.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/gcc/c-pretty-print.c b/gcc/c-pretty-print.c
index efd15ac..f9694bf 100644
--- a/gcc/c-pretty-print.c
+++ b/gcc/c-pretty-print.c
@@ -31,6 +31,10 @@ along with GCC; see the file COPYING3. If not see
#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
@@ -307,7 +311,7 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t)
switch (code)
{
case ERROR_MARK:
- pp_c_ws_string (pp, _("<type-error>"));
+ pp_c_ws_string (pp, M_("<type-error>"));
break;
case IDENTIFIER_NODE:
@@ -346,14 +350,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 ();
@@ -368,7 +372,7 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t)
if (DECL_NAME (t))
pp_id_expression (pp, t);
else
- pp_c_ws_string (pp, _("<typedef-error>"));
+ pp_c_ws_string (pp, M_("<typedef-error>"));
break;
case UNION_TYPE:
@@ -381,12 +385,12 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t)
else if (code == ENUMERAL_TYPE)
pp_c_ws_string (pp, "enum");
else
- pp_c_ws_string (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_ws_string (pp, _("<anonymous>"));
+ pp_c_ws_string (pp, M_("<anonymous>"));
break;
default:
@@ -1119,11 +1123,11 @@ pp_c_primary_expression (c_pretty_printer *pp, tree e)
break;
case ERROR_MARK:
- pp_c_ws_string (pp, _("<erroneous-expression>"));
+ pp_c_ws_string (pp, M_("<erroneous-expression>"));
break;
case RESULT_DECL:
- pp_c_ws_string (pp, _("<return-value>"));
+ pp_c_ws_string (pp, M_("<return-value>"));
break;
case INTEGER_CST: