public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libcpp: Fix up raw string literal parsing error-recovery [PR96323]
@ 2020-07-28  8:26 Jakub Jelinek
  2020-07-28 12:22 ` Nathan Sidwell
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2020-07-28  8:26 UTC (permalink / raw)
  To: Nathan Sidwell; +Cc: gcc-patches

Hi!

For (invalid) newline inside of the raw string literal delimiter, doing
continue means we skip the needed processing of newlines.  Instead of
duplicating that, this patch just doesn't continue for those.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2020-07-28  Jakub Jelinek  <jakub@redhat.com>

	PR preprocessor/96323
	* lex.c (lex_raw_string): For c == '\n' don't continue after reporting
	an prefix delimiter error.

	* c-c++-common/cpp/pr96323.c: New test.

--- libcpp/lex.c.jj	2020-05-20 10:33:37.000000000 +0200
+++ libcpp/lex.c	2020-07-27 09:12:19.827974203 +0200
@@ -1885,7 +1885,8 @@ lex_raw_string (cpp_reader *pfile, cpp_t
 		 the best failure mode.  */
 	      prefix_len = 0;
 	    }
-	  continue;
+	  if (c != '\n')
+	    continue;
 	}
 
       if (phase != PHASE_NONE)
--- gcc/testsuite/c-c++-common/cpp/pr96323.c.jj	2020-07-27 09:19:42.021557709 +0200
+++ gcc/testsuite/c-c++-common/cpp/pr96323.c	2020-07-27 09:30:37.197052063 +0200
@@ -0,0 +1,8 @@
+/* PR preprocessor/96323 */
+/* { dg-do preprocess } */
+/* { dg-options "-std=gnu99 -Wno-c++-compat -trigraphs" { target c } } */
+/* { dg-options "-std=c++0x" { target c++ } } */
+/* { dg-error "invalid new-line in raw string delimiter" "" { target *-*-* } .+2 } */
+/* { dg-warning "missing terminating . character" "" { target *-*-* } .+2 } */
+const char tu[] = R"a";
+const char tua[] = "(R)a";

	Jakub


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] libcpp: Fix up raw string literal parsing error-recovery [PR96323]
  2020-07-28  8:26 [PATCH] libcpp: Fix up raw string literal parsing error-recovery [PR96323] Jakub Jelinek
@ 2020-07-28 12:22 ` Nathan Sidwell
  0 siblings, 0 replies; 2+ messages in thread
From: Nathan Sidwell @ 2020-07-28 12:22 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

On 7/28/20 4:26 AM, Jakub Jelinek wrote:
> Hi!
> 
> For (invalid) newline inside of the raw string literal delimiter, doing
> continue means we skip the needed processing of newlines.  Instead of
> duplicating that, this patch just doesn't continue for those.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>

ok, thanks!  It's hard to think of all the wrong ways code can be written!

nathan

-- 
Nathan Sidwell

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-28 12:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-28  8:26 [PATCH] libcpp: Fix up raw string literal parsing error-recovery [PR96323] Jakub Jelinek
2020-07-28 12:22 ` Nathan Sidwell

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).