Hi!

The attached testcase fails when using -save-temps, -E
prints the string as
R"raw(foo%sbar%sfred%sbob?????]raw"
instead of
R"raw(foo%sbar%sfred%sbob?????)raw"
because ??) is ] trigraph.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
ok for trunk/4.6?

2011-04-23  Jakub Jelinek  <ja...@redhat.com>

        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.

--- libcpp/lex.c.jj     2011-03-19 16:20:30.000000000 +0100
+++ libcpp/lex.c        2011-04-23 14:22:53.000000000 +0200
@@ -1410,7 +1410,9 @@ lex_raw_string (cpp_reader *pfile, cpp_t
                                       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
--- gcc/testsuite/c-c++-common/raw-string-11.c.jj       2011-04-23 
14:24:08.000000000 +0200
+++ gcc/testsuite/c-c++-common/raw-string-11.c  2011-04-23 14:28:02.000000000 
+0200
@@ -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 } }

        Jakub

Reply via email to