public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* libcpp PATCH for c++/45399 (undesired NUL warning in raw strings)
@ 2011-06-16 22:02 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2011-06-16 22:02 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 176 bytes --]

People want to use raw strings for embedding binary data in source 
files, so we don't want to complain about \0 in the middle.

Tested x86_64-pc-linux-gnu, applying to trunk.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 45399.patch --]
[-- Type: text/x-patch; name="45399.patch", Size: 1625 bytes --]

commit 35ebd948dd567743ed6b31deb063b5ef948304a9
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Jun 15 14:16:43 2011 -0400

    	PR c++/45399
    	* lex.c (lex_raw_string): Don't check for embedded NUL.

diff --git a/gcc/testsuite/c-c++-common/raw-string-12.c b/gcc/testsuite/c-c++-common/raw-string-12.c
new file mode 100644
index 0000000..5bdf3b9
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/raw-string-12.c
@@ -0,0 +1,5 @@
+// PR c++/45399
+// { dg-options "-std=gnu99" { target c } }
+// { dg-options "-std=c++0x" { target c++ } }
+
+char const *S = R"raw(\0)raw";
diff --git a/libcpp/lex.c b/libcpp/lex.c
index 6c3be71..d29f36d 100644
--- a/libcpp/lex.c
+++ b/libcpp/lex.c
@@ -1270,7 +1270,6 @@ static void
 lex_raw_string (cpp_reader *pfile, cpp_token *token, const uchar *base,
 		const uchar *cur)
 {
-  source_location saw_NUL = 0;
   const uchar *raw_prefix;
   unsigned int raw_prefix_len = 0;
   enum cpp_ttype type;
@@ -1476,16 +1475,9 @@ lex_raw_string (cpp_reader *pfile, cpp_token *token, const uchar *base,
 	  cur = base = pfile->buffer->cur;
 	  note = &pfile->buffer->notes[pfile->buffer->cur_note];
 	}
-      else if (c == '\0' && !saw_NUL)
-	LINEMAP_POSITION_FOR_COLUMN (saw_NUL, pfile->line_table,
-				     CPP_BUF_COLUMN (pfile->buffer, cur));
     }
  break_outer_loop:
 
-  if (saw_NUL && !pfile->state.skipping)
-    cpp_error_with_line (pfile, CPP_DL_WARNING, saw_NUL, 0,
-	       "null character(s) preserved in literal");
-
   pfile->buffer->cur = cur;
   if (first_buff == NULL)
     create_literal (pfile, token, base, cur - base, type);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-06-16 22:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-16 22:02 libcpp PATCH for c++/45399 (undesired NUL warning in raw strings) Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).