* pretty-print.h (struct pretty_print_info): Add
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 10 May 2009 10:28:34 +0000 (10:28 +0000)
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 10 May 2009 10:28:34 +0000 (10:28 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@147333 138bc75d-0d04-0410-961f-82ee72b054a4

15 files changed:
gcc/ChangeLog
gcc/c-pretty-print.c
gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/cp-tree.h
gcc/cp/cxx-pretty-print.c
gcc/cp/decl.c
gcc/cp/error.c
gcc/cp/parser.c
gcc/cp/tree.c
gcc/objc/ChangeLog
gcc/objc/objc-act.c
gcc/pretty-print.c
gcc/pretty-print.h
gcc/tree-pretty-print.c

index 0752599..c2e3f12 100644 (file)
@@ -1,3 +1,19 @@
+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>
 
        PR tree-optimization/40081
index efd15ac..f9694bf 100644 (file)
@@ -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:
index cc7b5f7..8117f22 100644 (file)
@@ -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
index ba8dac1..ee13ba2 100644 (file)
@@ -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;
 }
index ae93e66..0ea2d86 100644 (file)
@@ -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);
index 2edffd3..b873289 100644 (file)
@@ -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);
index fb91647..fd944f7 100644 (file)
@@ -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>";
                  }
index 13b32ad..3c7a8d5 100644 (file)
@@ -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"),
index c691ef2..1fc9469 100644 (file)
@@ -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.  */
index c95c11c..9cc767d 100644 (file)
@@ -1238,11 +1238,12 @@ build_overload (tree decl, tree chain)
 \f
 #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);
+}
 \f
 /* Build the FUNCTION_TYPE or METHOD_TYPE which may throw exceptions
    listed in RAISES.  */
index 5f5a478..58f60d2 100644 (file)
@@ -1,3 +1,25 @@
+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>
 
        * objc-act.c (objc_gimplify_expr): Add casts to enum type.
index 741e344..02bff7d 100644 (file)
@@ -69,6 +69,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "debug.h"
 #include "target.h"
 #include "diagnostic.h"
+#include "intl.h"
 #include "cgraph.h"
 #include "tree-iterator.h"
 #include "libfuncs.h"
@@ -980,17 +981,17 @@ objc_lookup_protocol (tree proto, tree cls, tree typ, bool warn)
 
   if (warn)
     {
-      strcpy (errbuf, class_type ? "class \'" : "type \'");
+      *errbuf = 0;
       gen_type_name_0 (class_type ? typ : TYPE_POINTER_TO (typ));
-      strcat (errbuf, "\' does not ");
       /* NB: Types 'id' and 'Class' cannot reasonably be described as
         "implementing" a given protocol, since they do not have an
         implementation.  */
-      strcat (errbuf, class_type ? "implement" : "conform to");
-      strcat (errbuf, " the \'");
-      strcat (errbuf, IDENTIFIER_POINTER (PROTOCOL_NAME (proto)));
-      strcat (errbuf, "\' protocol");
-      warning (0, errbuf);
+      if (class_type)
+       warning (0, "class %qs does not implement the %qE protocol",
+                identifier_to_locale (errbuf), PROTOCOL_NAME (proto));
+      else
+       warning (0, "type %qs does not conform to the %qE protocol",
+                identifier_to_locale (errbuf), PROTOCOL_NAME (proto));
     }
 
   return false;
@@ -1338,8 +1339,8 @@ objc_check_decl (tree decl)
   if (TREE_CODE (type) != RECORD_TYPE)
     return;
   if (OBJC_TYPE_NAME (type) && (type = objc_is_class_name (OBJC_TYPE_NAME (type))))
-    error ("statically allocated instance of Objective-C class %qs",
-          IDENTIFIER_POINTER (type));
+    error ("statically allocated instance of Objective-C class %qE",
+          type);
 }
 
 /* Construct a PROTOCOLS-qualified variant of INTERFACE, where INTERFACE may
@@ -1415,8 +1416,8 @@ check_protocol_recursively (tree proto, tree list)
        pp = lookup_protocol (pp);
 
       if (pp == proto)
-       fatal_error ("protocol %qs has circular dependency",
-                    IDENTIFIER_POINTER (PROTOCOL_NAME (pp)));
+       fatal_error ("protocol %qE has circular dependency",
+                    PROTOCOL_NAME (pp));
       if (pp)
        check_protocol_recursively (proto, PROTOCOL_LIST (pp));
     }
@@ -1440,8 +1441,8 @@ lookup_and_install_protocols (tree protocols)
        return_value = chainon (return_value,
                                build_tree_list (NULL_TREE, p));
       else if (ident != error_mark_node)
-       error ("cannot find protocol declaration for %qs",
-              IDENTIFIER_POINTER (ident));
+       error ("cannot find protocol declaration for %qE",
+              ident);
     }
 
   return return_value;
@@ -1904,17 +1905,17 @@ objc_build_string_object (tree string)
       if (!constant_string_class
          || !(constant_string_type
               = CLASS_STATIC_TEMPLATE (constant_string_class)))
-       error ("cannot find interface declaration for %qs",
-              IDENTIFIER_POINTER (constant_string_id));
+       error ("cannot find interface declaration for %qE",
+              constant_string_id);
       /* The NSConstantString/NXConstantString ivar layout is now known.  */
       else if (!check_string_class_template ())
-       error ("interface %qs does not have valid constant string layout",
-              IDENTIFIER_POINTER (constant_string_id));
+       error ("interface %qE does not have valid constant string layout",
+              constant_string_id);
       /* For the NeXT runtime, we can generate a literal reference
         to the string class, don't need to run a constructor.  */
       else if (flag_next_runtime && !setup_string_decl ())
-       error ("cannot find reference tag for class %qs",
-              IDENTIFIER_POINTER (constant_string_id));
+       error ("cannot find reference tag for class %qE",
+              constant_string_id);
       else
        {
          string_layout_checked = 1;  /* Success!  */
@@ -2753,8 +2754,8 @@ objc_get_class_reference (tree ident)
 
   if (local_scope || !(ident = objc_is_class_name (ident)))
     {
-      error ("%qs is not an Objective-C class name or alias",
-            IDENTIFIER_POINTER (orig_ident));
+      error ("%qE is not an Objective-C class name or alias",
+            orig_ident);
       return error_mark_node;
     }
 
@@ -2886,9 +2887,9 @@ objc_declare_alias (tree alias_ident, tree class_ident)
 #endif /* OBJCPLUS */
 
   if (!(underlying_class = objc_is_class_name (class_ident)))
-    warning (0, "cannot find class %qs", IDENTIFIER_POINTER (class_ident));
+    warning (0, "cannot find class %qE", class_ident);
   else if (objc_is_class_name (alias_ident))
-    warning (0, "class %qs already exists", IDENTIFIER_POINTER (alias_ident));
+    warning (0, "class %qE already exists", alias_ident);
   else
     {
       /* Implement @compatibility_alias as a typedef.  */
@@ -2932,8 +2933,8 @@ objc_declare_class (tree ident_list)
              if (!TYPE_HAS_OBJC_INFO (type)
                  || !TYPE_OBJC_INTERFACE (type))
                {
-                 error ("%qs redeclared as different kind of symbol",
-                        IDENTIFIER_POINTER (ident));
+                 error ("%qE redeclared as different kind of symbol",
+                        ident);
                  error ("previous declaration of %q+D",
                         record);
                }
@@ -3354,8 +3355,8 @@ objc_get_class_ivars (tree class_name)
   if (interface)
     return get_class_ivars (interface, true);
 
-  error ("cannot find interface declaration for %qs",
-        IDENTIFIER_POINTER (class_name));
+  error ("cannot find interface declaration for %qE",
+        class_name);
 
   return error_mark_node;
 }
@@ -4970,7 +4971,7 @@ static void
 error_with_ivar (const char *message, tree decl)
 {
   error ("%J%s %qs", decl,
-         message, gen_declaration (decl));
+         message, identifier_to_locale (gen_declaration (decl)));
 
 }
 
@@ -6103,23 +6104,23 @@ check_duplicates (hash hsh, int methods, int is_class)
            {
              bool type = TREE_CODE (meth) == INSTANCE_METHOD_DECL;
 
-             warning (0, "multiple methods named %<%c%s%> found",
+             warning (0, "multiple methods named %<%c%E%> found",
                       (is_class ? '+' : '-'),
-                      IDENTIFIER_POINTER (METHOD_SEL_NAME (meth)));
+                      METHOD_SEL_NAME (meth));
              inform (0, "%Jusing %<%c%s%>", meth,
                      (type ? '-' : '+'),
-                     gen_method_decl (meth));
+                     identifier_to_locale (gen_method_decl (meth)));
            }
          else
            {
              bool type = TREE_CODE (meth) == INSTANCE_METHOD_DECL;
 
-             warning (0, "multiple selectors named %<%c%s%> found",
+             warning (0, "multiple selectors named %<%c%E%> found",
                       (is_class ? '+' : '-'),
-                      IDENTIFIER_POINTER (METHOD_SEL_NAME (meth)));
+                      METHOD_SEL_NAME (meth));
              inform (0, "%Jfound %<%c%s%>", meth,
                      (type ? '-' : '+'),
-                     gen_method_decl (meth));
+                     identifier_to_locale (gen_method_decl (meth)));
            }
 
          for (loop = hsh->list; loop; loop = loop->next)
@@ -6128,7 +6129,7 @@ check_duplicates (hash hsh, int methods, int is_class)
 
              inform (0, "%Jalso found %<%c%s%>", loop->value, 
                      (type ? '-' : '+'),
-                     gen_method_decl (loop->value));
+                     identifier_to_locale (gen_method_decl (loop->value)));
            }
         }
     }
@@ -6340,8 +6341,8 @@ objc_finish_message_expr (tree receiver, tree sel_name, tree method_params)
        {
          if (!CLASS_SUPER_NAME (implementation_template))
            {
-             error ("no super class declared in @interface for %qs",
-                    IDENTIFIER_POINTER (CLASS_NAME (implementation_template)));
+             error ("no super class declared in @interface for %qE",
+                    CLASS_NAME (implementation_template));
              return error_mark_node;
            }
          rtype = lookup_interface (CLASS_SUPER_NAME (implementation_template));
@@ -6378,9 +6379,8 @@ objc_finish_message_expr (tree receiver, tree sel_name, tree method_params)
                = lookup_method_in_protocol_list (rprotos, sel_name, 0);
 
              if (method_prototype)
-               warning (0, "found %<-%s%> instead of %<+%s%> in protocol(s)",
-                        IDENTIFIER_POINTER (sel_name),
-                        IDENTIFIER_POINTER (sel_name));
+               warning (0, "found %<-%E%> instead of %<+%E%> in protocol(s)",
+                        sel_name, sel_name);
            }
        }
     }
@@ -6438,7 +6438,7 @@ objc_finish_message_expr (tree receiver, tree sel_name, tree method_params)
       else
        {
          warning (0, "invalid receiver type %qs",
-                  gen_type_name (orig_rtype));
+                  identifier_to_locale (gen_type_name (orig_rtype)));
          /* After issuing the "invalid receiver" warning, perform method
             lookup as if we were messaging 'id'.  */
          rtype = rprotos = NULL_TREE;
@@ -6452,9 +6452,9 @@ objc_finish_message_expr (tree receiver, tree sel_name, tree method_params)
   if (!method_prototype)
     {
       if (rprotos)
-       warning (0, "%<%c%s%> not found in protocol(s)",
+       warning (0, "%<%c%E%> not found in protocol(s)",
                 (class_tree ? '+' : '-'),
-                IDENTIFIER_POINTER (sel_name));
+                sel_name);
 
       if (!rtype)
        method_prototype
@@ -6466,17 +6466,17 @@ objc_finish_message_expr (tree receiver, tree sel_name, tree method_params)
       static bool warn_missing_methods = false;
 
       if (rtype)
-       warning (0, "%qs may not respond to %<%c%s%>",
-                IDENTIFIER_POINTER (OBJC_TYPE_NAME (rtype)),
+       warning (0, "%qE may not respond to %<%c%E%>",
+                OBJC_TYPE_NAME (rtype),
                 (class_tree ? '+' : '-'),
-                IDENTIFIER_POINTER (sel_name));
+                sel_name);
       /* If we are messaging an 'id' or 'Class' object and made it here,
         then we have failed to find _any_ instance or class method,
         respectively.  */
       else
-       warning (0, "no %<%c%s%> method found",
+       warning (0, "no %<%c%E%> method found",
                 (class_tree ? '+' : '-'),
-                IDENTIFIER_POINTER (sel_name));
+                sel_name);
 
       if (!warn_missing_methods)
        {
@@ -6616,8 +6616,8 @@ objc_build_protocol_expr (tree protoname)
 
   if (!p)
     {
-      error ("cannot find protocol declaration for %qs",
-            IDENTIFIER_POINTER (protoname));
+      error ("cannot find protocol declaration for %qE",
+            protoname);
       return error_mark_node;
     }
 
@@ -6716,7 +6716,7 @@ objc_build_selector_expr (tree selnamelist)
       /* If still not found, print out a warning.  */
       if (!hsh)
        {
-         warning (0, "undeclared selector %qs", IDENTIFIER_POINTER (selname));
+         warning (0, "undeclared selector %qE", selname);
        }
     }
 
@@ -6758,8 +6758,8 @@ build_ivar_reference (tree id)
         to an instance variable.  It's better to catch the cases
         where this is done unknowingly than to support the above
         paradigm.  */
-      warning (0, "instance variable %qs accessed in class method",
-              IDENTIFIER_POINTER (id));
+      warning (0, "instance variable %qE accessed in class method",
+              id);
       self_decl = convert (objc_instance_type, self_decl); /* cast */
     }
 
@@ -6992,9 +6992,9 @@ objc_add_method (tree klass, tree method, int is_class)
       if ((TREE_CODE (klass) == CLASS_INTERFACE_TYPE
           || TREE_CODE (klass) == CATEGORY_INTERFACE_TYPE)
          && !comp_proto_with_proto (method, mth, 1))
-       error ("duplicate declaration of method %<%c%s%>",
+       error ("duplicate declaration of method %<%c%E%>",
                is_class ? '+' : '-',
-               IDENTIFIER_POINTER (METHOD_SEL_NAME (mth)));
+               METHOD_SEL_NAME (mth));
     }
 
   if (is_class)
@@ -7053,9 +7053,9 @@ add_category (tree klass, tree category)
 
   if (cat)
     {
-      warning (0, "duplicate interface declaration for category %<%s(%s)%>",
-              IDENTIFIER_POINTER (CLASS_NAME (klass)),
-              IDENTIFIER_POINTER (CLASS_SUPER_NAME (category)));
+      warning (0, "duplicate interface declaration for category %<%E(%E)%>",
+              CLASS_NAME (klass),
+              CLASS_SUPER_NAME (category));
     }
   else
     {
@@ -7074,8 +7074,8 @@ add_instance_variable (tree klass, int visibility, tree field_decl)
 {
   tree field_type = TREE_TYPE (field_decl);
   const char *ivar_name = DECL_NAME (field_decl)
-                         ? IDENTIFIER_POINTER (DECL_NAME (field_decl))
-                         : "<unnamed>";
+                         ? identifier_to_locale (IDENTIFIER_POINTER (DECL_NAME (field_decl)))
+                         : _("<unnamed>");
 
 #ifdef OBJCPLUS
   if (TREE_CODE (field_type) == REFERENCE_TYPE)
@@ -7106,7 +7106,7 @@ add_instance_variable (tree klass, int visibility, tree field_decl)
          || TYPE_HAS_NONTRIVIAL_DESTRUCTOR (field_type)
          || TYPE_POLYMORPHIC_P (field_type)))
     {
-      const char *type_name = IDENTIFIER_POINTER (OBJC_TYPE_NAME (field_type));
+      tree type_name = OBJC_TYPE_NAME (field_type);
 
       if (flag_objc_call_cxx_cdtors)
         {
@@ -7116,13 +7116,13 @@ add_instance_variable (tree klass, int visibility, tree field_decl)
          if (TYPE_NEEDS_CONSTRUCTING (field_type)
              && !TYPE_HAS_DEFAULT_CONSTRUCTOR (field_type))
            {
-             warning (0, "type %qs has no default constructor to call",
+             warning (0, "type %qE has no default constructor to call",
                       type_name);
 
              /* If we cannot call a constructor, we should also avoid
                 calling the destructor, for symmetry.  */
              if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (field_type))
-               warning (0, "destructor for %qs shall not be run either",
+               warning (0, "destructor for %qE shall not be run either",
                         type_name);
            }
         }
@@ -7134,8 +7134,8 @@ add_instance_variable (tree klass, int visibility, tree field_decl)
            {
              /* Vtable pointers are Real Bad(tm), since Obj-C cannot
                 initialize them.  */
-             error ("type %qs has virtual member functions", type_name);
-             error ("illegal aggregate type %qs specified "
+             error ("type %qE has virtual member functions", type_name);
+             error ("illegal aggregate type %qE specified "
                     "for instance variable %qs",
                     type_name, ivar_name);
              /* Return class as is without adding this ivar.  */
@@ -7145,9 +7145,9 @@ add_instance_variable (tree klass, int visibility, tree field_decl)
          /* User-defined constructors and destructors are not known to Obj-C
             and hence will not be called.  This may or may not be a problem. */
          if (TYPE_NEEDS_CONSTRUCTING (field_type))
-           warning (0, "type %qs has a user-defined constructor", type_name);
+           warning (0, "type %qE has a user-defined constructor", type_name);
          if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (field_type))
-           warning (0, "type %qs has a user-defined destructor", type_name);
+           warning (0, "type %qE has a user-defined destructor", type_name);
 
          if (!warn_cxx_ivars)
            {
@@ -7231,8 +7231,8 @@ objc_is_public (tree expr, tree identifier)
 
          if (!klass)
            {
-             error ("cannot find interface declaration for %qs",
-                    IDENTIFIER_POINTER (OBJC_TYPE_NAME (basetype)));
+             error ("cannot find interface declaration for %qE",
+                    OBJC_TYPE_NAME (basetype));
              return 0;
            }
 
@@ -7260,8 +7260,8 @@ objc_is_public (tree expr, tree identifier)
                      int priv = is_private (decl);
 
                      if (priv)
-                       error ("instance variable %qs is declared private",
-                              IDENTIFIER_POINTER (DECL_NAME (decl)));
+                       error ("instance variable %qE is declared private",
+                              DECL_NAME (decl));
 
                      return !priv;
                    }
@@ -7271,15 +7271,15 @@ objc_is_public (tree expr, tree identifier)
                 non-@public ivars.  We will let this slide for now...  */
              if (!objc_method_context)
              {
-               warning (0, "instance variable %qs is %s; "
+               warning (0, "instance variable %qE is %s; "
                         "this will be a hard error in the future",
-                        IDENTIFIER_POINTER (identifier),
+                        identifier,
                         TREE_PRIVATE (decl) ? "@private" : "@protected");
                return 1;
              }
 
-             error ("instance variable %qs is declared %s",
-                    IDENTIFIER_POINTER (identifier),
+             error ("instance variable %qE is declared %s",
+                    identifier,
                     TREE_PRIVATE (decl) ? "private" : "protected");
              return 0;
            }
@@ -7304,17 +7304,17 @@ check_methods (tree chain, tree list, int mtype)
            {
              if (TREE_CODE (objc_implementation_context)
                  == CLASS_IMPLEMENTATION_TYPE)
-               warning (0, "incomplete implementation of class %qs",
-                        IDENTIFIER_POINTER (CLASS_NAME (objc_implementation_context)));
+               warning (0, "incomplete implementation of class %qE",
+                        CLASS_NAME (objc_implementation_context));
              else if (TREE_CODE (objc_implementation_context)
                       == CATEGORY_IMPLEMENTATION_TYPE)
-               warning (0, "incomplete implementation of category %qs",
-                        IDENTIFIER_POINTER (CLASS_SUPER_NAME (objc_implementation_context)));
+               warning (0, "incomplete implementation of category %qE",
+                        CLASS_SUPER_NAME (objc_implementation_context));
              first = 0;
            }
 
-         warning (0, "method definition for %<%c%s%> not found",
-                  mtype, IDENTIFIER_POINTER (METHOD_SEL_NAME (chain)));
+         warning (0, "method definition for %<%c%E%> not found",
+                  mtype, METHOD_SEL_NAME (chain));
        }
 
       chain = TREE_CHAIN (chain);
@@ -7392,18 +7392,16 @@ check_methods_accessible (tree chain, tree context, int mtype)
            {
              if (TREE_CODE (objc_implementation_context)
                  == CLASS_IMPLEMENTATION_TYPE)
-               warning (0, "incomplete implementation of class %qs",
-                        IDENTIFIER_POINTER
-                          (CLASS_NAME (objc_implementation_context)));
+               warning (0, "incomplete implementation of class %qE",
+                        CLASS_NAME (objc_implementation_context));
              else if (TREE_CODE (objc_implementation_context)
                       == CATEGORY_IMPLEMENTATION_TYPE)
-               warning (0, "incomplete implementation of category %qs",
-                        IDENTIFIER_POINTER
-                          (CLASS_SUPER_NAME (objc_implementation_context)));
+               warning (0, "incomplete implementation of category %qE",
+                        CLASS_SUPER_NAME (objc_implementation_context));
              first = 0;
            }
-         warning (0, "method definition for %<%c%s%> not found",
-                  mtype, IDENTIFIER_POINTER (METHOD_SEL_NAME (chain)));
+         warning (0, "method definition for %<%c%E%> not found",
+                  mtype, METHOD_SEL_NAME (chain));
        }
 
       chain = TREE_CHAIN (chain); /* next method...  */
@@ -7416,7 +7414,7 @@ check_methods_accessible (tree chain, tree context, int mtype)
    with any protocols that P inherits.  */
 
 static void
-check_protocol (tree p, const char *type, const char *name)
+check_protocol (tree p, const char *type, tree name)
 {
   if (TREE_CODE (p) == PROTOCOL_INTERFACE_TYPE)
     {
@@ -7443,8 +7441,8 @@ check_protocol (tree p, const char *type, const char *name)
        }
 
       if (!f1 || !f2)
-       warning (0, "%s %qs does not fully implement the %qs protocol",
-                type, name, IDENTIFIER_POINTER (PROTOCOL_NAME (p)));
+       warning (0, "%s %qE does not fully implement the %qE protocol",
+                type, name, PROTOCOL_NAME (p));
     }
 
   /* Check protocols recursively.  */
@@ -7472,7 +7470,7 @@ check_protocol (tree p, const char *type, const char *name)
    in PROTO_LIST.  */
 
 static void
-check_protocols (tree proto_list, const char *type, const char *name)
+check_protocols (tree proto_list, const char *type, tree name)
 {
   for ( ; proto_list; proto_list = TREE_CHAIN (proto_list))
     {
@@ -7520,9 +7518,9 @@ start_class (enum tree_code code, tree class_name, tree super_name,
 
       if (!super || !lookup_interface (super))
        {
-         error ("cannot find interface declaration for %qs, superclass of %qs",
-                IDENTIFIER_POINTER (super ? super : super_name),
-                IDENTIFIER_POINTER (class_name));
+         error ("cannot find interface declaration for %qE, superclass of %qE",
+                super ? super : super_name,
+                class_name);
          super_name = NULL_TREE;
        }
       else
@@ -7536,8 +7534,8 @@ start_class (enum tree_code code, tree class_name, tree super_name,
   if (! objc_is_class_name (class_name)
       && (decl = lookup_name (class_name)))
     {
-      error ("%qs redeclared as different kind of symbol",
-            IDENTIFIER_POINTER (class_name));
+      error ("%qE redeclared as different kind of symbol",
+            class_name);
       error ("previous declaration of %q+D",
             decl);
     }
@@ -7550,8 +7548,8 @@ start_class (enum tree_code code, tree class_name, tree super_name,
         for (chain = implemented_classes; chain; chain = TREE_CHAIN (chain))
            if (TREE_VALUE (chain) == class_name)
             {
-              error ("reimplementation of class %qs",
-                     IDENTIFIER_POINTER (class_name));
+              error ("reimplementation of class %qE",
+                     class_name);
               return error_mark_node;
             }
         implemented_classes = tree_cons (NULL_TREE, class_name,
@@ -7567,8 +7565,8 @@ start_class (enum tree_code code, tree class_name, tree super_name,
 
       if (!(implementation_template = lookup_interface (class_name)))
         {
-         warning (0, "cannot find interface declaration for %qs",
-                  IDENTIFIER_POINTER (class_name));
+         warning (0, "cannot find interface declaration for %qE",
+                  class_name);
          add_class (implementation_template = objc_implementation_context,
                     class_name);
         }
@@ -7580,11 +7578,12 @@ start_class (enum tree_code code, tree class_name, tree super_name,
          && (super_name != CLASS_SUPER_NAME (implementation_template)))
         {
          tree previous_name = CLASS_SUPER_NAME (implementation_template);
-          const char *const name =
-           previous_name ? IDENTIFIER_POINTER (previous_name) : "";
-         error ("conflicting super class name %qs",
-                IDENTIFIER_POINTER (super_name));
-         error ("previous declaration of %qs", name);
+         error ("conflicting super class name %qE",
+                super_name);
+         if (previous_name)
+           error ("previous declaration of %qE", previous_name);
+         else
+           error ("previous declaration");
         }
 
       else if (! super_name)
@@ -7598,11 +7597,11 @@ start_class (enum tree_code code, tree class_name, tree super_name,
     {
       if (lookup_interface (class_name))
 #ifdef OBJCPLUS
-       error ("duplicate interface declaration for class %qs",
+       error ("duplicate interface declaration for class %qE",
 #else
-       warning (0, "duplicate interface declaration for class %qs",
+       warning (0, "duplicate interface declaration for class %qE",
 #endif
-        IDENTIFIER_POINTER (class_name));
+        class_name);
       else
         add_class (klass, class_name);
 
@@ -7621,8 +7620,8 @@ start_class (enum tree_code code, tree class_name, tree super_name,
 
       if (!(class_category_is_assoc_with = lookup_interface (class_name)))
        {
-         error ("cannot find interface declaration for %qs",
-                IDENTIFIER_POINTER (class_name));
+         error ("cannot find interface declaration for %qE",
+                class_name);
          exit (FATAL_EXIT_CODE);
        }
       else
@@ -7646,8 +7645,8 @@ start_class (enum tree_code code, tree class_name, tree super_name,
 
       if (!(implementation_template = lookup_interface (class_name)))
         {
-         error ("cannot find interface declaration for %qs",
-                IDENTIFIER_POINTER (class_name));
+         error ("cannot find interface declaration for %qE",
+                class_name);
          exit (FATAL_EXIT_CODE);
         }
     }
@@ -7741,7 +7740,7 @@ finish_class (tree klass)
          if (CLASS_PROTOCOL_LIST (implementation_template))
            check_protocols (CLASS_PROTOCOL_LIST (implementation_template),
                             "class",
-                            IDENTIFIER_POINTER (CLASS_NAME (objc_implementation_context)));
+                            CLASS_NAME (objc_implementation_context));
        }
     }
 
@@ -7760,7 +7759,7 @@ finish_class (tree klass)
          if (CLASS_PROTOCOL_LIST (category))
            check_protocols (CLASS_PROTOCOL_LIST (category),
                             "category",
-                            IDENTIFIER_POINTER (CLASS_SUPER_NAME (objc_implementation_context)));
+                            CLASS_SUPER_NAME (objc_implementation_context));
        }
     }
 }
@@ -7854,8 +7853,8 @@ start_protocol (enum tree_code code, tree name, tree list)
     }
   else
     {
-      warning (0, "duplicate declaration for protocol %qs",
-              IDENTIFIER_POINTER (name));
+      warning (0, "duplicate declaration for protocol %qE",
+              name);
     }
   return protocol;
 }
@@ -8684,10 +8683,10 @@ really_start_method (tree method,
 
              warning (0, "%Jconflicting types for %<%c%s%>", method,
                       (type ? '-' : '+'),
-                      gen_method_decl (method));
+                      identifier_to_locale (gen_method_decl (method)));
              inform (0, "%Jprevious declaration of %<%c%s%>", proto,
                      (type ? '-' : '+'),
-                     gen_method_decl (proto));
+                     identifier_to_locale (gen_method_decl (proto)));
            }
        }
       else
@@ -8771,8 +8770,8 @@ get_super_receiver (void)
          /* Barf if super used in a category of Object.  */
          if (!super_name)
            {
-             error ("no super class declared in interface for %qs",
-                   IDENTIFIER_POINTER (CLASS_NAME (implementation_template)));
+             error ("no super class declared in interface for %qE",
+                    CLASS_NAME (implementation_template));
              return error_mark_node;
            }
 
@@ -8866,22 +8865,6 @@ objc_finish_method_definition (tree fndecl)
     warning (0, "method possibly missing a [super dealloc] call");
 }
 
-#if 0
-int
-lang_report_error_function (tree decl)
-{
-  if (objc_method_context)
-    {
-      fprintf (stderr, "In method %qs\n",
-              IDENTIFIER_POINTER (METHOD_SEL_NAME (objc_method_context)));
-      return 1;
-    }
-
-  else
-    return 0;
-}
-#endif
-
 /* Given a tree DECL node, produce a printable description of it in the given
    buffer, overwriting the buffer.  */
 
@@ -9493,8 +9476,8 @@ objc_lookup_ivar (tree other, tree id)
       && !DECL_FILE_SCOPE_P (other))
 #endif
     {
-      warning (0, "local declaration of %qs hides instance variable",
-              IDENTIFIER_POINTER (id));
+      warning (0, "local declaration of %qE hides instance variable",
+              id);
 
       return other;
     }
index d531075..55bc3fe 100644 (file)
@@ -719,6 +719,7 @@ pp_construct (pretty_printer *pp, const char *prefix, int maximum_length)
   pp_line_cutoff (pp) = maximum_length;
   pp_prefixing_rule (pp) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
   pp_set_prefix (pp, prefix);
+  pp_translate_identifiers (pp) = true;
 }
 
 /* Append a string delimited by START and END to the output area of
@@ -855,8 +856,14 @@ pp_base_maybe_space (pretty_printer *pp)
 void
 pp_base_tree_identifier (pretty_printer *pp, tree id)
 {
-  const char *text = identifier_to_locale (IDENTIFIER_POINTER (id));
-  pp_append_text (pp, text, text + strlen (text));
+  if (pp_translate_identifiers (pp))
+    {
+      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));
 }
 \f
 /* The string starting at P has LEN (at least 1) bytes left; if they
index 5829225..5c4ddca 100644 (file)
@@ -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.  */
 #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
    proper pretty-printing.  Clients may derived from this structure
    and add additional fields they need.  */
@@ -187,6 +191,10 @@ struct pretty_print_info
 
   /* Nonzero means one should emit a newline before outputting anything.  */
   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) \
@@ -273,7 +281,9 @@ struct pretty_print_info
    pp_scalar (PP, HOST_WIDEST_INT_PRINT_DEC, (HOST_WIDEST_INT) I)
 #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)                      \
   pp_base_tree_identifier (pp_base (PP), T)
 
index c8cbe1d..d9d31ee 100644 (file)
@@ -2767,6 +2767,7 @@ maybe_init_pretty_print (FILE *file)
     {
       pp_construct (&buffer, /* prefix */NULL, /* line-width */0);
       pp_needs_newline (&buffer) = true;
+      pp_translate_identifiers (&buffer) = false;
       initialized = 1;
     }