This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH COMMITTED: Fix stringification of wide characters


There is a thinko in
    http://gcc.gnu.org/ml/gcc-patches/2008-04/msg01235.html
This patch to libcpp/macro.c:

-      escape_it = (token->type == CPP_STRING || token->type == CPP_WSTRING
-		   || token->type == CPP_CHAR || token->type == CPP_WCHAR);
+      escape_it = (token->type == CPP_STRING || token->type == CPP_CHAR
+		   || token->type == CPP_WSTRING || token->type == CPP_STRING
+		   || token->type == CPP_STRING32 || token->type == CPP_CHAR32
+		   || token->type == CPP_STRING16 || token->type == CPP_CHAR16);

duplicates CPP_STRING and drops CPP_WCHAR.  This causes stringification
of wide characters to fail.

This patch fixes it and includes a test case.  Bootstrapped and tested
on x86_64-unknown-linux-gnu.  Committed as obvious.

Ian


libcpp/ChangeLog:

2009-09-02  Ian Lance Taylor  <iant@google.com>

	* macro.c (stringify_arg): Escape CPP_WCHAR tokens.

gcc/testsuite/ChangeLog:

2009-09-02  Ian Lance Taylor  <iant@google.com>

	* gcc.dg/20090902-1.c: New test.


Index: libcpp/macro.c
===================================================================
--- libcpp/macro.c	(revision 151339)
+++ libcpp/macro.c	(working copy)
@@ -377,7 +377,7 @@ stringify_arg (cpp_reader *pfile, macro_
 	}
 
       escape_it = (token->type == CPP_STRING || token->type == CPP_CHAR
-		   || token->type == CPP_WSTRING || token->type == CPP_STRING
+		   || token->type == CPP_WSTRING || token->type == CPP_WCHAR
 		   || token->type == CPP_STRING32 || token->type == CPP_CHAR32
 		   || token->type == CPP_STRING16 || token->type == CPP_CHAR16);
 
Index: gcc/testsuite/gcc.dg/20090902-1.c
===================================================================
--- gcc/testsuite/gcc.dg/20090902-1.c	(revision 0)
+++ gcc/testsuite/gcc.dg/20090902-1.c	(revision 0)
@@ -0,0 +1,3 @@
+/* { dg-do compile } */
+#define STRING(x) #x
+char buf[] = STRING(L'\x123');

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]