#define S(s) s const char x[] = R"( abc )"; const char y[] = S(R"( abc )"); void bar (); void foo () { #pragma omp parallel num_threads(sizeof R"( abc )") bar (); } isn't lexed properly.
Created attachment 30459 [details] gcc49-pr57824.patch Untested fix. Seems to work on these testcases without -save-temps, with -save-temps the line numbers in -lineno dumps are off unfortunately, so some further work is needed. Tom, any ideas?
Author: jakub Date: Wed Jul 10 16:52:19 2013 New Revision: 200879 URL: http://gcc.gnu.org/viewcvs?rev=200879&root=gcc&view=rev Log: PR preprocessor/57824 * lex.c (lex_raw_string): Allow reading new-lines if in_deferred_pragma or if parsing_args and there is still data in the current buffer. * c-c++-common/raw-string-17.c: New test. * c-c++-common/gomp/pr57824.c: New test. Added: trunk/gcc/testsuite/c-c++-common/gomp/pr57824.c trunk/gcc/testsuite/c-c++-common/raw-string-17.c Modified: trunk/gcc/testsuite/ChangeLog trunk/libcpp/ChangeLog trunk/libcpp/lex.c Fixed for 4.9+.
*** Bug 52852 has been marked as a duplicate of this bug. ***
Raw string literals are still not handled correctly in macros in some cases: #define myMacro(string) u##string int square(int num) { auto string = myMacro(R"EOF( )EOF"); // intentional syntax error return num * num } (https://godbolt.org/z/qYfax5E8x) The line number in the compiler error message refers to a line that doesn't even exist. It seems like line breaks in the raw string literal are counted twice.