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
libcpp/
2014-07-07 Edward Smith-Rowland <3dw...@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 <3dw...@verizon.net>
PR c++/58155 - -Wliteral-suffix warns about tokens which are skipped
g++.dg/cpp0x/pr58155.C: New.
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