Commit 0691175f by Gabriel Dos Reis Committed by Gabriel Dos Reis

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
parent 66dfe4c4
2013-08-25 Gabriel Dos Reis <gdr@integrable-solutions.net>
* 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 <gdr@integrable-solutions.net> 2013-08-24 Gabriel Dos Reis <gdr@integrable-solutions.net>
* c-pretty-print.h (c_pretty_printer::id_expression): Now a * c-pretty-print.h (c_pretty_printer::id_expression): Now a
......
...@@ -29,10 +29,6 @@ along with GCC; see the file COPYING3. If not see ...@@ -29,10 +29,6 @@ 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
...@@ -341,7 +337,7 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t) ...@@ -341,7 +337,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, M_("<type-error>")); pp->translate_string ("<type-error>");
break; break;
case IDENTIFIER_NODE: case IDENTIFIER_NODE:
...@@ -379,15 +375,15 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t) ...@@ -379,15 +375,15 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t)
switch (code) switch (code)
{ {
case INTEGER_TYPE: case INTEGER_TYPE:
pp_string (pp, (TYPE_UNSIGNED (t) pp->translate_string (TYPE_UNSIGNED (t)
? M_("<unnamed-unsigned:") ? "<unnamed-unsigned:"
: M_("<unnamed-signed:"))); : "<unnamed-signed:");
break; break;
case REAL_TYPE: case REAL_TYPE:
pp_string (pp, M_("<unnamed-float:")); pp->translate_string ("<unnamed-float:");
break; break;
case FIXED_POINT_TYPE: case FIXED_POINT_TYPE:
pp_string (pp, M_("<unnamed-fixed:")); pp->translate_string ("<unnamed-fixed:");
break; break;
default: default:
gcc_unreachable (); gcc_unreachable ();
...@@ -402,7 +398,7 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t) ...@@ -402,7 +398,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, M_("<typedef-error>")); pp->translate_string ("<typedef-error>");
break; break;
case UNION_TYPE: case UNION_TYPE:
...@@ -415,12 +411,12 @@ pp_c_type_specifier (c_pretty_printer *pp, tree t) ...@@ -415,12 +411,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, M_("<tag-error>")); pp->translate_string ("<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, M_("<anonymous>")); pp->translate_string ("<anonymous>");
break; break;
default: default:
...@@ -1187,6 +1183,15 @@ pp_c_ws_string (c_pretty_printer *pp, const char *str) ...@@ -1187,6 +1183,15 @@ pp_c_ws_string (c_pretty_printer *pp, const char *str)
pp->padding = pp_before; 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 /* Pretty-print an IDENTIFIER_NODE, which may contain UTF-8 sequences
that need converting to the locale encoding, preceded by whitespace that need converting to the locale encoding, preceded by whitespace
is necessary. */ is necessary. */
...@@ -1225,11 +1230,11 @@ pp_c_primary_expression (c_pretty_printer *pp, tree e) ...@@ -1225,11 +1230,11 @@ pp_c_primary_expression (c_pretty_printer *pp, tree e)
break; break;
case ERROR_MARK: case ERROR_MARK:
pp_c_ws_string (pp, M_("<erroneous-expression>")); pp->translate_string ("<erroneous-expression>");
break; break;
case RESULT_DECL: case RESULT_DECL:
pp_c_ws_string (pp, M_("<return-value>")); pp->translate_string ("<return-value>");
break; break;
case INTEGER_CST: case INTEGER_CST:
...@@ -2155,7 +2160,7 @@ pp_c_expression (c_pretty_printer *pp, tree e) ...@@ -2155,7 +2160,7 @@ pp_c_expression (c_pretty_printer *pp, tree e)
&& !DECL_ARTIFICIAL (SSA_NAME_VAR (e))) && !DECL_ARTIFICIAL (SSA_NAME_VAR (e)))
pp_c_expression (pp, SSA_NAME_VAR (e)); pp_c_expression (pp, SSA_NAME_VAR (e));
else else
pp_c_ws_string (pp, M_("<unknown>")); pp->translate_string ("<unknown>");
break; break;
case POSTINCREMENT_EXPR: case POSTINCREMENT_EXPR:
......
...@@ -51,6 +51,9 @@ struct c_pretty_printer : pretty_printer ...@@ -51,6 +51,9 @@ struct c_pretty_printer : pretty_printer
{ {
c_pretty_printer (); c_pretty_printer ();
// Format string, possibly translated.
void translate_string (const char *);
virtual void constant (tree); virtual void constant (tree);
virtual void id_expression (tree); virtual void id_expression (tree);
/* Points to the first element of an array of offset-list. /* Points to the first element of an array of offset-list.
......
2013-08-25 Gabriel Dos Reis <gdr@integrable-solutions.net>
* 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 <gdr@integrable-solutions.net> 2013-08-24 Gabriel Dos Reis <gdr@integrable-solutions.net>
* cxx-pretty-print.h (cxx_pretty_printer::id_expression): Declare. * cxx-pretty-print.h (cxx_pretty_printer::id_expression): Declare.
......
...@@ -27,10 +27,6 @@ along with GCC; see the file COPYING3. If not see ...@@ -27,10 +27,6 @@ along with GCC; see the file COPYING3. If not see
#include "cxx-pretty-print.h" #include "cxx-pretty-print.h"
#include "tree-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_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);
...@@ -149,7 +145,7 @@ pp_cxx_unqualified_id (cxx_pretty_printer *pp, tree t) ...@@ -149,7 +145,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, M_("<return-value>")); pp->translate_string ("<return-value>");
break; break;
case OVERLOAD: case OVERLOAD:
...@@ -168,7 +164,7 @@ pp_cxx_unqualified_id (cxx_pretty_printer *pp, tree t) ...@@ -168,7 +164,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, M_("<unnamed>")); pp->translate_string ("<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
...@@ -2154,7 +2150,7 @@ pp_cxx_canonical_template_parameter (cxx_pretty_printer *pp, tree parm) ...@@ -2154,7 +2150,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, M_("template-parameter-")); pp->translate_string ("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);
......
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