]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR preprocessor/48740 (Raw C++0x strings and trigraphs mix badly)
authorJakub Jelinek <jakub@redhat.com>
Tue, 26 Apr 2011 10:04:18 +0000 (12:04 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 26 Apr 2011 10:04:18 +0000 (12:04 +0200)
2011-04-26  Jakub Jelinek  <jakub@redhat.com>

Backported from mainline
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 ??].

* c-c++-common/raw-string-11.c: New test.

From-SVN: r172956

gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/raw-string-11.c [new file with mode: 0644]
libcpp/ChangeLog
libcpp/lex.c

index 133776ef7305e5b83991a833b53533f6a9868d0f..523b0dcb869a942ddc534d509e65b62d2f8cc890 100644 (file)
@@ -1,3 +1,11 @@
+2011-04-26  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       2011-04-24  Jakub Jelinek  <jakub@redhat.com>
+
+       PR preprocessor/48740
+       * c-c++-common/raw-string-11.c: New test.
+
 2011-04-20  Jason Merrill  <jason@redhat.com>
 
        * 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 (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 703300db59686efd31bcc71c3b43325dead72bf1..fdf128c8ae2a53fbf2a05d51cbe57c2cfea59a03 100644 (file)
@@ -1,3 +1,13 @@
+2011-04-26  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       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-03-21  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
        PR preprocessor/48192
index f29998225340954e0affb7f59da3c1d66ea51bd9..7e0e50e910af82747ae00d98ac451f0c3a1d51b3 100644 (file)
@@ -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