diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4a059c971085b32e2e6212d14e136b5b61a87998..bdc63518d3253fd3c1420b4f5c5ce686e86ac53a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,12 +1,37 @@
+2005-02-20  Zack Weinberg  <zack@codesourcery.com>
+
+	PR 18785
+	* langhooks.h (struct lang_hooks): Add to_target_charset.
+	* langhooks.c (lhd_to_target_charset): New function.
+	* langhooks-def.h: Declare lhd_to_target_charset.
+	(LANG_HOOKS_TO_TARGET_CHARSET): New macro.
+	(LANG_HOOKS_INITIALIZER): Update.
+	* c-common.c (c_common_to_target_charset): New function.
+	* c-common.h: Declare it.
+	* c-objc-common.h (LANG_HOOKS_TO_TARGET_CHARSET): Set to
+	c_common_to_target_charset.
+
+	* defaults.c (TARGET_BELL, TARGET_BS, TARGET_CR, TARGET_DIGIT0)
+	(TARGET_ESC, TARGET_FF, TARGET_NEWLINE, TARGET_TAB, TARGET_VT):
+	Delete definitions.
+	* system.h: Poison them.
+	* doc/tm.texi: Don't discuss them.
+	* builtins.c (fold_builtin_isdigit): Use lang_hooks.to_target_charset.
+	* c-pretty-print.c (pp_c_integer_constant): Don't use pp_c_char.
+	(pp_c_char): Do not attempt to generate letter escapes for
+	newline, tab, etc.
+	* config/arm/arm.c (output_ascii_pseudo_op): Likewise.
+	* config/mips/mips.c (mips_output_ascii): Likewise.
+
 2005-02-20  Dorit Naishlos  <dorit@il.ibm.com>
 
 	PR tree-optimization/19951
 	* tree-vect-analyze.c (vect_analyze_loop_form): Check if loop exit edge
 	is abnormal.
-	
+
 2005-02-19  Steven Bosscher  <stevenb@suse.de>
 
-	PR middle-end/19698 
+	PR middle-end/19698
 	* function.h (struct function): New field `max_loop_depth'.
 	* cfgloop.c (establish_preds): Update maximum loop depth seen so far.
 	(flow_loops_find): Reset the max loop depth count before finding loops.
diff --git a/gcc/builtins.c b/gcc/builtins.c
index c214ef7ae201df8b0bbb1f6582b13825f796a7da..f0dd878d36b9d99063b04962cad423ce9dcd8f20 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -7623,11 +7623,18 @@ fold_builtin_isdigit (tree arglist)
   else
     {
       /* Transform isdigit(c) -> (unsigned)(c) - '0' <= 9.  */
-      /* According to the C standard, isdigit is unaffected by locale.  */
-      tree arg = TREE_VALUE (arglist);
-      arg = fold_convert (unsigned_type_node, arg);
+      /* According to the C standard, isdigit is unaffected by locale.
+	 However, it definitely is affected by the target character set.  */
+      tree arg;
+      unsigned HOST_WIDE_INT target_digit0
+	= lang_hooks.to_target_charset ('0');
+
+      if (target_digit0 == 0)
+	return NULL_TREE;
+
+      arg = fold_convert (unsigned_type_node, TREE_VALUE (arglist));
       arg = build2 (MINUS_EXPR, unsigned_type_node, arg,
-		    build_int_cst (unsigned_type_node, TARGET_DIGIT0));
+		    build_int_cst (unsigned_type_node, target_digit0));
       arg = build2 (LE_EXPR, integer_type_node, arg,
 		    build_int_cst (unsigned_type_node, 9));
       arg = fold (arg);
diff --git a/gcc/c-common.c b/gcc/c-common.c
index b414915bc872ca18bba608fa9343672c7e9dbdd2..a4dfdd84136bd3370ca6faf4d1dcc337f2d4f2f6 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -5620,6 +5620,27 @@ c_warn_unused_result (tree *top_p)
     }
 }
 
+/* Convert a character from the host to the target execution character
+   set.  cpplib handles this, mostly.  */
+
+HOST_WIDE_INT
+c_common_to_target_charset (HOST_WIDE_INT c)
+{
+  /* Character constants in GCC proper are sign-extended under -fsigned-char,
+     zero-extended under -fno-signed-char.  cpplib insists that characters
+     and character constants are always unsigned.  Hence we must convert
+     back and forth.  */
+  cppchar_t uc = ((cppchar_t)c) & ((((cppchar_t)1) << CHAR_BIT)-1);
+
+  uc = cpp_host_to_exec_charset (parse_in, uc);
+
+  if (flag_signed_char)
+    return ((HOST_WIDE_INT)uc) << (HOST_BITS_PER_WIDE_INT - CHAR_TYPE_SIZE)
+			       >> (HOST_BITS_PER_WIDE_INT - CHAR_TYPE_SIZE);
+  else
+    return uc;
+}
+
 /* Build the result of __builtin_offsetof.  EXPR is a nested sequence of
    component references, with an INDIRECT_REF at the bottom; much like
    the traditional rendering of offsetof as a macro.  Returns the folded
diff --git a/gcc/c-common.h b/gcc/c-common.h
index 13377f167faf32b145f7a58375a2ae99c2779ab9..91be602066b40d292ba6bd00495391e623390e84 100644
--- a/gcc/c-common.h
+++ b/gcc/c-common.h
@@ -688,12 +688,14 @@ extern bool c_promoting_integer_type_p (tree);
 extern int self_promoting_args_p (tree);
 extern tree strip_array_types (tree);
 extern tree strip_pointer_operator (tree);
+extern HOST_WIDE_INT c_common_to_target_charset (HOST_WIDE_INT);
 
 /* This is the basic parsing function.  */
 extern void c_parse_file (void);
 /* This is misnamed, it actually performs end-of-compilation processing.  */
 extern void finish_file	(void);
 
+
 /* These macros provide convenient access to the various _STMT nodes.  */
 
 /* Nonzero if this statement should be considered a full-expression,
diff --git a/gcc/c-objc-common.h b/gcc/c-objc-common.h
index 4c7be6327ab7a496a20f8e1dfcbb41cfa8acf064..c0eb844c06e30d132597eac06eb55a8023e9c984 100644
--- a/gcc/c-objc-common.h
+++ b/gcc/c-objc-common.h
@@ -117,6 +117,8 @@ extern void c_initialize_diagnostics (diagnostic_context *);
 #define LANG_HOOKS_TYPE_PROMOTES_TO c_type_promotes_to
 #undef LANG_HOOKS_REGISTER_BUILTIN_TYPE
 #define LANG_HOOKS_REGISTER_BUILTIN_TYPE c_register_builtin_type
+#undef LANG_HOOKS_TO_TARGET_CHARSET
+#define LANG_HOOKS_TO_TARGET_CHARSET c_common_to_target_charset
 
 /* The C front end's scoping structure is very different from
    that expected by the language-independent code; it is best
diff --git a/gcc/c-pretty-print.c b/gcc/c-pretty-print.c
index 7b741244bbf0508ab6ed06b92e9a9f1f90105b71..aff29d975807afb76600f5456a18eeb5bd7030ec 100644
--- a/gcc/c-pretty-print.c
+++ b/gcc/c-pretty-print.c
@@ -712,50 +712,37 @@ pp_c_function_definition (c_pretty_printer *pp, tree t)
 
 /* Expressions.  */
 
-/* Print out a c-char.  */
+/* Print out a c-char.  This is called solely for characters which are
+   in the *target* execution character set.  We ought to convert them
+   back to the *host* execution character set before printing, but we
+   have no way to do this at present.  A decent compromise is to print
+   all characters as if they were in the host execution character set,
+   and not attempt to recover any named escape characters, but render
+   all unprintables as octal escapes.  If the host and target character
+   sets are the same, this produces relatively readable output.  If they
+   are not the same, strings may appear as gibberish, but that's okay
+   (in fact, it may well be what the reader wants, e.g. if they are looking
+   to see if conversion to the target character set happened correctly).
+
+   A special case: we need to prefix \, ", and ' with backslashes.  It is
+   correct to do so for the *host*'s \, ", and ', because the rest of the
+   file appears in the host character set.  */
 
 static void
 pp_c_char (c_pretty_printer *pp, int c)
 {
-  switch (c)
+  if (ISPRINT (c))
     {
-    case TARGET_NEWLINE:
-      pp_string (pp, "\\n");
-      break;
-    case TARGET_TAB:
-      pp_string (pp, "\\t");
-      break;
-    case TARGET_VT:
-      pp_string (pp, "\\v");
-      break;
-    case TARGET_BS:
-      pp_string (pp, "\\b");
-      break;
-    case TARGET_CR:
-      pp_string (pp, "\\r");
-      break;
-    case TARGET_FF:
-      pp_string (pp, "\\f");
-      break;
-    case TARGET_BELL:
-      pp_string (pp, "\\a");
-      break;
-    case '\\':
-      pp_string (pp, "\\\\");
-      break;
-    case '\'':
-      pp_string (pp, "\\'");
-      break;
-    case '\"':
-      pp_string (pp, "\\\"");
-      break;
-    default:
-      if (ISPRINT (c))
-	pp_character (pp, c);
-      else
-	pp_scalar (pp, "\\%03o", (unsigned) c);
-      break;
+      switch (c)
+	{
+	case '\\': pp_string (pp, "\\\\"); break;
+	case '\'': pp_string (pp, "\\\'"); break;
+	case '\"': pp_string (pp, "\\\""); break;
+	default:   pp_character (pp, c);
+	}
     }
+  else
+    pp_scalar (pp, "\\%03o", (unsigned) c);
 }
 
 /* Print out a STRING literal.  */
@@ -785,7 +772,7 @@ pp_c_integer_constant (c_pretty_printer *pp, tree i)
     {
       if (tree_int_cst_sgn (i) < 0)
         {
-          pp_c_char (pp, '-');
+          pp_character (pp, '-');
           i = build_int_cst_wide (NULL_TREE,
 				  -TREE_INT_CST_LOW (i),
 				  ~TREE_INT_CST_HIGH (i)
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 7c614fd53963c6c44df13a9d4c0f16dfde858408..f8907befd61f0561800422b93471a038b346f470 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -8657,8 +8657,14 @@ int_log2 (HOST_WIDE_INT power)
   return shift;
 }
 
-/* Output a .ascii pseudo-op, keeping track of lengths.  This is because
-   /bin/as is horribly restrictive.  */
+/* Output a .ascii pseudo-op, keeping track of lengths.  This is
+   because /bin/as is horribly restrictive.  The judgement about
+   whether or not each character is 'printable' (and can be output as
+   is) or not (and must be printed with an octal escape) must be made
+   with reference to the *host* character set -- the situation is
+   similar to that discussed in the comments above pp_c_char in
+   c-pretty-print.c.  */
+
 #define MAX_ASCII_LEN 51
 
 void
@@ -8679,57 +8685,20 @@ output_ascii_pseudo_op (FILE *stream, const unsigned char *p, int len)
 	  len_so_far = 0;
 	}
 
-      switch (c)
+      if (ISPRINT (c))
 	{
-	case TARGET_TAB:
-	  fputs ("\\t", stream);
-	  len_so_far += 2;
-	  break;
-
-	case TARGET_FF:
-	  fputs ("\\f", stream);
-	  len_so_far += 2;
-	  break;
-
-	case TARGET_BS:
-	  fputs ("\\b", stream);
-	  len_so_far += 2;
-	  break;
-
-	case TARGET_CR:
-	  fputs ("\\r", stream);
-	  len_so_far += 2;
-	  break;
-
-	case TARGET_NEWLINE:
-	  fputs ("\\n", stream);
-	  c = p [i + 1];
-	  if ((c >= ' ' && c <= '~')
-	      || c == TARGET_TAB)
-	    /* This is a good place for a line break.  */
-	    len_so_far = MAX_ASCII_LEN;
-	  else
-	    len_so_far += 2;
-	  break;
-
-	case '\"':
-	case '\\':
-	  putc ('\\', stream);
-	  len_so_far++;
-	  /* Drop through.  */
-
-	default:
-	  if (c >= ' ' && c <= '~')
+	  if (c == '\\' || c == '\"')
 	    {
-	      putc (c, stream);
+	      putc ('\\', stream);
 	      len_so_far++;
 	    }
-	  else
-	    {
-	      fprintf (stream, "\\%03o", c);
-	      len_so_far += 4;
-	    }
-	  break;
+	  putc (c, stream);
+	  len_so_far++;
+	}
+      else
+	{
+	  fprintf (stream, "\\%03o", c);
+	  len_so_far += 4;
 	}
     }
 
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index b295ffcb8e1bccc789949a0be0e245c1aa419c9f..acd6ae0a704f270768071d2884d118223825f050 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -5135,56 +5135,20 @@ mips_output_ascii (FILE *stream, const char *string_param, size_t len,
     {
       register int c = string[i];
 
-      switch (c)
+      if (ISPRINT (c))
 	{
-	case '\"':
-	case '\\':
-	  putc ('\\', stream);
-	  putc (c, stream);
-	  cur_pos += 2;
-	  break;
-
-	case TARGET_NEWLINE:
-	  fputs ("\\n", stream);
-	  if (i+1 < len
-	      && (((c = string[i+1]) >= '\040' && c <= '~')
-		  || c == TARGET_TAB))
-	    cur_pos = 32767;		/* break right here */
-	  else
-	    cur_pos += 2;
-	  break;
-
-	case TARGET_TAB:
-	  fputs ("\\t", stream);
-	  cur_pos += 2;
-	  break;
-
-	case TARGET_FF:
-	  fputs ("\\f", stream);
-	  cur_pos += 2;
-	  break;
-
-	case TARGET_BS:
-	  fputs ("\\b", stream);
-	  cur_pos += 2;
-	  break;
-
-	case TARGET_CR:
-	  fputs ("\\r", stream);
-	  cur_pos += 2;
-	  break;
-
-	default:
-	  if (c >= ' ' && c < 0177)
+	  if (c == '\\' || c == '\"')
 	    {
-	      putc (c, stream);
+	      putc ('\\', stream);
 	      cur_pos++;
 	    }
-	  else
-	    {
-	      fprintf (stream, "\\%03o", c);
-	      cur_pos += 4;
-	    }
+	  putc (c, stream);
+	  cur_pos++;
+	}
+      else
+	{
+	  fprintf (stream, "\\%03o", c);
+	  cur_pos += 4;
 	}
 
       if (cur_pos > 72 && i+1 < len)
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 62e7a43ee37a5e37e6c3ab777628c50e25a75548..e190787041be776205474e5247ea8f188090b47a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2005-02-20  Zack Weinberg  <zack@codesourcery.com>
+
+	PR 18785
+	* cp-objcp-common.h (LANG_HOOKS_TO_TARGET_CHARSET): Set to
+	c_common_to_target_charset.  Delete bogus comment.
+
 2005-02-18  Richard Henderson  <rth@redhat.com>
 
 	PR libstdc++/10606
@@ -91,8 +97,8 @@
 2005-02-11  Richard Henderson  <rth@redhat.com>
 
 	PR c++/19632
-        * pt.c (get_mostly_instantiated_function_type): Save and restore
-        flag_access_control instead of push/pop_access_scope.
+	* pt.c (get_mostly_instantiated_function_type): Save and restore
+	flag_access_control instead of push/pop_access_scope.
 
 2005-02-10  Mark Mitchell  <mark@codesourcery.com>
 
@@ -203,13 +209,13 @@
 	* cp-tree.h (builtin_valid_in_constant_expr_p): Declare.
 	* parser.c (cp_parser_postfix_expression): Accept function call in
 	constant expression if builtin_valid_in_constant_expr_p is true
-	for that function. 
+	for that function.
 	* pt.c (value_dependent_expression_p): Handle CALL_EXPRs properly.
 	* semantics.c (finish_id_expression): Accept function call in constant
 	expression if builtin_valid_in_constant_expr_p is true for that
-	function. 
+	function.
 	* tree.c (builtin_valid_in_constant_expr_p): New.
-	
+
 2005-02-02  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
 	PR c++/17413
@@ -242,7 +248,7 @@
 2005-02-01  Alexandre Oliva  <aoliva@redhat.com>
 
 	* parser.c (cp_parser_template_id): Revert comment patch too.
-	
+
 	PR c++/18757
 	PR c++/19366
 	PR c++/19499
@@ -326,7 +332,7 @@
 
 	PR c++/19349
 	* name-lookup.c (pushdecl_namespace_level): Avoid accessing free'd
-	memory. 
+	memory.
 
 2005-01-28  Mark Mitchell  <mark@codesourcery.com>
 
@@ -399,7 +405,7 @@
 
 	* typeck.c (comptypes): Handle return code from objc_comptypes
 	correctly.
-	
+
 2005-01-19  Kazu Hirata  <kazu@cs.umass.edu>
 
 	* cp-tree.h, name-lookup.h: Remove unused prototypes.
@@ -562,8 +568,8 @@
 	names.
 	(cp_parser_member_declaration): Adjust call to make_id_declarator.
 	(cp_parser_check_declarator_template_parameters): Do not expect a
-	SCOPE_REF. 
-	
+	SCOPE_REF.
+
 	* decl.c (duplicate_decls): Call ggc_free on declarations we will
 	not be needing any longer.
 
@@ -617,7 +623,7 @@
 	* call.c (build_this): In templates, do not bother with
 	build_unary_op.
 	* typeck.c (unary_complex_lvalue): In a template, always refuse
-	simplifications. 
+	simplifications.
 
 	PR c++/18492
 	* cp-gimplify.c (cp_genericize): Relax assertion.
@@ -627,7 +633,7 @@
 
 	PR c++/18257
 	* rtti.c (emit_support_tinfos): On systems without weak symbols,
-	emit the runtime library type-info objects as non-COMDAT. 
+	emit the runtime library type-info objects as non-COMDAT.
 
 2004-12-21  Mark Mitchell  <mark@codesourcery.com>
 
@@ -670,14 +676,14 @@
 	* error.c (dump_expr): <STRING_CST case> Add parens, if needed.
 
 	* cp-tree.def (TEMPLATE_TYPE_PARM,
-	BOUND_TEMPLATE_TEMPLATE_PARM, TYPE_OF_TYPE, TYPENAME_TYPE): Reorder 
+	BOUND_TEMPLATE_TEMPLATE_PARM, TYPE_OF_TYPE, TYPENAME_TYPE): Reorder
 	for better code efficiency.
 	* cp-tree.h (CLASS_TYPE_P): Short circuit IS_AGGR_TYPE check.
 	(CAN_HAVE_FULL_LANG_DECL_P): Reorder for better optimization.
 	(INTEGRAL_CODE_P, CP_INTEGRAL_TYPE_P,
 	INTEGRAL_OR_ENUMERATION_TYPE_P, SCALAR_TYPE_P,
 	CP_AGGREGATE_TYPE_P, TYPE_PTROB_P, TYPE_REF_OBJ_P,
-	TYPE_PTROBV_P): Likewise. 
+	TYPE_PTROBV_P): Likewise.
 
 	PR c++/18975
 	* method.c (do_build_copy_constructor): Refactor. Don't const
@@ -689,7 +695,7 @@
 	PR c++/19044
 	* decl.c (make_rtl_for_nonlocal_decl): Use
 	set_builtin_user_assembler_name.
-	
+
 2004-12-19  Mark Mitchell  <mark@codesourcery.com>
 
 	* cp-tree.h (note_decl_for_pch): New function.
@@ -826,7 +832,7 @@
 	PR c++/18514
 	* name-lookup.c (do_nonmember_using_decl): A real function
 	declaration takes precedence over an anticipated declaration.
-	
+
 2004-12-09  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
 	* parser.c (cp_parser_member_declaration): Fix comment typo.
@@ -855,7 +861,7 @@
 2004-12-08  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
 	PR c++/18100
-	* decl.c (lookup_and_check_tag): Diagnose nested class with 
+	* decl.c (lookup_and_check_tag): Diagnose nested class with
 	the same name as enclosing class.
 
 2004-12-08  Nathan Sidwell  <nathan@codesourcery.com>
@@ -1044,7 +1050,7 @@
 	make_typename_type.
 	(tsubst_decl): Do not pre-substitute the type of the declaration.
 	(tsubst): Hand off declarations more quickly.  Adjust call to
-	make_typename_type. 
+	make_typename_type.
 
 	PR c++/18512
 	* parser.c (cp_parser_postfix_dot_deref_expression): Robustify.
@@ -1140,7 +1146,7 @@
 	(lookup_type_scope): Adjust declaration.
 	* decl.c (lookup_and_check_tag, xref_tag, xref_tag_from_type):
 	Change bool parameter GLOBALIZED to TAG_SCOPE parameter SCOPE.
-	(start_enum): Likewise.  Add assertion test that NAME is 
+	(start_enum): Likewise.  Add assertion test that NAME is
 	IDENTIFIER_NODE.  Use anonymous name for dummy ENUMERAL_TYPE in
 	case of error.
 	* cp-tree.h (xref_tag, xref_tag_from_type): Adjust declarations.
@@ -1280,7 +1286,7 @@
 	PR c++/18407
 	* pt.c (tsubst_copy_and_build): Handle qualified names used from a
 	derived class correctly.
-	
+
 	* decl2.c (import_export_decl): Fix typo in comment.
 	* tree.c (pod_type_p): Likewise.
 
@@ -1290,7 +1296,7 @@
 
 2004-11-10  Adam Nemet  <anemet@lnxw.com>
 
-	PR middle-end/18160  
+	PR middle-end/18160
 	* typeck.c (cxx_mark_addressable): Issue an error if address of an
 	explicit register variable is requested.
 
@@ -1328,7 +1334,7 @@
 	search.c, typeck2.c: Fix comment formatting.
 
 2004-11-04  Ulrich Weigand  <uweigand@de.ibm.com>
-	
+
 	PR tree-optimization/18184
 	* cp-objcp-common.c (cxx_types_compatible_p): Do not treat pointers
 	of different modes or alias-all flags as equivalent.
@@ -1380,26 +1386,26 @@
 2004-10-31  Gabriel Dos Reis  <gdr@integrable-solutions.net>
 
 	Convert diagnostics to use quoting flag q 9/n
-	* typeck.c (build_x_unary_op, convert_member_func_to_ptr, 
+	* typeck.c (build_x_unary_op, convert_member_func_to_ptr,
 	get_delta_difference):  Use new quotation style.
 	* repo.c (reopen_repo_file_for_write): Likewise.
 	* pt.c (do_type_instantiation): Likewise.
-	* parser.c (cp_parser_diagnose_invalid_type_name): 
-	* name-lookup.c (push_overloaded_decl, set_decl_namespace): 
+	* parser.c (cp_parser_diagnose_invalid_type_name):
+	* name-lookup.c (push_overloaded_decl, set_decl_namespace):
 	* error.c (cp_print_error_function,
 	print_instantiation_full_context): Likewise.
-	* decl.c (define_label, grok_reference_init, 
-	maybe_deduce_size_from_array_init, revert_static_member_fn): 
+	* decl.c (define_label, grok_reference_init,
+	maybe_deduce_size_from_array_init, revert_static_member_fn):
 	* decl2.c (check_classfn): Likewise.
-	* class.c (add_method, check_field_decls, layout_class_type, 
+	* class.c (add_method, check_field_decls, layout_class_type,
 	resolve_address_of_overloaded_function): Likewise.
 	* call.c (build_x_va_arg, build_over_call): Likewise.
 
 2004-10-31  Gabriel Dos Reis  <gdr@integrable-solutions.net>
 
 	Convert diagnostics to use quoting flag q 8/n
-	* cvt.c (cp_convert_to_pointer, warn_ref_binding, 
-	convert_to_reference, ocp_convert, convert_to_void 
+	* cvt.c (cp_convert_to_pointer, warn_ref_binding,
+	convert_to_reference, ocp_convert, convert_to_void
 	cp_convert_to_pointer): Use new quotation style.
 
 2004-10-31  Mark Mitchell  <mark@codesourcery.com>
@@ -1407,7 +1413,7 @@
 	PR c++/15172
 	* typeck2.c (store_init_value): Use split_nonconstant_init even
 	for types that require construction.
-	
+
 1004-10-28  Matt Austern  <austern@apple.com>
 
 	PR c++/17542
@@ -1416,7 +1422,7 @@
 	and remove static qualifier.
 	* decl.c (shadow_tag): Warn about ignored attributes in class/struct/
 	union/enum declaration.
-	
+
 2004-10-29  Kazu Hirata  <kazu@cs.umass.edu>
 
 	* pt.c: Fix a comment typo.
@@ -1439,7 +1445,7 @@
 	PR c++/14124
 	* decl.c (finish_enum): Handle packed attribute.
 	* parser.c (cp_parser_enum_specifier): Process trailing attributes.
-	
+
 2004-10-28  Mark Mitchell  <mark@codesourcery.com>
 
 	PR c++/17132
@@ -1579,7 +1585,7 @@
 	(build_reinterpret_cast_1): Add for_reinterpret_cast_p parameter.
 	Allow function pointer conversions that DR195 suggests.
 	(build_reinterpret_cast, build_c_cast): Update
-	build_reinterpret_cast_1 calls. 
+	build_reinterpret_cast_1 calls.
 
 2004-10-20  Kazu Hirata  <kazu@cs.umass.edu>
 
@@ -1700,7 +1706,7 @@
 	* parser.c (cp_parser_simple_declaration): Do not diagnose invalid
 	type names if we have already found a valid type.
 	(cp_parser_member_declaration): Likewise.
-	
+
 	PR c++/17916
 	* parser.c (cp_parser_member_specification_opt): Handle
 	CPP_PRAGMA.
@@ -1733,7 +1739,7 @@
 	* pt.c (struct pair_fn_data): Use pointer_set_t, not htab_t
 	(for_each_template_parm): Convert from htab_t to pointer_set_t.
 	* tree.c (cp_walk_subtrees): Last argument is pointer_set_t* now.
-	
+
 2004-10-13  Andrew Pinski  <pinskia@physics.uc.edu>
 
 	PR c++/17661
@@ -1765,7 +1771,7 @@
 2004-10-11  Mark Mitchell  <mark@codesourcery.com>
 
 	PR c++/15786
-	* parser.c (cp_parser_declarator): Add member_p parameter. 
+	* parser.c (cp_parser_declarator): Add member_p parameter.
 	(cp_parser_condition): Adjust calls to cp_parser_declarator.
 	(cp_parser_explicit_instantiation): Likewise.
 	(cp_parser_init_declarator): Likewise.
@@ -1849,34 +1855,34 @@
 2004-10-10  Gabriel Dos Reis  <gdr@integrable-solutions.net>
 
 	Convert diagnostics to use quoting flag q 7/n
-	* typeck.c (composite_pointer_type_r, composite_pointer_type, 
-	cxx_sizeof_or_alignof_type, cxx_sizeof_or_alignof_expr, 
-	string_conv_p, build_class_member_access_expr, 
-	build_class_member_access_expr, lookup_destructor, 
-	finish_class_member_access_expr, build_indirect_ref, 
-	get_member_function_from_ptrfunc, build_function_call, 
-	convert_arguments, build_binary_op, pointer_diff, build_unary_op, 
-	check_for_casting_away_constness, build_static_cast, 
-	build_reinterpret_cast, build_const_cast, build_c_cast, 
-	build_modify_expr, get_delta_difference, build_ptrmemfunc, 
-	dubious_conversion_warnings, convert_for_assignment, 
-	convert_for_initialization, 
-	maybe_warn_about_returning_address_of_local, check_return_expr): 
+	* typeck.c (composite_pointer_type_r, composite_pointer_type,
+	cxx_sizeof_or_alignof_type, cxx_sizeof_or_alignof_expr,
+	string_conv_p, build_class_member_access_expr,
+	build_class_member_access_expr, lookup_destructor,
+	finish_class_member_access_expr, build_indirect_ref,
+	get_member_function_from_ptrfunc, build_function_call,
+	convert_arguments, build_binary_op, pointer_diff, build_unary_op,
+	check_for_casting_away_constness, build_static_cast,
+	build_reinterpret_cast, build_const_cast, build_c_cast,
+	build_modify_expr, get_delta_difference, build_ptrmemfunc,
+	dubious_conversion_warnings, convert_for_assignment,
+	convert_for_initialization,
+	maybe_warn_about_returning_address_of_local, check_return_expr):
 	Use quoting marks.
 
-	* typeck2.c (error_not_base_type, readonly_error, 
-	abstract_virtuals_error, cxx_incomplete_type_diagnostic, 
-	store_init_value, digest_init, build_x_arrow, 
+	* typeck2.c (error_not_base_type, readonly_error,
+	abstract_virtuals_error, cxx_incomplete_type_diagnostic,
+	store_init_value, digest_init, build_x_arrow,
 	build_m_component_ref, require_complete_eh_spec_types): Likewise.
 
-	* tree.c (cp_build_qualified_type_real, 
+	* tree.c (cp_build_qualified_type_real,
 	handle_java_interface_attribute, handle_init_priority_attribute):
 	Likewise.
 
-	* semantics.c (finish_asm_stmt, finish_non_static_data_member, 
-	finish_pseudo_destructor_expr, 
-	check_template_template_default_arg, begin_class_definition, 
-	finish_base_specifier, qualified_name_lookup_error, 
+	* semantics.c (finish_asm_stmt, finish_non_static_data_member,
+	finish_pseudo_destructor_expr,
+	check_template_template_default_arg, begin_class_definition,
+	finish_base_specifier, qualified_name_lookup_error,
 	finish_id_expression, finish_typeof): Likewise.
 
 	* search.c (lookup_base, check_final_overrider,
@@ -1912,7 +1918,7 @@
 	PR c++/17685
 	* decl.c (grokdeclarator): Disallow declarations of operators as
 	non-functions.
-	
+
 2004-10-08  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
 	PR c++/17868
@@ -2018,20 +2024,20 @@
 2004-10-05  Gabriel Dos Reis  <gdr@integrable-solutions.net>
 
 	Convert diagnostics to use quoting flag q 6/n
-	* pt.c (finish_member_template_decl, check_specialization_scope, 
-	maybe_process_partial_specialization, determine_specialization, 
-	check_explicit_specialization, maybe_check_template_type, 
-	process_partial_specialization, check_default_tmpl_args, 
-	push_template_decl_real, redeclare_class_template, 
-	convert_nontype_argument, coerce_template_parms, 
-	lookup_template_class, push_tinst_level, 
-	instantiate_class_template, tsubst_arg_types, 
-	tsubst_function_type, tsubst, tsubst_qualified_id, 
-	tsubst_copy_and_build, check_instantiated_args, 
-	do_decl_instantiation, do_type_instantiation, 
-	invalid_nontype_parm_type_p, check_specialization_namespace, 
-	convert_template_argument, determine_specialization, 
-	check_template_shadow, tsubst_decl 
+	* pt.c (finish_member_template_decl, check_specialization_scope,
+	maybe_process_partial_specialization, determine_specialization,
+	check_explicit_specialization, maybe_check_template_type,
+	process_partial_specialization, check_default_tmpl_args,
+	push_template_decl_real, redeclare_class_template,
+	convert_nontype_argument, coerce_template_parms,
+	lookup_template_class, push_tinst_level,
+	instantiate_class_template, tsubst_arg_types,
+	tsubst_function_type, tsubst, tsubst_qualified_id,
+	tsubst_copy_and_build, check_instantiated_args,
+	do_decl_instantiation, do_type_instantiation,
+	invalid_nontype_parm_type_p, check_specialization_namespace,
+	convert_template_argument, determine_specialization,
+	check_template_shadow, tsubst_decl
 	instantiate_pending_templates): Use quoting marks.
 
 2004-10-05  Nathan Sidwell  <nathan@codesourcery.com>
@@ -2043,41 +2049,41 @@
 2004-10-04  Gabriel Dos Reis  <gdr@integrable-solutions.net>
 
 	Convert diagnostics to use quoting flag q 5/n
-	* parser.c (cp_parser_name_lookup_error, 
-	cp_parser_diagnose_invalid_type_name, 
-	cp_parser_primary_expression, cp_parser_unqualified_id, 
-	cp_parser_nested_name_specifier_opt, cp_parser_labeled_statement, 
-	cp_parser_jump_statement, cp_parser_simple_declaration, 
-	cp_parser_decl_specifier_seq, cp_parser_mem_initializer_id, 
-	cp_parser_type_parameter, cp_parser_template_id, 
-	cp_parser_template_name, cp_parser_direct_declarator, 
-	cp_parser_parameter_declaration_list, cp_parser_class_head, 
-	cp_parser_base_specifier, cp_parser_lookup_name, 
-	cp_parser_late_parsing_default_args, 
-	cp_parser_optional_template_keyword 
-	cp_parser_elaborated_type_specifier, cp_parser_check_class_key, 
+	* parser.c (cp_parser_name_lookup_error,
+	cp_parser_diagnose_invalid_type_name,
+	cp_parser_primary_expression, cp_parser_unqualified_id,
+	cp_parser_nested_name_specifier_opt, cp_parser_labeled_statement,
+	cp_parser_jump_statement, cp_parser_simple_declaration,
+	cp_parser_decl_specifier_seq, cp_parser_mem_initializer_id,
+	cp_parser_type_parameter, cp_parser_template_id,
+	cp_parser_template_name, cp_parser_direct_declarator,
+	cp_parser_parameter_declaration_list, cp_parser_class_head,
+	cp_parser_base_specifier, cp_parser_lookup_name,
+	cp_parser_late_parsing_default_args,
+	cp_parser_optional_template_keyword
+	cp_parser_elaborated_type_specifier, cp_parser_check_class_key,
 	cp_parser_check_access_in_redeclaration): Use quoting marks.
 
-	* name-lookup.c (supplement_binding, pushdecl, 
-	check_for_out_of_scope_variable, validate_nonmember_using_decl, 
-	do_nonmember_using_decl, lookup_tag, set_decl_namespace, 
-	push_namespace, do_namespace_alias, do_using_directive, 
+	* name-lookup.c (supplement_binding, pushdecl,
+	check_for_out_of_scope_variable, validate_nonmember_using_decl,
+	do_nonmember_using_decl, lookup_tag, set_decl_namespace,
+	push_namespace, do_namespace_alias, do_using_directive,
 	ambiguous_decl, lookup_namespace_name, add_function): Likewise.
 
 	* method.c (use_thunk): Likewise.
 
-	* lex.c (unqualified_name_lookup_error, 
+	* lex.c (unqualified_name_lookup_error,
 	unqualified_fn_lookup_error): Likewise.
 
 2004-10-04  Gabriel Dos Reis  <gdr@integrable-solutions.net>
 
 	Convert diagnostics to use quoting flag q 4/n
-	* except.c (decl_is_java_type, build_throw, 
-	is_admissible_throw_operand, check_handlers_1, check_handlers): 
+	* except.c (decl_is_java_type, build_throw,
+	is_admissible_throw_operand, check_handlers_1, check_handlers):
 	Use quoting formats.
 	* friend.c (add_friend, make_friend_class, do_friend): Likewise.
-	* init.c (sort_mem_initializers, emit_mem_initializers, 
-	member_init_ok_or_else, expand_member_init, is_aggr_type, 
+	* init.c (sort_mem_initializers, emit_mem_initializers,
+	member_init_ok_or_else, expand_member_init, is_aggr_type,
 	build_offset_ref, build_java_class_ref): Likewise.
 
 2004-10-03  Gabriel Dos Reis  <gdr@integrable-solutions.net>
@@ -2086,20 +2092,20 @@
 	* decl.c (pop_label, duplicate_decls, redeclaration_error_message,
 	redeclaration_error_message, lookup_label, check_goto,
 	make_typename_type, make_unbound_class_template,
-	fixup_anonymous_aggr, check_tag_decl, start_decl, start_decl_1, 
-	grok_reference_init, layout_var_decl, maybe_commonize_var, 
-	check_for_uninitialized_const_var, reshape_init_array, 
+	fixup_anonymous_aggr, check_tag_decl, start_decl, start_decl_1,
+	grok_reference_init, layout_var_decl, maybe_commonize_var,
+	check_for_uninitialized_const_var, reshape_init_array,
 	reshape_init, check_initializer, cp_finish_decl,
-	member_function_or_else, bad_specifiers, grokfndecl, grokvardecl, 
-	check_static_variable_definition, compute_array_index_type, 
-	create_array_type_for_decl, check_special_function_return_type, 
-	grokdeclarator, check_default_argument, grokparms, 
-	grok_ctor_properties, grok_op_properties, 
-	check_elaborated_type_specifier, xref_tag, finish_enum, 
-	build_enumerator, check_function_type, start_preparsed_function, 
+	member_function_or_else, bad_specifiers, grokfndecl, grokvardecl,
+	check_static_variable_definition, compute_array_index_type,
+	create_array_type_for_decl, check_special_function_return_type,
+	grokdeclarator, check_default_argument, grokparms,
+	grok_ctor_properties, grok_op_properties,
+	check_elaborated_type_specifier, xref_tag, finish_enum,
+	build_enumerator, check_function_type, start_preparsed_function,
 	store_parm_decls): Use quoting formats.
-	* decl2.c (grok_array_decl, delete_sanity, check_member_template, 
-	check_java_method, check_classfn, finish_static_data_member_decl, 
+	* decl2.c (grok_array_decl, delete_sanity, check_member_template,
+	check_java_method, check_classfn, finish_static_data_member_decl,
 	grokfield, grokbitfield, grok_function_init,
 	build_anon_union_vars, coerce_new_type, coerce_delete_type,
 	check_default_args): Likewise.
@@ -2224,7 +2230,7 @@
 	header that was implicitly extern "C".
 	(cp_parser_declaration_seq_opt): Push/pop lang context as
 	required by the token's and parser's implicit_extern_c.
-	
+
 2004-09-27  Mark Mitchell  <mark@codesourcery.com>
 
 	PR c++/17585
@@ -2246,11 +2252,11 @@
 	(dfs_depth_post, dfs_depth_q): Remove.
 	(find_final_overrider): Use number of vbase classes as depth
 	bound.
-	
+
 	* cp-tree.h (types_overlap_p): Remove.
 	* search.c (struct overlap_info): Remove.
 	(dfs_check_overlap, dfs_no_overlap_yet, types_overlap_p): Remove.
-	
+
 	* pt.c (GTB_VIA_VIRTUAL, GTB_IGNORE_TYPE): Remove.
 	(get_template_base_recursive): Remove. Replace with ...
 	(get_template_base_r): ... this.
diff --git a/gcc/cp/cp-objcp-common.h b/gcc/cp/cp-objcp-common.h
index 7a2a2343b7c379e0713f43ea16655abf9cba2cd4..9baba3fc4caea4fe3875364cd75bdc4e781ffb84 100644
--- a/gcc/cp/cp-objcp-common.h
+++ b/gcc/cp/cp-objcp-common.h
@@ -159,6 +159,8 @@ extern tree objcp_tsubst_copy_and_build (tree, tree, tsubst_flags_t,
 #define LANG_HOOKS_TYPE_PROMOTES_TO cxx_type_promotes_to
 #undef LANG_HOOKS_REGISTER_BUILTIN_TYPE
 #define LANG_HOOKS_REGISTER_BUILTIN_TYPE c_register_builtin_type
+#undef LANG_HOOKS_TO_TARGET_CHARSET
+#define LANG_HOOKS_TO_TARGET_CHARSET c_common_to_target_charset
 #undef LANG_HOOKS_GIMPLIFY_EXPR
 #define LANG_HOOKS_GIMPLIFY_EXPR cp_gimplify_expr
 
diff --git a/gcc/defaults.h b/gcc/defaults.h
index 7c8812963940181ebec0ef3a36b586670a7bad2a..0347121eac5fd928d461d562e71ed093f8dbe273 100644
--- a/gcc/defaults.h
+++ b/gcc/defaults.h
@@ -36,19 +36,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 		  obstack_chunk_alloc,			\
 		  obstack_chunk_free)
 
-/* Define default standard character escape sequences.  */
-#ifndef TARGET_BELL
-#  define TARGET_BELL 007
-#  define TARGET_BS 010
-#  define TARGET_CR 015
-#  define TARGET_DIGIT0 060
-#  define TARGET_ESC 033
-#  define TARGET_FF 014
-#  define TARGET_NEWLINE 012
-#  define TARGET_TAB 011
-#  define TARGET_VT 013
-#endif
-
 /* Store in OUTPUT a string (made with alloca) containing an
    assembler-name for a local static variable or function named NAME.
    LABELNO is an integer which is different for each call.  */
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 023b907a49039fcf24dd2c284de477f51b4122d4..b50c1a57b6d6f2b6296d607bc029c494bdb3556c 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -31,7 +31,6 @@ through the macros defined in the @file{.h} file.
 * Per-Function Data::   Defining data structures for per-function information.
 * Storage Layout::      Defining sizes and alignments of data.
 * Type Layout::         Defining sizes and properties of basic user data types.
-* Escape Sequences::    Defining the value of target character escape sequences
 * Registers::           Naming and describing the hardware registers.
 * Register Classes::    Defining the classes of hardware registers.
 * Stack and Calling::   Defining which way the stack grows and by how much.
@@ -1816,42 +1815,6 @@ specified by @code{TARGET_VTABLE_ENTRY_ALIGN}), set this to the number
 of words in each data entry.
 @end defmac
 
-@node Escape Sequences
-@section Target Character Escape Sequences
-@cindex escape sequences
-
-By default, GCC assumes that the C character escape sequences and other
-characters take on their ASCII values for the target.  If this is not
-correct, you must explicitly define all of the macros below.  All of
-them must evaluate to constants; they are used in @code{case}
-statements.
-
-@findex TARGET_BELL
-@findex TARGET_BS
-@findex TARGET_CR
-@findex TARGET_DIGIT0
-@findex TARGET_ESC
-@findex TARGET_FF
-@findex TARGET_NEWLINE
-@findex TARGET_TAB
-@findex TARGET_VT
-@multitable {@code{TARGET_NEWLINE}} {Escape} {ASCII character}
-@item Macro                 @tab Escape             @tab ASCII character
-@item @code{TARGET_BELL}    @tab @kbd{\a}           @tab @code{07}, @code{BEL}
-@item @code{TARGET_BS}      @tab @kbd{\b}           @tab @code{08}, @code{BS}
-@item @code{TARGET_CR}      @tab @kbd{\r}           @tab @code{0D}, @code{CR}
-@item @code{TARGET_DIGIT0}  @tab @kbd{0}            @tab @code{30}, @code{ZERO}
-@item @code{TARGET_ESC}     @tab @kbd{\e}, @kbd{\E} @tab @code{1B}, @code{ESC}
-@item @code{TARGET_FF}      @tab @kbd{\f}           @tab @code{0C}, @code{FF}
-@item @code{TARGET_NEWLINE} @tab @kbd{\n}           @tab @code{0A}, @code{LF}
-@item @code{TARGET_TAB}     @tab @kbd{\t}           @tab @code{09}, @code{HT}
-@item @code{TARGET_VT}      @tab @kbd{\v}           @tab @code{0B}, @code{VT}
-@end multitable
-
-@noindent
-Note that the @kbd{\e} and @kbd{\E} escapes are GNU extensions, not
-part of the C standard.
-
 @node Registers
 @section Register Usage
 @cindex register usage
diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h
index 59083ad7b563ea7aea728e0f5b100377ad097053..fc6decaaf8598335490996988277b5583379cc07 100644
--- a/gcc/langhooks-def.h
+++ b/gcc/langhooks-def.h
@@ -68,6 +68,7 @@ extern bool lhd_decl_ok_for_sibcall (tree);
 extern const char *lhd_comdat_group (tree);
 extern tree lhd_expr_size (tree);
 extern size_t lhd_tree_size (enum tree_code);
+extern HOST_WIDE_INT lhd_to_target_charset (HOST_WIDE_INT);
 
 /* Declarations of default tree inlining hooks.  */
 extern tree lhd_tree_inlining_walk_subtrees (tree *, int *, walk_tree_fn,
@@ -122,6 +123,7 @@ extern int lhd_gimplify_expr (tree *, tree *, tree *);
 #define LANG_HOOKS_TREE_SIZE		lhd_tree_size
 #define LANG_HOOKS_TYPES_COMPATIBLE_P	lhd_types_compatible_p
 #define LANG_HOOKS_BUILTIN_FUNCTION	builtin_function
+#define LANG_HOOKS_TO_TARGET_CHARSET	lhd_to_target_charset
 
 #define LANG_HOOKS_FUNCTION_INIT	lhd_do_nothing_f
 #define LANG_HOOKS_FUNCTION_FINAL	lhd_do_nothing_f
@@ -285,6 +287,7 @@ extern tree lhd_make_node (enum tree_code);
   LANG_HOOKS_GET_CALLEE_FNDECL, \
   LANG_HOOKS_PRINT_ERROR_FUNCTION, \
   LANG_HOOKS_EXPR_SIZE, \
+  LANG_HOOKS_TO_TARGET_CHARSET, \
   LANG_HOOKS_ATTRIBUTE_TABLE, \
   LANG_HOOKS_COMMON_ATTRIBUTE_TABLE, \
   LANG_HOOKS_FORMAT_ATTRIBUTE_TABLE, \
diff --git a/gcc/langhooks.c b/gcc/langhooks.c
index 0cf31be78067d727acf35eada568ff8502ba064e..c29168c4f0ab3df2d9f419344312b73580e2acfc 100644
--- a/gcc/langhooks.c
+++ b/gcc/langhooks.c
@@ -546,3 +546,9 @@ lhd_make_node (enum tree_code code)
 {
   return make_node (code);
 }
+
+HOST_WIDE_INT
+lhd_to_target_charset (HOST_WIDE_INT c)
+{
+  return c;
+}
diff --git a/gcc/langhooks.h b/gcc/langhooks.h
index f57f14821ec92e9221a6ea9a836788ff882119ad..a3dc6fa89fabe8edacf9538fabf739ee9a168074 100644
--- a/gcc/langhooks.h
+++ b/gcc/langhooks.h
@@ -374,6 +374,15 @@ struct lang_hooks
      semantics in cases that it doesn't want to handle specially.  */
   tree (*expr_size) (tree);
 
+  /* Convert a character from the host's to the target's character
+     set.  The character should be in what C calls the "basic source
+     character set" (roughly, the set of characters defined by plain
+     old ASCII).  The default is to return the character unchanged,
+     which is correct in most circumstances.  Note that both argument
+     and result should be sign-extended under -fsigned-char,
+     zero-extended under -fno-signed-char.  */
+  HOST_WIDE_INT (*to_target_charset) (HOST_WIDE_INT);
+
   /* Pointers to machine-independent attribute tables, for front ends
      using attribs.c.  If one is NULL, it is ignored.  Respectively, a
      table of attributes specific to the language, a table of
diff --git a/gcc/system.h b/gcc/system.h
index 752c2542b2661e4d07e9a31a175150dca182e66c..fd7c64bd4dba356b5aedda4175d83b6434b0681e 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -660,7 +660,8 @@ extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN;
 	PUT_SDB_SRC_FILE STABS_GCC_MARKER DBX_OUTPUT_FUNCTION_END	   \
 	DBX_OUTPUT_GCC_MARKER DBX_FINISH_SYMBOL SDB_GENERATE_FAKE	   \
 	NON_SAVING_SETJMP TARGET_LATE_RTL_PROLOGUE_EPILOGUE		   \
-	CASE_DROPS_THROUGH
+	CASE_DROPS_THROUGH TARGET_BELL TARGET_BS TARGET_CR TARGET_DIGIT0   \
+        TARGET_ESC TARGET_FF TARGET_NEWLINE TARGET_TAB TARGET_VT
 
 /* Hooks that are no longer used.  */
  #pragma GCC poison LANG_HOOKS_FUNCTION_MARK LANG_HOOKS_FUNCTION_FREE	\
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 16498815ecab487b1a1298d1a31d0fe0d885d130..bfcbe971fbb670f72c694481354b0d8f4c7afa38 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2005-02-20  Zack Weinberg  <zack@codesourcery.com>
+
+	PR 18785
+	* gcc.dg/charset/builtin1.c: New test.
+
 2005-02-19  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
 	PR c++/19299
@@ -13,7 +18,7 @@
 2005-02-19  Devang Patel  <dpatel@apple.com>
 
 	* gcc.dg/cpp/mac-eol-at-eof.c: New test.
-	
+
 2005-02-19  Steven G. Kargl  <kargls@comcast.net>
 
 	* gfortran.dg/achar_1.f90: New test.
@@ -47,8 +52,8 @@
 
 2005-01-20  Giovanni Bajo  <giovannibajo@gcc.gnu.org>
 
-        PR c++/19508
-        * g++.dg/ext/attrib20.C: New test.
+	PR c++/19508
+	* g++.dg/ext/attrib20.C: New test.
 
 2004-02-18  Andrew Pinski  <pinskia@physics.uc.edu>
 
@@ -315,9 +320,9 @@
 	no longer optimize.
 	* gcc.dg/builtins-47.c: New testcase.
 
-2005-02-07  Leehod Baruch  <leehod@il.ibm.com> 
+2005-02-07  Leehod Baruch  <leehod@il.ibm.com>
 	    Dorit Naishlos  <dorit@il.ibm.com>
-	
+
 	* testsuite/gcc.dg/vect/vect.exp: Add -ftree-vectorizer-verbose=3.
 
 2005-02-06  Richard Sandiford  <rsandifo@redhat.com>
@@ -346,7 +351,7 @@
 2005-02-03  Dorit Naishlos  <dorit@il.ibm.com>
 
 	* gcc.dg/vect/vect-85.c: Remove xfail.
-	* gcc.dg/vect/vect-86.c: Remove xfail. 
+	* gcc.dg/vect/vect-86.c: Remove xfail.
 	* gcc.dg/vect/vect-87.c: Remove xfail.
 	* gcc.dg/vect/vect-88.c: Remove xfail.
 
@@ -370,7 +375,7 @@
 	PR c++/19628
 	* g++/ext/builtin7.C: New.
 	* g++/ext/builtin8.C: New.
-	
+
 2005-02-02  Joseph S. Myers  <joseph@codesourcery.com>
 
 	PR c/18502
@@ -524,7 +529,7 @@
 	* g++.dg/template/static10.C: New test.
 
 	PR c++/19395
-	* g++.dg/parse/error24.C: New test. 
+	* g++.dg/parse/error24.C: New test.
 
 	PR c++/19367
 	* g++.dg/lookup/builtin1.C: New test.
@@ -645,7 +650,7 @@
 
 2005-01-26  Greg Parker  <gparker@apple.com>
 	Stuart Hastings  <stuart@apple.com>
-	
+
 	* gcc.c-torture/execute/20050125-1.c: New.
 
 2005-01-18  Jan Hubicka  <jh@suse.cz>
@@ -958,7 +963,7 @@
 	* ada/acats/tests/c3/c92005b.ada: Likewise.
 	* ada/acats/tests/c3/cxb3012.a: Likewise.
 	* ada/acats/norun.lst: Add c380004 and c953002, add PR
-	
+
 2005-01-09  Paul Brook  <paul@codesourcery.com>
 
 	* gfortran.dg/common_2.f90: New file.
diff --git a/gcc/testsuite/gcc.dg/charset/builtin1.c b/gcc/testsuite/gcc.dg/charset/builtin1.c
new file mode 100644
index 0000000000000000000000000000000000000000..c15c06ed73cb8814e843719affcb27bf6755bdb7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/charset/builtin1.c
@@ -0,0 +1,25 @@
+/* isdigit(c) can be optimized to ((unsigned)c) - '0' <= 9, but only if
+   we know the correct value of '0'.  PR 18785.  */
+
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-inline -fexec-charset=IBM-1047" } */
+
+extern int isdigit(int);
+extern void abort(void);
+
+static int str1(void) { return '1'; }
+static int strA(void) { return 'A'; }
+
+int
+main(void)
+{
+  if (!isdigit('1'))
+    abort();
+  if (isdigit('A'))
+    abort();
+  if (!isdigit(str1()))
+    abort();
+  if (isdigit(strA()))
+    abort();
+  return 0;
+}
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index 0764fc8e4b306843ad3e147a4a74ca09ba855167..5e6ad289e3653ebbef2201e9f02873beb246c945 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,8 +1,15 @@
+2005-02-20  Zack Weinberg  <zack@codesourcery.com>
+
+	PR 18785
+	* charset.c (LAST_POSSIBLY_BASIC_SOURCE_CHAR): New helper macro.
+	(cpp_host_to_exec_charset): New function.
+	* include/cpplib.h: Declare cpp_host_to_exec_charset.
+
 2005-02-19  Devang Patel  <dpatel@apple.com>
 
 	* charset.c (_cpp_convert_input): Check '\r' before inserting
 	'\n' at the end.
-	
+
 2005-02-15  Eric Christopher  <echristo@redhat.com>
 
 	PR preprocessor/19077
@@ -41,7 +48,7 @@
 	* include/cpplib.h (c_lang): Fix comment to say cpp_create_reader.
 
 	* include/cpplib.h: Also update copyright years.
-	
+
 2005-01-03  Geoffrey Keating  <geoffk@apple.com>
 
 	* files.c (_cpp_find_file): Add files found by search_path_exhausted
@@ -64,7 +71,7 @@
 
 2004-11-28  Nathanael Nerode  <neroden@gcc.gnu.org>
 
-	PR preprocessor/17610 
+	PR preprocessor/17610
 	* directives.c (do_include_common): Error out if an empty filename
 	is given for #include (or #include_next or #import).
 
@@ -87,7 +94,7 @@
 	* configure: Regenerate.
 
 2004-11-23  Daniel Jacobowitz  <dan@codesourcery.com>
-            Joseph Myers  <joseph@codesourcery.com>
+	    Joseph Myers  <joseph@codesourcery.com>
 
 	* internal.h (struct lexer_state): Add in_deferred_pragma.
 	* directives.c (struct pragma_entry): Add allow_expansion.
@@ -100,7 +107,7 @@
 	* include/cpplib.h (cpp_register_pragma): Update prototype.
 
 2004-11-18  Daniel Jacobowitz  <dan@codesourcery.com>
-            Mark Mitchell  <mark@codesourcery.com>
+	    Mark Mitchell  <mark@codesourcery.com>
 
 	* configure.ac (i[34567]86-*-solaris2.1[0-9]*): Set
 	need_64bit_hwint=yes.
@@ -115,7 +122,7 @@
 	Remove local srcdir path from generated file.
 
 2004-11-04  Zack Weinberg  <zack@codesourcery.com>
-            Gerald Pfeifer  <gerald@pfeifer.com>
+	    Gerald Pfeifer  <gerald@pfeifer.com>
 
 	* internal.h (HAVE_ICONV): Undefine if we do not have HAVE_ICONV_H
 	as well.
diff --git a/libcpp/charset.c b/libcpp/charset.c
index 37859c52a319a632f8104518d0c8e0b927b2cdd1..6b6c360f73d5702fc0442c3fc82b67fa3fcfea11 100644
--- a/libcpp/charset.c
+++ b/libcpp/charset.c
@@ -81,8 +81,10 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #if HOST_CHARSET == HOST_CHARSET_ASCII
 #define SOURCE_CHARSET "UTF-8"
+#define LAST_POSSIBLY_BASIC_SOURCE_CHAR 0x7e
 #elif HOST_CHARSET == HOST_CHARSET_EBCDIC
 #define SOURCE_CHARSET "UTF-EBCDIC"
+#define LAST_POSSIBLY_BASIC_SOURCE_CHAR 0xFF
 #else
 #error "Unrecognized basic host character set"
 #endif
@@ -714,6 +716,63 @@ _cpp_destroy_iconv (cpp_reader *pfile)
     }
 }
 
+/* Utility routine for use by a full compiler.  C is a character taken
+   from the *basic* source character set, encoded in the host's
+   execution encoding.  Convert it to (the target's) execution
+   encoding, and return that value.
+
+   Issues an internal error if C's representation in the narrow
+   execution character set fails to be a single-byte value (C99
+   5.2.1p3: "The representation of each member of the source and
+   execution character sets shall fit in a byte.")  May also issue an
+   internal error if C fails to be a member of the basic source
+   character set (testing this exactly is too hard, especially when
+   the host character set is EBCDIC).  */
+cppchar_t
+cpp_host_to_exec_charset (cpp_reader *pfile, cppchar_t c)
+{
+  uchar sbuf[1];
+  struct _cpp_strbuf tbuf;
+
+  /* This test is merely an approximation, but it suffices to catch
+     the most important thing, which is that we don't get handed a
+     character outside the unibyte range of the host character set.  */
+  if (c > LAST_POSSIBLY_BASIC_SOURCE_CHAR)
+    {
+      cpp_error (pfile, CPP_DL_ICE,
+		 "character 0x%lx is not in the basic source character set\n",
+		 (unsigned long)c);
+      return 0;
+    }
+
+  /* Being a character in the unibyte range of the host character set,
+     we can safely splat it into a one-byte buffer and trust that that
+     is a well-formed string.  */
+  sbuf[0] = c;
+
+  /* This should never need to reallocate, but just in case... */
+  tbuf.asize = 1;
+  tbuf.text = xmalloc (tbuf.asize);
+  tbuf.len = 0;
+
+  if (!APPLY_CONVERSION (pfile->narrow_cset_desc, sbuf, 1, &tbuf))
+    {
+      cpp_errno (pfile, CPP_DL_ICE, "converting to execution character set");
+      return 0;
+    }
+  if (tbuf.len != 1)
+    {
+      cpp_error (pfile, CPP_DL_ICE,
+		 "character 0x%lx is not unibyte in execution character set",
+		 (unsigned long)c);
+      return 0;
+    }
+  c = tbuf.text[0];
+  free(tbuf.text);
+  return c;
+}
+
+
 
 /* Utility routine that computes a mask of the form 0000...111... with
    WIDTH 1-bits.  */
@@ -727,8 +786,6 @@ width_to_mask (size_t width)
     return ((size_t) 1 << width) - 1;
 }
 
-
-
 /* Returns 1 if C is valid in an identifier, 2 if C is valid except at
    the start of an identifier, and 0 if C is not valid in an
    identifier.  We assume C has already gone through the checks of
diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h
index c3814460705477b2b5e59661529caa37c6a8f060..70f8d895afdcb7faa57bc07f84b4283c1bb8a8bd 100644
--- a/libcpp/include/cpplib.h
+++ b/libcpp/include/cpplib.h
@@ -659,6 +659,9 @@ extern bool cpp_interpret_string_notranslate (cpp_reader *,
 					      const cpp_string *, size_t,
 					      cpp_string *, bool);
 
+/* Convert a host character constant to the execution character set.  */
+extern cppchar_t cpp_host_to_exec_charset (cpp_reader *, cppchar_t);
+
 /* Used to register macros and assertions, perhaps from the command line.
    The text is the same as the command line argument.  */
 extern void cpp_define (cpp_reader *, const char *);
@@ -743,12 +746,6 @@ cpp_num cpp_num_sign_extend (cpp_num, size_t);
 #define CPP_DL_WARNING_P(l)	(CPP_DL_EXTRACT (l) >= CPP_DL_WARNING \
 				 && CPP_DL_EXTRACT (l) <= CPP_DL_PEDWARN)
 
-/* N.B. The error-message-printer prototypes have not been nicely
-   formatted because exgettext needs to see 'msgid' on the same line
-   as the name of the function in order to work properly.  Only the
-   string argument gets a name in an effort to keep the lines from
-   getting ridiculously oversized.  */
-
 /* Output a diagnostic of some kind.  */
 extern void cpp_error (cpp_reader *, int, const char *msgid, ...)
   ATTRIBUTE_PRINTF_3;