[Bug c++/80955] Macros expanded in definition of user-defined literals
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80955 --- Comment #8 from Jonathan Wakely --- Also the new testcase for this bug has undefined behaviour. _ID is a reserved name so the program cannot use it to define a macro or a UDL.
[Bug c++/80955] Macros expanded in definition of user-defined literals
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80955 --- Comment #7 from Jonathan Wakely --- Moved to PR 84517
[Bug c++/80955] Macros expanded in definition of user-defined literals
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80955 --- Comment #6 from Jonathan Wakely --- Testing this: --- a/libcpp/lex.c +++ b/libcpp/lex.c @@ -1903,7 +1903,7 @@ lex_raw_string (cpp_reader *pfile, cpp_token *token, const uchar *base, literal thus breaking the program. 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)) + if ((*cur != '_' || cur[1] == '_') && is_macro (pfile, cur)) { /* Raise a warning, but do not consume subsequent tokens. */ if (CPP_OPTION (pfile, warn_literal_suffix) && !pfile->state.skipping) @@ -2034,7 +2034,7 @@ lex_string (cpp_reader *pfile, cpp_token *token, const uchar *base) literal thus breaking the program. 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)) + if ((*cur != '_' || cur[1] == '_') && is_macro (pfile, cur)) { /* Raise a warning, but do not consume subsequent tokens. */ if (CPP_OPTION (pfile, warn_literal_suffix) && !pfile->state.skipping)
[Bug c++/80955] Macros expanded in definition of user-defined literals
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80955 --- Comment #5 from Jonathan Wakely --- Is there a way to check if it's a pre-defined macro? Or just change the condition to allow starting with two underscores, but not allow starting with one (since user-defined UDLs must start with a single underscore, and must not start with two).
[Bug c++/80955] Macros expanded in definition of user-defined literals
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80955 --- Comment #4 from Jonathan Wakely --- This causes a regression for: const char* err() { return "Error in "__FILE__; } file.cc: In function ‘const char* err()’: file.cc:1:28: error: unable to find string literal operator ‘operator""__FILE__’ with ‘const char [10]’, ‘long unsigned int’ arguments const char* err() { return "Error in "__FILE__; } ^~~ With GCC 7 this gave a warning about not finding a literal operator, and then continued as the author intended, i.e. concatenating the two strings.
[Bug c++/80955] Macros expanded in definition of user-defined literals
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80955 Paolo Carlini changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED Target Milestone|--- |8.0 --- Comment #3 from Paolo Carlini --- Fixed.
[Bug c++/80955] Macros expanded in definition of user-defined literals
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80955 --- Comment #2 from paolo at gcc dot gnu.org --- Author: paolo Date: Mon Nov 6 10:33:41 2017 New Revision: 254443 URL: https://gcc.gnu.org/viewcvs?rev=254443=gcc=rev Log: /libcpp 2017-11-06 Mukesh KapoorPR 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 PR c++/80955 * g++.dg/cpp0x/udlit-macros.C: New. Added: trunk/gcc/testsuite/g++.dg/cpp0x/udlit-macros.C Modified: trunk/gcc/testsuite/ChangeLog trunk/libcpp/ChangeLog trunk/libcpp/lex.c
[Bug c++/80955] Macros expanded in definition of user-defined literals
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80955 Mukesh Kapoor changed: What|Removed |Added CC||mukesh.kapoor at oracle dot com --- Comment #1 from Mukesh Kapoor --- Incorrect parsing of string. I am working on this.
[Bug c++/80955] Macros expanded in definition of user-defined literals
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80955 Jonathan Wakely changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2017-06-02 Ever confirmed|0 |1