public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [C++ Patch] PR 58155  -  -Wliteral-suffix warns about tokens which are skipped
@ 2014-07-07 14:20 Ed Smith-Rowland
  2014-07-08 22:41 ` Jason Merrill
  0 siblings, 1 reply; 2+ messages in thread
From: Ed Smith-Rowland @ 2014-07-07 14:20 UTC (permalink / raw)
  To: gcc-patches, Jason Merrill

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

This patch addresses an old issue of warning about macro touching string 
literal even if the code is skipped:

#define BAZ "baz"
#if 0
"bar"BAZ
#endif

Just skip the warning Wliteral-suffix if the preprocessor is skipping.

Built and tested on x86_64-linux.

OK?

And for 4.9?

Thanks,

Ed Smith-Rowland


[-- Attachment #2: CL_pr58155 --]
[-- Type: text/plain, Size: 428 bytes --]


libcpp/

2014-07-07  Edward Smith-Rowland  <3dw4rd@verizon.net>

	PR c++/58155 - -Wliteral-suffix warns about tokens which are skipped
	by preprocessor
	* lex.c (lex_raw_string ()): Do not warn about invalid suffix
	if skipping. (lex_string ()): Ditto.


gcc/testsuite/

2014-07-07  Edward Smith-Rowland  <3dw4rd@verizon.net>

	PR c++/58155 - -Wliteral-suffix warns about tokens which are skipped
	g++.dg/cpp0x/pr58155.C: New.

[-- Attachment #3: patch_pr58155 --]
[-- Type: text/plain, Size: 1280 bytes --]

Index: libcpp/lex.c
===================================================================
--- libcpp/lex.c	(revision 212209)
+++ libcpp/lex.c	(working copy)
@@ -1646,7 +1646,7 @@
       if (is_macro (pfile, cur))
 	{
 	  /* Raise a warning, but do not consume subsequent tokens.  */
-	  if (CPP_OPTION (pfile, warn_literal_suffix))
+	  if (CPP_OPTION (pfile, warn_literal_suffix) && !pfile->state.skipping)
 	    cpp_warning_with_line (pfile, CPP_W_LITERAL_SUFFIX,
 				   token->src_loc, 0,
 				   "invalid suffix on literal; C++11 requires "
@@ -1775,7 +1775,7 @@
       if (is_macro (pfile, cur))
 	{
 	  /* Raise a warning, but do not consume subsequent tokens.  */
-	  if (CPP_OPTION (pfile, warn_literal_suffix))
+	  if (CPP_OPTION (pfile, warn_literal_suffix) && !pfile->state.skipping)
 	    cpp_warning_with_line (pfile, CPP_W_LITERAL_SUFFIX,
 				   token->src_loc, 0,
 				   "invalid suffix on literal; C++11 requires "
Index: gcc/testsuite/g++.dg/cpp0x/pr58155.C
===================================================================
--- gcc/testsuite/g++.dg/cpp0x/pr58155.C	(revision 0)
+++ gcc/testsuite/g++.dg/cpp0x/pr58155.C	(revision 0)
@@ -0,0 +1,13 @@
+// { dg-do compile { target c++11 } }
+
+#define BAZ "baz"
+
+#if 0
+
+"bar"BAZ
+
+R"(
+  bar
+)"BAZ
+
+#endif

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

* Re: [C++ Patch] PR 58155  -  -Wliteral-suffix warns about tokens which are skipped
  2014-07-07 14:20 [C++ Patch] PR 58155 - -Wliteral-suffix warns about tokens which are skipped Ed Smith-Rowland
@ 2014-07-08 22:41 ` Jason Merrill
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2014-07-08 22:41 UTC (permalink / raw)
  To: Ed Smith-Rowland, gcc-patches

On 07/07/2014 07:20 AM, Ed Smith-Rowland wrote:
> OK?
>
> And for 4.9?

Yes.

Jason


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

end of thread, other threads:[~2014-07-08 22:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-07 14:20 [C++ Patch] PR 58155 - -Wliteral-suffix warns about tokens which are skipped Ed Smith-Rowland
2014-07-08 22:41 ` 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).