]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR preprocessor/48740 (Raw C++0x strings and trigraphs mix badly)
authorJakub Jelinek <jakub@redhat.com>
Sat, 23 Apr 2011 23:32:09 +0000 (01:32 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sat, 23 Apr 2011 23:32:09 +0000 (01:32 +0200)
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
gcc/testsuite/c-c++-common/raw-string-11.c [new file with mode: 0644]
libcpp/ChangeLog
libcpp/lex.c

index 2cf73c70cfe1cc0ecc17425e0e7d44ed62f73ecc..0ec9b20126ae50569c101060d416687d110233f0 100644 (file)
@@ -1,3 +1,8 @@
+2011-04-24  Jakub Jelinek  <jakub@redhat.com>
+
+       PR preprocessor/48740
+       * c-c++-common/raw-string-11.c: New test.
+
 2011-04-23  John David Anglin  <dave.anglin@nrc-cnrc.ca>
 
        * 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 (file)
index 0000000..49ceba2
--- /dev/null
@@ -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 } }
index eb93719e27bee67ecc8a1e14b77a885d6397b613..26013027b691ccc66a8d0b1b49d7f00776eb5602 100644 (file)
@@ -1,3 +1,10 @@
+2011-04-24  Jakub Jelinek  <jakub@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 ??].
+
 2011-04-20  Jim Meyering  <meyering@redhat.com>
 
        * files.c (destroy_cpp_file): Remove useless if-before-free.
index c9b5c95df6a55e32567e59a6c1f452dc3b064c72..3bf4886b6d28c273be03fde83b1384ab67fe4e5a 100644 (file)
@@ -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