The first example of C++11 section 2.14.5 paragraph 5 confuses the scanner. $ cat test.cc const char *phantom_terminator = R"a( )\ a" )a"; $ xg++ -std=c++11 -g -O2 -c test.cc test.cc:4:3: warning: missing terminating " character [enabled by default] )a"; ^ test.cc:4:1: error: missing terminating " character )a"; ^ test.cc:4:1: error: expected ',' or ';' before ')' token
Maybe Jakub can have a look.
There seems to be more issues in the raw string literal lexing. E.g. const char *s = R"a??/(x)a??/"; should be I think handled the same as const char *s = "x"; with -std=c++11 or -std=gnu++11 -trigraphs, but is not. We only revert the phase 1 and phase 2 transformations in between ( and ), but they should actually be reverted everywhere between the " after R and the final ".
Created attachment 30306 [details] gcc49-pr57620.patch So far only very lightly tested patch, passes raw-string* tests (except for raw-string-2.c which contains also trigraph tests that were valid in the earlier raw string paper, but aren't valid in C++11) and this plus a few other tests. Will still need to adjust raw-string-2.c, and add sufficient test coverage for all the corner cases.
Thanks!
Author: jakub Date: Sun Jul 21 02:28:03 2013 New Revision: 201091 URL: http://gcc.gnu.org/viewcvs?rev=201091&root=gcc&view=rev Log: PR preprocessor/57620 * lex.c (lex_raw_string): Undo phase1 and phase2 transformations between R" and final " rather than only in between R"del( and )del". * c-c++-common/raw-string-2.c (s12, u12, U12, L12): Remove. (main): Don't test {s,u,U,L}12. * c-c++-common/raw-string-13.c: New test. * c-c++-common/raw-string-14.c: New test. * c-c++-common/raw-string-15.c: New test. * c-c++-common/raw-string-16.c: New test. Added: trunk/gcc/testsuite/c-c++-common/raw-string-13.c trunk/gcc/testsuite/c-c++-common/raw-string-14.c trunk/gcc/testsuite/c-c++-common/raw-string-15.c trunk/gcc/testsuite/c-c++-common/raw-string-16.c Modified: trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/c-c++-common/raw-string-2.c trunk/libcpp/ChangeLog trunk/libcpp/lex.c
*** Bug 52852 has been marked as a duplicate of this bug. ***