Commit f41c4af3 by Joseph Myers Committed by Joseph Myers

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
parent 082b1749
2009-05-10 Joseph Myers <joseph@codesourcery.com>
* 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.
2009-05-10 Richard Guenther <rguenther@suse.de> 2009-05-10 Richard Guenther <rguenther@suse.de>
PR tree-optimization/40081 PR tree-optimization/40081
......
...@@ -31,6 +31,10 @@ along with GCC; see the file COPYING3. If not see ...@@ -31,6 +31,10 @@ along with GCC; see the file COPYING3. If not see
#include "tree-iterator.h" #include "tree-iterator.h"
#include "diagnostic.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 /* The pretty-printer code is primarily designed to closely follow
(GNU) C and C++ grammars. That is to be contrasted with spaghetti (GNU) C and C++ grammars. That is to be contrasted with spaghetti
codes we used to have in the past. Following a structured 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) ...@@ -307,7 +311,7 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t)
switch (code) switch (code)
{ {
case ERROR_MARK: case ERROR_MARK:
pp_c_ws_string (pp, _("<type-error>")); pp_c_ws_string (pp, M_("<type-error>"));
break; break;
case IDENTIFIER_NODE: case IDENTIFIER_NODE:
...@@ -346,14 +350,14 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t) ...@@ -346,14 +350,14 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t)
{ {
case INTEGER_TYPE: case INTEGER_TYPE:
pp_string (pp, (TYPE_UNSIGNED (t) pp_string (pp, (TYPE_UNSIGNED (t)
? _("<unnamed-unsigned:") ? M_("<unnamed-unsigned:")
: _("<unnamed-signed:"))); : M_("<unnamed-signed:")));
break; break;
case REAL_TYPE: case REAL_TYPE:
pp_string (pp, _("<unnamed-float:")); pp_string (pp, M_("<unnamed-float:"));
break; break;
case FIXED_POINT_TYPE: case FIXED_POINT_TYPE:
pp_string (pp, _("<unnamed-fixed:")); pp_string (pp, M_("<unnamed-fixed:"));
break; break;
default: default:
gcc_unreachable (); gcc_unreachable ();
...@@ -368,7 +372,7 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t) ...@@ -368,7 +372,7 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t)
if (DECL_NAME (t)) if (DECL_NAME (t))
pp_id_expression (pp, t); pp_id_expression (pp, t);
else else
pp_c_ws_string (pp, _("<typedef-error>")); pp_c_ws_string (pp, M_("<typedef-error>"));
break; break;
case UNION_TYPE: case UNION_TYPE:
...@@ -381,12 +385,12 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t) ...@@ -381,12 +385,12 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t)
else if (code == ENUMERAL_TYPE) else if (code == ENUMERAL_TYPE)
pp_c_ws_string (pp, "enum"); pp_c_ws_string (pp, "enum");
else else
pp_c_ws_string (pp, _("<tag-error>")); pp_c_ws_string (pp, M_("<tag-error>"));
if (TYPE_NAME (t)) if (TYPE_NAME (t))
pp_id_expression (pp, TYPE_NAME (t)); pp_id_expression (pp, TYPE_NAME (t));
else else
pp_c_ws_string (pp, _("<anonymous>")); pp_c_ws_string (pp, M_("<anonymous>"));
break; break;
default: default:
...@@ -1119,11 +1123,11 @@ pp_c_primary_expression (c_pretty_printer *pp, tree e) ...@@ -1119,11 +1123,11 @@ pp_c_primary_expression (c_pretty_printer *pp, tree e)
break; break;
case ERROR_MARK: case ERROR_MARK:
pp_c_ws_string (pp, _("<erroneous-expression>")); pp_c_ws_string (pp, M_("<erroneous-expression>"));
break; break;
case RESULT_DECL: case RESULT_DECL:
pp_c_ws_string (pp, _("<return-value>")); pp_c_ws_string (pp, M_("<return-value>"));
break; break;
case INTEGER_CST: case INTEGER_CST:
......
2009-05-10 Joseph Myers <joseph@codesourcery.com>
* 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.
2009-05-08 H.J. Lu <hongjiu.lu@intel.com> 2009-05-08 H.J. Lu <hongjiu.lu@intel.com>
PR c/36892 PR c/36892
......
...@@ -5731,7 +5731,7 @@ name_as_c_string (tree name, tree type, bool *free_p) ...@@ -5731,7 +5731,7 @@ name_as_c_string (tree name, tree type, bool *free_p)
if (IDENTIFIER_CTOR_OR_DTOR_P (name)) if (IDENTIFIER_CTOR_OR_DTOR_P (name))
{ {
pretty_name pretty_name
= CONST_CAST (char *, IDENTIFIER_POINTER (constructor_name (type))); = CONST_CAST (char *, identifier_to_locale (IDENTIFIER_POINTER (constructor_name (type))));
/* For a destructor, add the '~'. */ /* For a destructor, add the '~'. */
if (name == complete_dtor_identifier if (name == complete_dtor_identifier
|| name == base_dtor_identifier || name == base_dtor_identifier
...@@ -5745,14 +5745,14 @@ name_as_c_string (tree name, tree type, bool *free_p) ...@@ -5745,14 +5745,14 @@ name_as_c_string (tree name, tree type, bool *free_p)
else if (IDENTIFIER_TYPENAME_P (name)) else if (IDENTIFIER_TYPENAME_P (name))
{ {
pretty_name = concat ("operator ", pretty_name = concat ("operator ",
type_as_string (TREE_TYPE (name), type_as_string_translate (TREE_TYPE (name),
TFF_PLAIN_IDENTIFIER), TFF_PLAIN_IDENTIFIER),
NULL); NULL);
/* Remember that we need to free the memory allocated. */ /* Remember that we need to free the memory allocated. */
*free_p = true; *free_p = true;
} }
else else
pretty_name = CONST_CAST (char *, IDENTIFIER_POINTER (name)); pretty_name = CONST_CAST (char *, identifier_to_locale (IDENTIFIER_POINTER (name)));
return pretty_name; return pretty_name;
} }
......
...@@ -4422,9 +4422,11 @@ extern int parm_index (tree); ...@@ -4422,9 +4422,11 @@ extern int parm_index (tree);
/* in error.c */ /* in error.c */
extern void init_error (void); extern void init_error (void);
extern const char *type_as_string (tree, int); extern const char *type_as_string (tree, int);
extern const char *type_as_string_translate (tree, int);
extern const char *decl_as_string (tree, int); extern const char *decl_as_string (tree, int);
extern const char *decl_as_string_translate (tree, int);
extern const char *expr_as_string (tree, int); extern const char *expr_as_string (tree, int);
extern const char *lang_decl_name (tree, int); extern const char *lang_decl_name (tree, int, bool);
extern const char *language_to_string (enum languages); extern const char *language_to_string (enum languages);
extern const char *class_key_or_enum_as_string (tree); extern const char *class_key_or_enum_as_string (tree);
extern void print_instantiation_context (void); extern void print_instantiation_context (void);
...@@ -4839,6 +4841,7 @@ extern tree get_first_fn (tree); ...@@ -4839,6 +4841,7 @@ extern tree get_first_fn (tree);
extern tree ovl_cons (tree, tree); extern tree ovl_cons (tree, tree);
extern tree build_overload (tree, tree); extern tree build_overload (tree, tree);
extern const char *cxx_printable_name (tree, int); extern const char *cxx_printable_name (tree, int);
extern const char *cxx_printable_name_translate (tree, int);
extern tree build_exception_variant (tree, tree); extern tree build_exception_variant (tree, tree);
extern tree bind_template_template_parm (tree, tree); extern tree bind_template_template_parm (tree, tree);
extern tree array_type_nelts_total (tree); extern tree array_type_nelts_total (tree);
......
...@@ -29,6 +29,10 @@ along with GCC; see the file COPYING3. If not see ...@@ -29,6 +29,10 @@ along with GCC; see the file COPYING3. If not see
#include "cp-tree.h" #include "cp-tree.h"
#include "toplev.h" #include "toplev.h"
/* Translate if being used for diagnostics, but not for dump files or
__PRETTY_FUNCTION. */
#define M_(msgid) (pp_translate_identifiers (pp) ? _(msgid) : (msgid))
static void pp_cxx_unqualified_id (cxx_pretty_printer *, tree); static void pp_cxx_unqualified_id (cxx_pretty_printer *, tree);
static void pp_cxx_nested_name_specifier (cxx_pretty_printer *, tree); static void pp_cxx_nested_name_specifier (cxx_pretty_printer *, tree);
static void pp_cxx_qualified_id (cxx_pretty_printer *, tree); static void pp_cxx_qualified_id (cxx_pretty_printer *, tree);
...@@ -147,7 +151,7 @@ pp_cxx_unqualified_id (cxx_pretty_printer *pp, tree t) ...@@ -147,7 +151,7 @@ pp_cxx_unqualified_id (cxx_pretty_printer *pp, tree t)
switch (code) switch (code)
{ {
case RESULT_DECL: case RESULT_DECL:
pp_cxx_ws_string (pp, _("<return-value>")); pp_cxx_ws_string (pp, M_("<return-value>"));
break; break;
case OVERLOAD: case OVERLOAD:
...@@ -166,7 +170,7 @@ pp_cxx_unqualified_id (cxx_pretty_printer *pp, tree t) ...@@ -166,7 +170,7 @@ pp_cxx_unqualified_id (cxx_pretty_printer *pp, tree t)
case IDENTIFIER_NODE: case IDENTIFIER_NODE:
if (t == NULL) if (t == NULL)
pp_cxx_ws_string (pp, _("<unnamed>")); pp_cxx_ws_string (pp, M_("<unnamed>"));
else if (IDENTIFIER_TYPENAME_P (t)) else if (IDENTIFIER_TYPENAME_P (t))
pp_cxx_conversion_function_id (pp, t); pp_cxx_conversion_function_id (pp, t);
else else
...@@ -2048,7 +2052,7 @@ pp_cxx_canonical_template_parameter (cxx_pretty_printer *pp, tree parm) ...@@ -2048,7 +2052,7 @@ pp_cxx_canonical_template_parameter (cxx_pretty_printer *pp, tree parm)
parm = TEMPLATE_TYPE_PARM_INDEX (parm); parm = TEMPLATE_TYPE_PARM_INDEX (parm);
pp_cxx_begin_template_argument_list (pp); pp_cxx_begin_template_argument_list (pp);
pp_cxx_ws_string (pp, _("template-parameter-")); pp_cxx_ws_string (pp, M_("template-parameter-"));
pp_wide_integer (pp, TEMPLATE_PARM_LEVEL (parm)); pp_wide_integer (pp, TEMPLATE_PARM_LEVEL (parm));
pp_minus (pp); pp_minus (pp);
pp_wide_integer (pp, TEMPLATE_PARM_IDX (parm) + 1); pp_wide_integer (pp, TEMPLATE_PARM_IDX (parm) + 1);
......
...@@ -7701,7 +7701,7 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -7701,7 +7701,7 @@ grokdeclarator (const cp_declarator *declarator,
type = TREE_OPERAND (decl, 0); type = TREE_OPERAND (decl, 0);
if (TYPE_P (type)) if (TYPE_P (type))
type = constructor_name (type); type = constructor_name (type);
name = IDENTIFIER_POINTER (type); name = identifier_to_locale (IDENTIFIER_POINTER (type));
dname = decl; dname = decl;
} }
break; break;
...@@ -7727,10 +7727,10 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -7727,10 +7727,10 @@ grokdeclarator (const cp_declarator *declarator,
{ {
error ("declarator-id missing; using reserved word %qD", error ("declarator-id missing; using reserved word %qD",
dname); dname);
name = IDENTIFIER_POINTER (dname); name = identifier_to_locale (IDENTIFIER_POINTER (dname));
} }
else if (!IDENTIFIER_TYPENAME_P (dname)) else if (!IDENTIFIER_TYPENAME_P (dname))
name = IDENTIFIER_POINTER (dname); name = identifier_to_locale (IDENTIFIER_POINTER (dname));
else else
{ {
gcc_assert (flags == NO_SPECIAL); gcc_assert (flags == NO_SPECIAL);
...@@ -7738,7 +7738,7 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -7738,7 +7738,7 @@ grokdeclarator (const cp_declarator *declarator,
ctor_return_type = TREE_TYPE (dname); ctor_return_type = TREE_TYPE (dname);
sfk = sfk_conversion; sfk = sfk_conversion;
if (is_typename_at_global_scope (dname)) if (is_typename_at_global_scope (dname))
name = IDENTIFIER_POINTER (dname); name = identifier_to_locale (IDENTIFIER_POINTER (dname));
else else
name = "<invalid operator>"; name = "<invalid operator>";
} }
......
...@@ -428,8 +428,8 @@ cp_lexer_get_preprocessor_token (cp_lexer *lexer, cp_token *token) ...@@ -428,8 +428,8 @@ cp_lexer_get_preprocessor_token (cp_lexer *lexer, cp_token *token)
/* Warn about the C++0x keyword (but still treat it as /* Warn about the C++0x keyword (but still treat it as
an identifier). */ an identifier). */
warning (OPT_Wc__0x_compat, warning (OPT_Wc__0x_compat,
"identifier %<%s%> will become a keyword in C++0x", "identifier %qE will become a keyword in C++0x",
IDENTIFIER_POINTER (token->u.value)); token->u.value);
/* Clear out the C_RID_CODE so we don't warn about this /* Clear out the C_RID_CODE so we don't warn about this
particular identifier-turned-keyword again. */ particular identifier-turned-keyword again. */
......
...@@ -1238,11 +1238,12 @@ build_overload (tree decl, tree chain) ...@@ -1238,11 +1238,12 @@ build_overload (tree decl, tree chain)
#define PRINT_RING_SIZE 4 #define PRINT_RING_SIZE 4
const char * static const char *
cxx_printable_name (tree decl, int v) cxx_printable_name_internal (tree decl, int v, bool translate)
{ {
static unsigned int uid_ring[PRINT_RING_SIZE]; static unsigned int uid_ring[PRINT_RING_SIZE];
static char *print_ring[PRINT_RING_SIZE]; static char *print_ring[PRINT_RING_SIZE];
static bool trans_ring[PRINT_RING_SIZE];
static int ring_counter; static int ring_counter;
int i; int i;
...@@ -1250,11 +1251,11 @@ cxx_printable_name (tree decl, int v) ...@@ -1250,11 +1251,11 @@ cxx_printable_name (tree decl, int v)
if (v < 2 if (v < 2
|| TREE_CODE (decl) != FUNCTION_DECL || TREE_CODE (decl) != FUNCTION_DECL
|| DECL_LANG_SPECIFIC (decl) == 0) || DECL_LANG_SPECIFIC (decl) == 0)
return lang_decl_name (decl, v); return lang_decl_name (decl, v, translate);
/* See if this print name is lying around. */ /* See if this print name is lying around. */
for (i = 0; i < PRINT_RING_SIZE; i++) for (i = 0; i < PRINT_RING_SIZE; i++)
if (uid_ring[i] == DECL_UID (decl)) if (uid_ring[i] == DECL_UID (decl) && translate == trans_ring[i])
/* yes, so return it. */ /* yes, so return it. */
return print_ring[i]; return print_ring[i];
...@@ -1273,10 +1274,23 @@ cxx_printable_name (tree decl, int v) ...@@ -1273,10 +1274,23 @@ cxx_printable_name (tree decl, int v)
if (print_ring[ring_counter]) if (print_ring[ring_counter])
free (print_ring[ring_counter]); free (print_ring[ring_counter]);
print_ring[ring_counter] = xstrdup (lang_decl_name (decl, v)); print_ring[ring_counter] = xstrdup (lang_decl_name (decl, v, translate));
uid_ring[ring_counter] = DECL_UID (decl); uid_ring[ring_counter] = DECL_UID (decl);
trans_ring[ring_counter] = translate;
return print_ring[ring_counter]; return print_ring[ring_counter];
} }
const char *
cxx_printable_name (tree decl, int v)
{
return cxx_printable_name_internal (decl, v, false);
}
const char *
cxx_printable_name_translate (tree decl, int v)
{
return cxx_printable_name_internal (decl, v, true);
}
/* Build the FUNCTION_TYPE or METHOD_TYPE which may throw exceptions /* Build the FUNCTION_TYPE or METHOD_TYPE which may throw exceptions
listed in RAISES. */ listed in RAISES. */
......
2009-05-10 Joseph Myers <joseph@codesourcery.com>
* 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.
2009-04-27 Ian Lance Taylor <iant@google.com> 2009-04-27 Ian Lance Taylor <iant@google.com>
* objc-act.c (objc_gimplify_expr): Add casts to enum type. * objc-act.c (objc_gimplify_expr): Add casts to enum type.
......
...@@ -719,6 +719,7 @@ pp_construct (pretty_printer *pp, const char *prefix, int maximum_length) ...@@ -719,6 +719,7 @@ pp_construct (pretty_printer *pp, const char *prefix, int maximum_length)
pp_line_cutoff (pp) = maximum_length; pp_line_cutoff (pp) = maximum_length;
pp_prefixing_rule (pp) = DIAGNOSTICS_SHOW_PREFIX_ONCE; pp_prefixing_rule (pp) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
pp_set_prefix (pp, prefix); pp_set_prefix (pp, prefix);
pp_translate_identifiers (pp) = true;
} }
/* Append a string delimited by START and END to the output area of /* Append a string delimited by START and END to the output area of
...@@ -855,8 +856,14 @@ pp_base_maybe_space (pretty_printer *pp) ...@@ -855,8 +856,14 @@ pp_base_maybe_space (pretty_printer *pp)
void void
pp_base_tree_identifier (pretty_printer *pp, tree id) pp_base_tree_identifier (pretty_printer *pp, tree id)
{ {
const char *text = identifier_to_locale (IDENTIFIER_POINTER (id)); if (pp_translate_identifiers (pp))
pp_append_text (pp, text, text + strlen (text)); {
const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
pp_append_text (pp, text, text + strlen (text));
}
else
pp_append_text (pp, IDENTIFIER_POINTER (id),
IDENTIFIER_POINTER (id) + IDENTIFIER_LENGTH (id));
} }
/* The string starting at P has LEN (at least 1) bytes left; if they /* The string starting at P has LEN (at least 1) bytes left; if they
......
...@@ -148,6 +148,10 @@ typedef bool (*printer_fn) (pretty_printer *, text_info *, const char *, ...@@ -148,6 +148,10 @@ typedef bool (*printer_fn) (pretty_printer *, text_info *, const char *,
/* The amount of whitespace to be emitted when starting a new line. */ /* The amount of whitespace to be emitted when starting a new line. */
#define pp_indentation(PP) pp_base (PP)->indent_skip #define pp_indentation(PP) pp_base (PP)->indent_skip
/* True if identifiers are translated to the locale character set on
output. */
#define pp_translate_identifiers(PP) pp_base (PP)->translate_identifiers
/* The data structure that contains the bare minimum required to do /* The data structure that contains the bare minimum required to do
proper pretty-printing. Clients may derived from this structure proper pretty-printing. Clients may derived from this structure
and add additional fields they need. */ and add additional fields they need. */
...@@ -187,6 +191,10 @@ struct pretty_print_info ...@@ -187,6 +191,10 @@ struct pretty_print_info
/* Nonzero means one should emit a newline before outputting anything. */ /* Nonzero means one should emit a newline before outputting anything. */
bool need_newline; bool need_newline;
/* Nonzero means identifiers are translated to the locale character
set on output. */
bool translate_identifiers;
}; };
#define pp_set_line_maximum_length(PP, L) \ #define pp_set_line_maximum_length(PP, L) \
...@@ -273,7 +281,9 @@ struct pretty_print_info ...@@ -273,7 +281,9 @@ struct pretty_print_info
pp_scalar (PP, HOST_WIDEST_INT_PRINT_DEC, (HOST_WIDEST_INT) I) pp_scalar (PP, HOST_WIDEST_INT_PRINT_DEC, (HOST_WIDEST_INT) I)
#define pp_pointer(PP, P) pp_scalar (PP, "%p", P) #define pp_pointer(PP, P) pp_scalar (PP, "%p", P)
#define pp_identifier(PP, ID) pp_string (PP, identifier_to_locale (ID)) #define pp_identifier(PP, ID) pp_string (PP, (pp_translate_identifiers (PP) \
? identifier_to_locale (ID) \
: (ID)))
#define pp_tree_identifier(PP, T) \ #define pp_tree_identifier(PP, T) \
pp_base_tree_identifier (pp_base (PP), T) pp_base_tree_identifier (pp_base (PP), T)
......
...@@ -2767,6 +2767,7 @@ maybe_init_pretty_print (FILE *file) ...@@ -2767,6 +2767,7 @@ maybe_init_pretty_print (FILE *file)
{ {
pp_construct (&buffer, /* prefix */NULL, /* line-width */0); pp_construct (&buffer, /* prefix */NULL, /* line-width */0);
pp_needs_newline (&buffer) = true; pp_needs_newline (&buffer) = true;
pp_translate_identifiers (&buffer) = false;
initialized = 1; initialized = 1;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment