diff options
author | Edward Smith-Rowland <3dw4rd@verizon.net> | 2014-05-21 00:35:29 +0000 |
---|---|---|
committer | Edward Smith-Rowland <emsr@gcc.gnu.org> | 2014-05-21 00:35:29 +0000 |
commit | 49039169f30099ed84696aadd872653b03ecfde3 (patch) | |
tree | a86ac06d461f5c244039fdc4fc80a89810ffe1a3 | |
parent | 956dd0932cef3c45b49405d3c64c46fc67da12c2 (diff) | |
download | gcc-49039169f30099ed84696aadd872653b03ecfde3.zip gcc-49039169f30099ed84696aadd872653b03ecfde3.tar.gz gcc-49039169f30099ed84696aadd872653b03ecfde3.tar.bz2 |
re PR c++/61038 (g++ -E is unusable with UDL strings)
gcc/testsuite/
2014-05-20 Edward Smith-Rowland <3dw4rd@verizon.net>
PR C++/61038
* g++.dg/cpp0x/pr61038.C: New.
libcpp/
2014-05-20 Edward Smith-Rowland <3dw4rd@verizon.net>
PR C++/61038
* macro.c (stringify_arg (cpp_reader *, macro_arg *)):
Check for user-defined literal strings and user-defined literal chars
to escape necessary characters.
From-SVN: r210666
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/pr61038.C | 40 | ||||
-rw-r--r-- | libcpp/ChangeLog | 7 | ||||
-rw-r--r-- | libcpp/macro.c | 3 |
4 files changed, 55 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 121cc19..142c9fa 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-05-20 Edward Smith-Rowland <3dw4rd@verizon.net> + + PR C++/61038 + * g++.dg/cpp0x/pr61038.C: New. + 2014-05-20 Paolo Carlini <paolo.carlini@oracle.com> PR c++/58753 diff --git a/gcc/testsuite/g++.dg/cpp0x/pr61038.C b/gcc/testsuite/g++.dg/cpp0x/pr61038.C new file mode 100644 index 0000000..b773000 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr61038.C @@ -0,0 +1,40 @@ +// PR c++/61038 +// { dg-do compile { target c++11 } } + +#include <cstring> +#include <cstdlib> + +void +operator "" _s(const char *, unsigned long) +{ } + +void +operator "" _t(const char) +{ } + +#define QUOTE(s) #s +#define QQUOTE(s) QUOTE(s) + +int +main() +{ + const char *s = QQUOTE(QUOTE("hello"_s)); + const char *t = QUOTE("\"hello\"_s"); + if (strcmp(s, t) != 0) + abort(); + + const char *c = QQUOTE(QUOTE('"'_t)); + const char *d = QUOTE("'\"'_t"); + if (strcmp(c, d) != 0) + abort(); + + const char *e = QQUOTE(QUOTE('\''_t)); + const char *f = QUOTE("'\\''_t"); + if (strcmp(e, f) != 0) + abort(); + + const char *g = QQUOTE(QUOTE('\\'_t)); + const char *h = QUOTE("'\\\\'_t"); + if (strcmp(g, h) != 0) + abort(); +} diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index e767aa5..bb44d3c 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,10 @@ +2014-05-20 Edward Smith-Rowland <3dw4rd@verizon.net> + + PR C++/61038 + * macro.c (stringify_arg (cpp_reader *, macro_arg *)): + Check for user-defined literal strings and user-defined literal chars + to escape necessary characters. + 2014-05-20 Richard Biener <rguenther@suse.de> * configure.ac: Copy gcc logic of detecting a 64bit type. diff --git a/libcpp/macro.c b/libcpp/macro.c index 11e50f4..c3db9a2 100644 --- a/libcpp/macro.c +++ b/libcpp/macro.c @@ -494,6 +494,9 @@ stringify_arg (cpp_reader *pfile, macro_arg *arg) || token->type == CPP_STRING16 || token->type == CPP_CHAR16 || token->type == CPP_UTF8STRING); + escape_it = escape_it || cpp_userdef_string_p (token->type) + || cpp_userdef_char_p (token->type); + /* Room for each char being written in octal, initial space and final quote and NUL. */ len = cpp_token_len (token); |