aboutsummaryrefslogtreecommitdiff
path: root/libcpp/macro.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2017-10-10 18:56:31 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2017-10-10 18:56:31 +0000
commit35b82d26e5b92ba0471f59f0073590de3550f00a (patch)
tree4fc1cc6080449593ca09e8bd58284591bc52f03a /libcpp/macro.c
parenteb484969f654680683aa2a419929029c2903d0b7 (diff)
downloadgcc-35b82d26e5b92ba0471f59f0073590de3550f00a.zip
gcc-35b82d26e5b92ba0471f59f0073590de3550f00a.tar.gz
gcc-35b82d26e5b92ba0471f59f0073590de3550f00a.tar.bz2
[PATCH] preprocessor stringizing raw strings
https://gcc.gnu.org/ml/gcc-patches/2017-10/msg00611.html libcpp/ PR preprocessor/82506 * macro.c (cpp_quote_string): Escape raw LFs. gcc/testsuite/ PR preprocessor/82506 * g++.dg/cpp/string-3.C: New. From-SVN: r253605
Diffstat (limited to 'libcpp/macro.c')
-rw-r--r--libcpp/macro.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/libcpp/macro.c b/libcpp/macro.c
index de18c22..fab1cb0 100644
--- a/libcpp/macro.c
+++ b/libcpp/macro.c
@@ -502,13 +502,21 @@ cpp_quote_string (uchar *dest, const uchar *src, unsigned int len)
{
uchar c = *src++;
- if (c == '\\' || c == '"')
+ switch (c)
{
+ case '\n':
+ /* Naked LF can appear in raw string literals */
+ c = 'n';
+ /* FALLTHROUGH */
+
+ case '\\':
+ case '"':
*dest++ = '\\';
+ /* FALLTHROUGH */
+
+ default:
*dest++ = c;
}
- else
- *dest++ = c;
}
return dest;