On Wed, Aug 31, 2022 at 05:07:29PM +0200, Jakub Jelinek via Gcc-patches wrote: > Given what you said above, I think that is what we want for the last 2 > for C++23, the question is if it is ok also for C++20/C17 etc. and whether > it should depend on -pedantic or -pedantic-errors or GNU vs. ISO mode > or not in that case. We could handle those 2 also differently, just > warn instead of error for the \N{ABC} case if not in C++23 mode when > identifier_pos.
Here is an incremental version of the patch which will make valid \u{123} and \N{LATIN SMALL LETTER A WITH ACUTE} an extension in GNU modes before C++23 and split it as separate tokens in ISO modes. Testcase: #define z(x) 0 #define a z( int b = a\u{123}); int c = a\N{LATIN SMALL LETTER A WITH ACUTE}); --- libcpp/charset.cc.jj 2022-08-31 16:50:48.862775486 +0200 +++ libcpp/charset.cc 2022-08-31 17:18:59.649257350 +0200 @@ -1448,7 +1448,11 @@ _cpp_valid_ucn (cpp_reader *pfile, const if (str[-1] == 'u') { length = 4; - if (str < limit && *str == '{') + if (str < limit + && *str == '{' + && (!identifier_pos + || CPP_OPTION (pfile, delimited_escape_seqs) + || !CPP_OPTION (pfile, std))) { str++; /* Magic value to indicate no digits seen. */ @@ -1462,6 +1466,13 @@ _cpp_valid_ucn (cpp_reader *pfile, const else if (str[-1] == 'N') { length = 4; + if (identifier_pos + && !CPP_OPTION (pfile, delimited_escape_seqs) + && CPP_OPTION (pfile, std)) + { + *cp = 0; + return false; + } if (str == limit || *str != '{') { if (identifier_pos) Jakub