From: Gabriel Dos Reis Date: Sun, 25 Aug 2013 05:51:54 +0000 (+0000) Subject: c-pretty-print.h (c_pretty_printer::translate_string): Declare. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0691175fe28c07b0dd6f619bbb9a20a0e1f055b7;p=gcc.git c-pretty-print.h (c_pretty_printer::translate_string): Declare. c-family/ * c-pretty-print.h (c_pretty_printer::translate_string): Declare. * c-pretty-print.c (M_): Remove. (c_pretty_printer::translate_string): Define. (pp_c_type_specifier): Use it. (pp_c_primary_expression): Likewise. (pp_c_expression): Likewise. cp/ * cxx-pretty-print.c (M_): Remove. (pp_cxx_unqualified_id): Use translate_string instead of M_. (pp_cxx_canonical_template_parameter): Likewise. From-SVN: r201974 --- diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index c3d9ab7fcaf..cf2dc3f2139 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,12 @@ +2013-08-25 Gabriel Dos Reis + + * c-pretty-print.h (c_pretty_printer::translate_string): Declare. + * c-pretty-print.c (M_): Remove. + (c_pretty_printer::translate_string): Define. + (pp_c_type_specifier): Use it. + (pp_c_primary_expression): Likewise. + (pp_c_expression): Likewise. + 2013-08-24 Gabriel Dos Reis * c-pretty-print.h (c_pretty_printer::id_expression): Now a diff --git a/gcc/c-family/c-pretty-print.c b/gcc/c-family/c-pretty-print.c index a5dc62e07c1..ecc01734925 100644 --- a/gcc/c-family/c-pretty-print.c +++ b/gcc/c-family/c-pretty-print.c @@ -29,10 +29,6 @@ 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 @@ -341,7 +337,7 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t) switch (code) { case ERROR_MARK: - pp_c_ws_string (pp, M_("")); + pp->translate_string (""); break; case IDENTIFIER_NODE: @@ -379,15 +375,15 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t) switch (code) { case INTEGER_TYPE: - pp_string (pp, (TYPE_UNSIGNED (t) - ? M_("translate_string (TYPE_UNSIGNED (t) + ? "translate_string ("translate_string ("")); + pp->translate_string (""); break; case UNION_TYPE: @@ -415,12 +411,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, M_("")); + pp->translate_string (""); if (TYPE_NAME (t)) pp_id_expression (pp, TYPE_NAME (t)); else - pp_c_ws_string (pp, M_("")); + pp->translate_string (""); break; default: @@ -1187,6 +1183,15 @@ pp_c_ws_string (c_pretty_printer *pp, const char *str) pp->padding = pp_before; } +void +c_pretty_printer::translate_string (const char *gmsgid) +{ + if (pp_translate_identifiers (this)) + pp_c_ws_string (this, _(gmsgid)); + else + pp_c_ws_string (this, gmsgid); +} + /* Pretty-print an IDENTIFIER_NODE, which may contain UTF-8 sequences that need converting to the locale encoding, preceded by whitespace is necessary. */ @@ -1225,11 +1230,11 @@ pp_c_primary_expression (c_pretty_printer *pp, tree e) break; case ERROR_MARK: - pp_c_ws_string (pp, M_("")); + pp->translate_string (""); break; case RESULT_DECL: - pp_c_ws_string (pp, M_("")); + pp->translate_string (""); break; case INTEGER_CST: @@ -2155,7 +2160,7 @@ pp_c_expression (c_pretty_printer *pp, tree e) && !DECL_ARTIFICIAL (SSA_NAME_VAR (e))) pp_c_expression (pp, SSA_NAME_VAR (e)); else - pp_c_ws_string (pp, M_("")); + pp->translate_string (""); break; case POSTINCREMENT_EXPR: diff --git a/gcc/c-family/c-pretty-print.h b/gcc/c-family/c-pretty-print.h index 91e635f56ab..f347bc53dd7 100644 --- a/gcc/c-family/c-pretty-print.h +++ b/gcc/c-family/c-pretty-print.h @@ -51,6 +51,9 @@ struct c_pretty_printer : pretty_printer { c_pretty_printer (); + // Format string, possibly translated. + void translate_string (const char *); + virtual void constant (tree); virtual void id_expression (tree); /* Points to the first element of an array of offset-list. diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 830744826cf..d746f53f313 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2013-08-25 Gabriel Dos Reis + + * cxx-pretty-print.c (M_): Remove. + (pp_cxx_unqualified_id): Use translate_string instead of M_. + (pp_cxx_canonical_template_parameter): Likewise. + 2013-08-24 Gabriel Dos Reis * cxx-pretty-print.h (cxx_pretty_printer::id_expression): Declare. diff --git a/gcc/cp/cxx-pretty-print.c b/gcc/cp/cxx-pretty-print.c index dcebe0bbcc6..6e3b2ad1115 100644 --- a/gcc/cp/cxx-pretty-print.c +++ b/gcc/cp/cxx-pretty-print.c @@ -27,10 +27,6 @@ along with GCC; see the file COPYING3. If not see #include "cxx-pretty-print.h" #include "tree-pretty-print.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); @@ -149,7 +145,7 @@ pp_cxx_unqualified_id (cxx_pretty_printer *pp, tree t) switch (code) { case RESULT_DECL: - pp_cxx_ws_string (pp, M_("")); + pp->translate_string (""); break; case OVERLOAD: @@ -168,7 +164,7 @@ pp_cxx_unqualified_id (cxx_pretty_printer *pp, tree t) case IDENTIFIER_NODE: if (t == NULL) - pp_cxx_ws_string (pp, M_("")); + pp->translate_string (""); else if (IDENTIFIER_TYPENAME_P (t)) pp_cxx_conversion_function_id (pp, t); else @@ -2154,7 +2150,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, M_("template-parameter-")); + pp->translate_string ("template-parameter-"); pp_wide_integer (pp, TEMPLATE_PARM_LEVEL (parm)); pp_minus (pp); pp_wide_integer (pp, TEMPLATE_PARM_IDX (parm) + 1);