re PR c++/80955 (Macros expanded in definition of user-defined literals)

/libcpp
2017-11-06  Mukesh Kapoor  <mukesh.kapoor@oracle.com>

	PR c++/80955
	* lex.c (lex_string): When checking for a valid macro for the
	warning related to -Wliteral-suffix (CPP_W_LITERAL_SUFFIX),
	check that the macro name does not start with an underscore
	before calling is_macro().

/gcc/testsuite
2017-11-06  Mukesh Kapoor  <mukesh.kapoor@oracle.com>

	PR c++/80955
	* g++.dg/cpp0x/udlit-macros.C: New.

From-SVN: r254443
This commit is contained in:
Mukesh Kapoor
2017-11-06 10:33:41 +00:00
committed by Paolo Carlini
parent 16f681db11
commit 7d19c460ed
4 changed files with 50 additions and 4 deletions
+8
View File
@@ -1,3 +1,11 @@
2017-11-06 Mukesh Kapoor <mukesh.kapoor@oracle.com>
PR c++/80955
* lex.c (lex_string): When checking for a valid macro for the
warning related to -Wliteral-suffix (CPP_W_LITERAL_SUFFIX),
check that the macro name does not start with an underscore
before calling is_macro().
2017-11-05 Tom de Vries <tom@codesourcery.com>
PR other/82784
+6 -4
View File
@@ -1871,8 +1871,9 @@ lex_raw_string (cpp_reader *pfile, cpp_token *token, const uchar *base,
/* If a string format macro, say from inttypes.h, is placed touching
a string literal it could be parsed as a C++11 user-defined string
literal thus breaking the program.
Try to identify macros with is_macro. A warning is issued. */
if (is_macro (pfile, cur))
Try to identify macros with is_macro. A warning is issued.
The macro name should not start with '_' for this warning. */
if ((*cur != '_') && is_macro (pfile, cur))
{
/* Raise a warning, but do not consume subsequent tokens. */
if (CPP_OPTION (pfile, warn_literal_suffix) && !pfile->state.skipping)
@@ -2001,8 +2002,9 @@ lex_string (cpp_reader *pfile, cpp_token *token, const uchar *base)
/* If a string format macro, say from inttypes.h, is placed touching
a string literal it could be parsed as a C++11 user-defined string
literal thus breaking the program.
Try to identify macros with is_macro. A warning is issued. */
if (is_macro (pfile, cur))
Try to identify macros with is_macro. A warning is issued.
The macro name should not start with '_' for this warning. */
if ((*cur != '_') && is_macro (pfile, cur))
{
/* Raise a warning, but do not consume subsequent tokens. */
if (CPP_OPTION (pfile, warn_literal_suffix) && !pfile->state.skipping)