From f6ca886d3202a08881ddfb207491ded8ed90c85e Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 26 Apr 2011 12:04:18 +0200 Subject: [PATCH] backport: re PR preprocessor/48740 (Raw C++0x strings and trigraphs mix badly) 2011-04-26 Jakub Jelinek Backported from mainline 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 ??]. * c-c++-common/raw-string-11.c: New test. From-SVN: r172956 --- gcc/testsuite/ChangeLog | 8 ++++++++ gcc/testsuite/c-c++-common/raw-string-11.c | 13 +++++++++++++ libcpp/ChangeLog | 10 ++++++++++ libcpp/lex.c | 4 +++- 4 files changed, 34 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 133776ef7305..523b0dcb869a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2011-04-26 Jakub Jelinek + + Backported from mainline + 2011-04-24 Jakub Jelinek + + PR preprocessor/48740 + * c-c++-common/raw-string-11.c: New test. + 2011-04-20 Jason Merrill * g++.dg/template/operator11.C: New. 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 000000000000..49ceba225b31 --- /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 703300db5968..fdf128c8ae2a 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,13 @@ +2011-04-26 Jakub Jelinek + + Backported from mainline + 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-03-21 Michael Meissner PR preprocessor/48192 diff --git a/libcpp/lex.c b/libcpp/lex.c index f29998225340..7e0e50e910af 100644 --- a/libcpp/lex.c +++ b/libcpp/lex.c @@ -858,7 +858,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.47.2