From 6cfae07011d50127089bc1ae02837f924cefccb2 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Sun, 24 Apr 2011 01:32:09 +0200 Subject: [PATCH] re PR preprocessor/48740 (Raw C++0x strings and trigraphs mix badly) PR preprocessor/48740 * lex.c (lex_raw_string): When raw string ends with ??) followed by raw prefix and ", ensure it is preprocessed with ??) rather than ??]. * c-c++-common/raw-string-11.c: New test. From-SVN: r172903 --- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/c-c++-common/raw-string-11.c | 13 +++++++++++++ libcpp/ChangeLog | 7 +++++++ libcpp/lex.c | 4 +++- 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/c-c++-common/raw-string-11.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2cf73c70cfe..0ec9b20126a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-04-24 Jakub Jelinek + + PR preprocessor/48740 + * c-c++-common/raw-string-11.c: New test. + 2011-04-23 John David Anglin * gcc.dg/pr48616.c (dg-options): Add -fno-common to options on diff --git a/gcc/testsuite/c-c++-common/raw-string-11.c b/gcc/testsuite/c-c++-common/raw-string-11.c new file mode 100644 index 00000000000..49ceba225b3 --- /dev/null +++ b/gcc/testsuite/c-c++-common/raw-string-11.c @@ -0,0 +1,13 @@ +// PR preprocessor/48740 +// { dg-options "-std=gnu99 -trigraphs -save-temps" { target c } } +// { dg-options "-std=c++0x -save-temps" { target c++ } } +// { dg-do run } + +int main () +{ + return __builtin_memcmp (R"raw(foo%sbar%sfred%sbob?????)raw", + "foo%sbar%sfred%sbob?""?""?""?""?", + sizeof ("foo%sbar%sfred%sbob?""?""?""?""?")); +} + +// { dg-final { cleanup-saved-temps } } diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index eb93719e27b..26013027b69 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,10 @@ +2011-04-24 Jakub Jelinek + + PR preprocessor/48740 + * lex.c (lex_raw_string): When raw string ends with + ??) followed by raw prefix and ", ensure it is preprocessed + with ??) rather than ??]. + 2011-04-20 Jim Meyering * files.c (destroy_cpp_file): Remove useless if-before-free. diff --git a/libcpp/lex.c b/libcpp/lex.c index c9b5c95df6a..3bf4886b6d2 100644 --- a/libcpp/lex.c +++ b/libcpp/lex.c @@ -1410,7 +1410,9 @@ lex_raw_string (cpp_reader *pfile, cpp_token *token, const uchar *base, raw_prefix_len) == 0 && cur[raw_prefix_len+1] == '"') { - cur += raw_prefix_len+2; + BUF_APPEND (")", 1); + base++; + cur += raw_prefix_len + 2; goto break_outer_loop; } else -- 2.30.2