diff options
author | Joseph Myers <joseph@codesourcery.com> | 2009-05-10 11:28:34 +0100 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2009-05-10 11:28:34 +0100 |
commit | f41c4af3d6936f7153b65c23ba80c81f7f8c518e (patch) | |
tree | a02bdc44763aa1057cf075a959ca0e50e4188797 /gcc/cp | |
parent | 082b1749a179b056f33db0e6971ad1edeca17cdc (diff) | |
download | gcc-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/cp')
-rw-r--r-- | gcc/cp/ChangeLog | 36 | ||||
-rw-r--r-- | gcc/cp/call.c | 8 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 5 | ||||
-rw-r--r-- | gcc/cp/cxx-pretty-print.c | 10 | ||||
-rw-r--r-- | gcc/cp/decl.c | 8 | ||||
-rw-r--r-- | gcc/cp/error.c | 100 | ||||
-rw-r--r-- | gcc/cp/parser.c | 4 | ||||
-rw-r--r-- | gcc/cp/tree.c | 24 |
8 files changed, 139 insertions, 56 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index cc7b5f7..8117f22 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,39 @@ +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> PR c/36892 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index ba8dac1..ee13ba2 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -5731,7 +5731,7 @@ name_as_c_string (tree name, tree type, bool *free_p) if (IDENTIFIER_CTOR_OR_DTOR_P (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 '~'. */ if (name == complete_dtor_identifier || name == base_dtor_identifier @@ -5745,14 +5745,14 @@ name_as_c_string (tree name, tree type, bool *free_p) else if (IDENTIFIER_TYPENAME_P (name)) { pretty_name = concat ("operator ", - type_as_string (TREE_TYPE (name), - TFF_PLAIN_IDENTIFIER), + type_as_string_translate (TREE_TYPE (name), + TFF_PLAIN_IDENTIFIER), NULL); /* Remember that we need to free the memory allocated. */ *free_p = true; } else - pretty_name = CONST_CAST (char *, IDENTIFIER_POINTER (name)); + pretty_name = CONST_CAST (char *, identifier_to_locale (IDENTIFIER_POINTER (name))); return pretty_name; } diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index ae93e66..0ea2d86 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4422,9 +4422,11 @@ extern int parm_index (tree); /* in error.c */ extern void init_error (void); 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_translate (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 *class_key_or_enum_as_string (tree); extern void print_instantiation_context (void); @@ -4839,6 +4841,7 @@ extern tree get_first_fn (tree); extern tree ovl_cons (tree, tree); extern tree build_overload (tree, tree); 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 bind_template_template_parm (tree, tree); extern tree array_type_nelts_total (tree); diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c index 2edffd3..b8732896 100644 --- a/gcc/cp/cxx-pretty-print.c +++ b/gcc/cp/cxx-pretty-print.c @@ -29,6 +29,10 @@ along with GCC; see the file COPYING3. If not see #include "cp-tree.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_nested_name_specifier (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) switch (code) { case RESULT_DECL: - pp_cxx_ws_string (pp, _("<return-value>")); + pp_cxx_ws_string (pp, M_("<return-value>")); break; case OVERLOAD: @@ -166,7 +170,7 @@ pp_cxx_unqualified_id (cxx_pretty_printer *pp, tree t) case IDENTIFIER_NODE: if (t == NULL) - pp_cxx_ws_string (pp, _("<unnamed>")); + pp_cxx_ws_string (pp, M_("<unnamed>")); else if (IDENTIFIER_TYPENAME_P (t)) pp_cxx_conversion_function_id (pp, t); else @@ -2048,7 +2052,7 @@ pp_cxx_canonical_template_parameter (cxx_pretty_printer *pp, tree parm) parm = TEMPLATE_TYPE_PARM_INDEX (parm); 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_minus (pp); pp_wide_integer (pp, TEMPLATE_PARM_IDX (parm) + 1); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index fb91647..fd944f7 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7701,7 +7701,7 @@ grokdeclarator (const cp_declarator *declarator, type = TREE_OPERAND (decl, 0); if (TYPE_P (type)) type = constructor_name (type); - name = IDENTIFIER_POINTER (type); + name = identifier_to_locale (IDENTIFIER_POINTER (type)); dname = decl; } break; @@ -7727,10 +7727,10 @@ grokdeclarator (const cp_declarator *declarator, { error ("declarator-id missing; using reserved word %qD", dname); - name = IDENTIFIER_POINTER (dname); + name = identifier_to_locale (IDENTIFIER_POINTER (dname)); } else if (!IDENTIFIER_TYPENAME_P (dname)) - name = IDENTIFIER_POINTER (dname); + name = identifier_to_locale (IDENTIFIER_POINTER (dname)); else { gcc_assert (flags == NO_SPECIAL); @@ -7738,7 +7738,7 @@ grokdeclarator (const cp_declarator *declarator, ctor_return_type = TREE_TYPE (dname); sfk = sfk_conversion; if (is_typename_at_global_scope (dname)) - name = IDENTIFIER_POINTER (dname); + name = identifier_to_locale (IDENTIFIER_POINTER (dname)); else name = "<invalid operator>"; } diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 13b32ad..3c7a8d5 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -41,6 +41,10 @@ along with GCC; see the file COPYING3. If not see static cxx_pretty_printer scratch_pretty_printer; #define cxx_pp (&scratch_pretty_printer) +/* Translate if being used for diagnostics, but not for dump files or + __PRETTY_FUNCTION. */ +#define M_(msgid) (pp_translate_identifiers (cxx_pp) ? _(msgid) : (msgid)) + # define NEXT_CODE(T) (TREE_CODE (TREE_TYPE (T))) static const char *args_to_string (tree, int); @@ -298,7 +302,7 @@ dump_template_bindings (tree parms, tree args, VEC(tree,gc)* typenames) if (arg) dump_template_argument (arg, TFF_PLAIN_IDENTIFIER); else - pp_string (cxx_pp, _("<missing>")); + pp_string (cxx_pp, M_("<missing>")); ++arg_idx; need_comma = 1; @@ -339,9 +343,9 @@ dump_type (tree t, int flags) { case UNKNOWN_TYPE: if (t == init_list_type_node) - pp_string (cxx_pp, _("<brace-enclosed initializer list>")); + pp_string (cxx_pp, M_("<brace-enclosed initializer list>")); else - pp_string (cxx_pp, _("<unresolved overloaded function type>")); + pp_string (cxx_pp, M_("<unresolved overloaded function type>")); break; case TREE_LIST: @@ -481,7 +485,7 @@ dump_type (tree t, int flags) /* Fall through to error. */ case ERROR_MARK: - pp_string (cxx_pp, _("<type error>")); + pp_string (cxx_pp, M_("<type error>")); break; } } @@ -578,9 +582,9 @@ dump_aggr_type (tree t, int flags) if (name == 0 || ANON_AGGRNAME_P (name)) { if (flags & TFF_CLASS_KEY_OR_ENUM) - pp_string (cxx_pp, _("<anonymous>")); + pp_string (cxx_pp, M_("<anonymous>")); else - pp_printf (pp_base (cxx_pp), _("<anonymous %s>"), variety); + pp_printf (pp_base (cxx_pp), M_("<anonymous %s>"), variety); } else pp_cxx_tree_identifier (cxx_pp, name); @@ -702,7 +706,7 @@ dump_type_prefix (tree t, int flags) pp_unsupported_tree (cxx_pp, t); /* fall through. */ case ERROR_MARK: - pp_string (cxx_pp, _("<typeprefixerror>")); + pp_string (cxx_pp, M_("<typeprefixerror>")); break; } } @@ -812,9 +816,9 @@ dump_global_iord (tree t) const char *p = NULL; if (DECL_GLOBAL_CTOR_P (t)) - p = _("(static initializers for %s)"); + p = M_("(static initializers for %s)"); else if (DECL_GLOBAL_DTOR_P (t)) - p = _("(static destructors for %s)"); + p = M_("(static destructors for %s)"); else gcc_unreachable (); @@ -841,7 +845,7 @@ dump_simple_decl (tree t, tree type, int flags) if (DECL_NAME (t)) dump_decl (DECL_NAME (t), flags); else - pp_string (cxx_pp, _("<anonymous>")); + pp_string (cxx_pp, M_("<anonymous>")); if (flags & TFF_DECL_SPECIFIERS) dump_type_suffix (type, flags); } @@ -884,7 +888,7 @@ dump_decl (tree t, int flags) case VAR_DECL: if (DECL_NAME (t) && VTABLE_NAME_P (DECL_NAME (t))) { - pp_string (cxx_pp, _("vtable for ")); + pp_string (cxx_pp, M_("vtable for ")); gcc_assert (TYPE_P (DECL_CONTEXT (t))); dump_type (DECL_CONTEXT (t), flags); break; @@ -896,7 +900,7 @@ dump_decl (tree t, int flags) break; case RESULT_DECL: - pp_string (cxx_pp, _("<return value> ")); + pp_string (cxx_pp, M_("<return value> ")); dump_simple_decl (t, TREE_TYPE (t), flags); break; @@ -909,7 +913,7 @@ dump_decl (tree t, int flags) dump_scope (CP_DECL_CONTEXT (t), flags); flags &= ~TFF_UNQUALIFIED_NAME; if (DECL_NAME (t) == NULL_TREE) - pp_string (cxx_pp, _("<unnamed>")); + pp_string (cxx_pp, M_("<unnamed>")); else pp_cxx_tree_identifier (cxx_pp, DECL_NAME (t)); } @@ -983,7 +987,7 @@ dump_decl (tree t, int flags) case FUNCTION_DECL: if (! DECL_LANG_SPECIFIC (t)) - pp_string (cxx_pp, _("<built-in>")); + pp_string (cxx_pp, M_("<built-in>")); else if (DECL_GLOBAL_CTOR_P (t) || DECL_GLOBAL_DTOR_P (t)) dump_global_iord (t); else @@ -1022,7 +1026,7 @@ dump_decl (tree t, int flags) else if (DECL_INITIAL (t)) dump_expr (DECL_INITIAL (t), flags | TFF_EXPR_IN_PARENS); else - pp_string (cxx_pp, _("<enumerator>")); + pp_string (cxx_pp, M_("<enumerator>")); break; case USING_DECL: @@ -1062,7 +1066,7 @@ dump_decl (tree t, int flags) /* Fall through to error. */ case ERROR_MARK: - pp_string (cxx_pp, _("<declaration error>")); + pp_string (cxx_pp, M_("<declaration error>")); break; } } @@ -1292,7 +1296,7 @@ dump_function_decl (tree t, int flags) { pp_cxx_whitespace (cxx_pp); pp_cxx_left_bracket (cxx_pp); - pp_cxx_ws_string (cxx_pp, _("with")); + pp_cxx_ws_string (cxx_pp, M_("with")); pp_cxx_whitespace (cxx_pp); dump_template_bindings (template_parms, template_args, typenames); pp_cxx_right_bracket (cxx_pp); @@ -1457,7 +1461,7 @@ dump_template_parms (tree info, int primary, int flags) pp_separate_with_comma (cxx_pp); if (!arg) - pp_string (cxx_pp, _("<template parameter error>")); + pp_string (cxx_pp, M_("<template parameter error>")); else dump_template_argument (arg, flags); } @@ -1477,7 +1481,7 @@ dump_template_parms (tree info, int primary, int flags) if (TREE_VEC_ELT (parms, ix) == error_mark_node) { - pp_string (cxx_pp, _("<template parameter error>")); + pp_string (cxx_pp, M_("<template parameter error>")); continue; } @@ -1603,7 +1607,7 @@ dump_expr (tree t, int flags) if (STATEMENT_CLASS_P (t)) { - pp_cxx_ws_string (cxx_pp, _("<statement>")); + pp_cxx_ws_string (cxx_pp, M_("<statement>")); return; } @@ -1632,7 +1636,7 @@ dump_expr (tree t, int flags) case THROW_EXPR: /* While waiting for caret diagnostics, avoid printing __cxa_allocate_exception, __cxa_throw, and the like. */ - pp_cxx_ws_string (cxx_pp, _("<throw-expression>")); + pp_cxx_ws_string (cxx_pp, M_("<throw-expression>")); break; case PTRMEM_CST: @@ -2078,7 +2082,7 @@ dump_expr (tree t, int flags) break; case DEFAULT_ARG: - pp_string (cxx_pp, _("<unparsed>")); + pp_string (cxx_pp, M_("<unparsed>")); break; case TRY_CATCH_EXPR: @@ -2224,7 +2228,7 @@ dump_expr (tree t, int flags) pp_unsupported_tree (cxx_pp, t); /* fall through to ERROR_MARK... */ case ERROR_MARK: - pp_string (cxx_pp, _("<expression error>")); + pp_string (cxx_pp, M_("<expression error>")); break; } } @@ -2238,7 +2242,7 @@ dump_binary_op (const char *opstring, tree t, int flags) if (opstring) pp_cxx_ws_string (cxx_pp, opstring); else - pp_string (cxx_pp, _("<unknown operator>")); + pp_string (cxx_pp, M_("<unknown operator>")); pp_cxx_whitespace (cxx_pp); dump_expr (TREE_OPERAND (t, 1), flags | TFF_EXPR_IN_PARENS); pp_cxx_right_paren (cxx_pp); @@ -2273,6 +2277,15 @@ const char * type_as_string (tree typ, int flags) { reinit_cxx_pp (); + pp_translate_identifiers (cxx_pp) = false; + dump_type (typ, flags); + return pp_formatted_text (cxx_pp); +} + +const char * +type_as_string_translate (tree typ, int flags) +{ + reinit_cxx_pp (); dump_type (typ, flags); return pp_formatted_text (cxx_pp); } @@ -2281,6 +2294,7 @@ const char * expr_as_string (tree decl, int flags) { reinit_cxx_pp (); + pp_translate_identifiers (cxx_pp) = false; dump_expr (decl, flags); return pp_formatted_text (cxx_pp); } @@ -2289,6 +2303,15 @@ const char * decl_as_string (tree decl, int flags) { reinit_cxx_pp (); + pp_translate_identifiers (cxx_pp) = false; + dump_decl (decl, flags); + return pp_formatted_text (cxx_pp); +} + +const char * +decl_as_string_translate (tree decl, int flags) +{ + reinit_cxx_pp (); dump_decl (decl, flags); return pp_formatted_text (cxx_pp); } @@ -2296,12 +2319,15 @@ decl_as_string (tree decl, int flags) /* Generate the three forms of printable names for cxx_printable_name. */ const char * -lang_decl_name (tree decl, int v) +lang_decl_name (tree decl, int v, bool translate) { if (v >= 2) - return decl_as_string (decl, TFF_DECL_SPECIFIERS); + return (translate + ? decl_as_string_translate (decl, TFF_DECL_SPECIFIERS) + : decl_as_string (decl, TFF_DECL_SPECIFIERS)); reinit_cxx_pp (); + pp_translate_identifiers (cxx_pp) = translate; if (v == 1 && DECL_CLASS_SCOPE_P (decl)) { dump_type (CP_DECL_CONTEXT (decl), TFF_PLAIN_IDENTIFIER); @@ -2420,7 +2446,7 @@ static const char * op_to_string (enum tree_code p) { tree id = operator_name_info[(int) p].identifier; - return id ? IDENTIFIER_POINTER (id) : _("<unknown>"); + return id ? IDENTIFIER_POINTER (id) : M_("<unknown>"); } static const char * @@ -2440,7 +2466,7 @@ static const char * assop_to_string (enum tree_code p) { tree id = assignment_operator_name_info[(int) p].identifier; - return id ? IDENTIFIER_POINTER (id) : _("{unknown}"); + return id ? IDENTIFIER_POINTER (id) : M_("{unknown}"); } static const char * @@ -2454,7 +2480,7 @@ args_to_string (tree p, int verbose) return ""; if (TYPE_P (TREE_VALUE (p))) - return type_as_string (p, flags); + return type_as_string_translate (p, flags); reinit_cxx_pp (); for (; p; p = TREE_CHAIN (p)) @@ -2541,7 +2567,7 @@ cp_print_error_function (diagnostic_context *context, fndecl = current_function_decl; pp_printf (context->printer, function_category (fndecl), - cxx_printable_name (fndecl, 2)); + cxx_printable_name_translate (fndecl, 2)); while (abstract_origin) { @@ -2592,18 +2618,18 @@ cp_print_error_function (diagnostic_context *context, if (flag_show_column && s.column != 0) pp_printf (context->printer, _(" inlined from %qs at %s:%d:%d"), - cxx_printable_name (fndecl, 2), + cxx_printable_name_translate (fndecl, 2), s.file, s.line, s.column); else pp_printf (context->printer, _(" inlined from %qs at %s:%d"), - cxx_printable_name (fndecl, 2), + cxx_printable_name_translate (fndecl, 2), s.file, s.line); } else pp_printf (context->printer, _(" inlined from %qs"), - cxx_printable_name (fndecl, 2)); + cxx_printable_name_translate (fndecl, 2)); } } pp_base_character (context->printer, ':'); @@ -2662,8 +2688,8 @@ print_instantiation_full_context (diagnostic_context *context) pp_verbatim (context->printer, _("%s: In instantiation of %qs:\n"), LOCATION_FILE (location), - decl_as_string (p->decl, - TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE)); + decl_as_string_translate (p->decl, + TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE)); location = p->locus; p = p->next; @@ -2686,8 +2712,8 @@ print_instantiation_partial_context (diagnostic_context *context, break; pp_verbatim (context->printer, _("%s:%d: instantiated from %qs\n"), xloc.file, xloc.line, - decl_as_string (t->decl, - TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE)); + decl_as_string_translate (t->decl, + TFF_DECL_SPECIFIERS | TFF_RETURN_TYPE)); loc = t->locus; } pp_verbatim (context->printer, _("%s:%d: instantiated from here"), diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index c691ef2..1fc9469 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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 an identifier). */ warning (OPT_Wc__0x_compat, - "identifier %<%s%> will become a keyword in C++0x", - IDENTIFIER_POINTER (token->u.value)); + "identifier %qE will become a keyword in C++0x", + token->u.value); /* Clear out the C_RID_CODE so we don't warn about this particular identifier-turned-keyword again. */ diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index c95c11c..9cc767d 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1238,11 +1238,12 @@ build_overload (tree decl, tree chain) #define PRINT_RING_SIZE 4 -const char * -cxx_printable_name (tree decl, int v) +static const char * +cxx_printable_name_internal (tree decl, int v, bool translate) { static unsigned int uid_ring[PRINT_RING_SIZE]; static char *print_ring[PRINT_RING_SIZE]; + static bool trans_ring[PRINT_RING_SIZE]; static int ring_counter; int i; @@ -1250,11 +1251,11 @@ cxx_printable_name (tree decl, int v) if (v < 2 || TREE_CODE (decl) != FUNCTION_DECL || 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. */ 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. */ return print_ring[i]; @@ -1273,10 +1274,23 @@ cxx_printable_name (tree decl, int v) if (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); + trans_ring[ring_counter] = translate; 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 listed in RAISES. */ |