[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
This commit is contained in:
parent
eb484969f6
commit
35b82d26e5
4 changed files with 30 additions and 3 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue