diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-11-06 10:33:41 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-11-06 10:33:41 +0000 |
commit | 3f6f41de8877187c0ea9a42953bc7a8b8082df50 (patch) | |
tree | 4ef2defce67d2862f4fcf5611615d618f5d1f6ec /libcpp | |
parent | baf9f855777713dca68b336d374c8eae9a01804c (diff) |
/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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@254443 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libcpp')
-rw-r--r-- | libcpp/ChangeLog | 8 | ||||
-rw-r--r-- | libcpp/lex.c | 10 |
2 files changed, 14 insertions, 4 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index 285f4143d5f6..86c42affdedc 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -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 diff --git a/libcpp/lex.c b/libcpp/lex.c index 9164a0745b21..8af09e502955 100644 --- a/libcpp/lex.c +++ b/libcpp/lex.c @@ -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) |