From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2153) id E64F23858D28; Wed, 1 Dec 2021 09:22:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E64F23858D28 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Jakub Jelinek To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-5653] libcpp: Enable P1949R7 for C++98 too [PR100977] X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/master X-Git-Oldrev: 35f2c098c81118020b1d288cd739108c8747a520 X-Git-Newrev: c264208e161830a5642ee3125871c23110508462 Message-Id: <20211201092225.E64F23858D28@sourceware.org> Date: Wed, 1 Dec 2021 09:22:25 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Dec 2021 09:22:26 -0000 https://gcc.gnu.org/g:c264208e161830a5642ee3125871c23110508462 commit r12-5653-gc264208e161830a5642ee3125871c23110508462 Author: Jakub Jelinek Date: Wed Dec 1 10:21:20 2021 +0100 libcpp: Enable P1949R7 for C++98 too [PR100977] On Mon, Nov 29, 2021 at 05:53:58PM -0500, Jason Merrill wrote: > I'm inclined to go ahead and change C++98 as well; I doubt anyone is relying > on the particular C++98 extended character set rules, and we already accept > the union of the different sets when not pedantic. Ok, here is an incremental patch to do that also for -std={c,gnu}++98. 2021-12-01 Jakub Jelinek PR c++/100977 * init.c (struct lang_flags): Remove cxx23_identifiers. (lang_defaults): Remove cxx23_identifiers initializers. (cpp_set_lang): Don't copy cxx23_identifiers. * include/cpplib.h (struct cpp_options): Adjust comment about c11_identifiers. Remove cxx23_identifiers field. * lex.c (warn_about_normalization): Use cplusplus instead of cxx23_identifiers. * charset.c (ucn_valid_in_identifier): Likewise. * g++.dg/cpp/ucnid-1.C: Adjust expected diagnostics. * g++.dg/cpp/ucnid-1-utf8.C: Likewise. Diff: --- gcc/testsuite/g++.dg/cpp/ucnid-1-utf8.C | 16 +++++----- gcc/testsuite/g++.dg/cpp/ucnid-1.C | 16 +++++----- libcpp/charset.c | 6 ++-- libcpp/include/cpplib.h | 6 +--- libcpp/init.c | 52 ++++++++++++++++----------------- libcpp/lex.c | 2 +- 6 files changed, 45 insertions(+), 53 deletions(-) diff --git a/gcc/testsuite/g++.dg/cpp/ucnid-1-utf8.C b/gcc/testsuite/g++.dg/cpp/ucnid-1-utf8.C index 839b1881bf4..01172c853c4 100644 --- a/gcc/testsuite/g++.dg/cpp/ucnid-1-utf8.C +++ b/gcc/testsuite/g++.dg/cpp/ucnid-1-utf8.C @@ -1,17 +1,17 @@ /* { dg-do preprocess } */ /* { dg-options "-std=gnu++98 -pedantic" } */ -ª /* { dg-error "not valid in an identifier" } */ +ª « /* { dg-error "not valid in an identifier" } */ ¶ /* { dg-error "not valid in an identifier" } */ -º /* { dg-error "not valid in an identifier" } */ +º À Ö -΄ +΄ /* { dg-error "not valid in an identifier" } */ -٩ /* { dg-error "not valid in an identifier" } */ -A٩ /* { dg-error "not valid in an identifier" } */ -0º /* { dg-error "not valid in an identifier" } */ -0٩ /* { dg-error "not valid in an identifier" } */ -๙ +٩ /* { dg-error "not valid at the start of an identifier" } */ +A٩ +0º +0٩ +๙ /* { dg-error "not valid at the start of an identifier" } */ A๙ diff --git a/gcc/testsuite/g++.dg/cpp/ucnid-1.C b/gcc/testsuite/g++.dg/cpp/ucnid-1.C index 65c8995baad..b0a64e34d4b 100644 --- a/gcc/testsuite/g++.dg/cpp/ucnid-1.C +++ b/gcc/testsuite/g++.dg/cpp/ucnid-1.C @@ -1,17 +1,17 @@ /* { dg-do preprocess } */ /* { dg-options "-std=gnu++98 -pedantic" } */ -\u00AA /* { dg-error "not valid in an identifier" } */ +\u00AA \u00AB /* { dg-error "not valid in an identifier" } */ \u00B6 /* { dg-error "not valid in an identifier" } */ -\u00BA /* { dg-error "not valid in an identifier" } */ +\u00BA \u00C0 \u00D6 -\u0384 +\u0384 /* { dg-error "not valid in an identifier" } */ -\u0669 /* { dg-error "not valid in an identifier" } */ -A\u0669 /* { dg-error "not valid in an identifier" } */ -0\u00BA /* { dg-error "not valid in an identifier" } */ -0\u0669 /* { dg-error "not valid in an identifier" } */ -\u0E59 +\u0669 /* { dg-error "not valid at the start of an identifier" } */ +A\u0669 +0\u00BA +0\u0669 +\u0E59 /* { dg-error "not valid at the start of an identifier" } */ A\u0E59 diff --git a/libcpp/charset.c b/libcpp/charset.c index bcfd3ad44e1..0854677e515 100644 --- a/libcpp/charset.c +++ b/libcpp/charset.c @@ -955,14 +955,12 @@ ucn_valid_in_identifier (cpp_reader *pfile, cppchar_t c, valid_flags = C99 | CXX | C11 | CXX23; if (CPP_PEDANTIC (pfile)) { - if (CPP_OPTION (pfile, cxx23_identifiers)) + if (CPP_OPTION (pfile, cplusplus)) valid_flags = CXX23; else if (CPP_OPTION (pfile, c11_identifiers)) valid_flags = C11; else if (CPP_OPTION (pfile, c99)) valid_flags = C99; - else if (CPP_OPTION (pfile, cplusplus)) - valid_flags = CXX; } if (! (ucnranges[mn].flags & valid_flags)) return 0; @@ -1021,7 +1019,7 @@ ucn_valid_in_identifier (cpp_reader *pfile, cppchar_t c, return 2; } - if (CPP_OPTION (pfile, cxx23_identifiers)) + if (CPP_OPTION (pfile, cplusplus)) invalid_start_flags = NXX23; else if (CPP_OPTION (pfile, c11_identifiers)) invalid_start_flags = N11; diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h index 112b9c24751..08c72e7bc26 100644 --- a/libcpp/include/cpplib.h +++ b/libcpp/include/cpplib.h @@ -491,13 +491,9 @@ struct cpp_options unsigned char ext_numeric_literals; /* Nonzero means extended identifiers allow the characters specified - in C11 and C++11. */ + in C11. */ unsigned char c11_identifiers; - /* Nonzero means extended identifiers allow the characters specified - in C++23. */ - unsigned char cxx23_identifiers; - /* Nonzero for C++ 2014 Standard binary constants. */ unsigned char binary_constants; diff --git a/libcpp/init.c b/libcpp/init.c index 78719abfe20..198afd077c1 100644 --- a/libcpp/init.c +++ b/libcpp/init.c @@ -82,7 +82,6 @@ struct lang_flags char extended_numbers; char extended_identifiers; char c11_identifiers; - char cxx23_identifiers; char std; char digraphs; char uliterals; @@ -100,31 +99,31 @@ struct lang_flags }; static const struct lang_flags lang_defaults[] = -{ /* c99 c++ xnum xid c11 c++23 std digr ulit rlit udlit bincst digsep trig u8chlit vaopt scope dfp szlit elifdef */ - /* GNUC89 */ { 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 }, - /* GNUC99 */ { 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 }, - /* GNUC11 */ { 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 }, - /* GNUC17 */ { 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 }, - /* GNUC2X */ { 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1 }, - /* STDC89 */ { 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 }, - /* STDC94 */ { 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 }, - /* STDC99 */ { 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 }, - /* STDC11 */ { 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 }, - /* STDC17 */ { 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 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0, 0, 0, 0, 0, 0 } +{ /* c99 c++ xnum xid c11 std digr ulit rlit udlit bincst digsep trig u8chlit vaopt scope dfp szlit elifdef */ + /* GNUC89 */ { 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 }, + /* GNUC99 */ { 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 }, + /* GNUC11 */ { 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 }, + /* GNUC17 */ { 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 }, + /* GNUC2X */ { 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1 }, + /* STDC89 */ { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 }, + /* STDC94 */ { 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 }, + /* STDC99 */ { 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 }, + /* STDC11 */ { 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 }, + /* STDC17 */ { 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 }, + /* STDC2X */ { 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1 }, + /* GNUCXX */ { 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0 }, + /* CXX98 */ { 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0 }, + /* GNUCXX11 */ { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0 }, + /* CXX11 */ { 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0 }, + /* GNUCXX14 */ { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0 }, + /* CXX14 */ { 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0 }, + /* GNUCXX17 */ { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0 }, + /* CXX17 */ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0 }, + /* GNUCXX20 */ { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0 }, + /* CXX20 */ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0 }, + /* GNUCXX23 */ { 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1 }, + /* CXX23 */ { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1 }, + /* ASM */ { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; /* Sets internal flags correctly for a given language. */ @@ -140,7 +139,6 @@ cpp_set_lang (cpp_reader *pfile, enum c_lang lang) CPP_OPTION (pfile, extended_numbers) = l->extended_numbers; CPP_OPTION (pfile, extended_identifiers) = l->extended_identifiers; CPP_OPTION (pfile, c11_identifiers) = l->c11_identifiers; - CPP_OPTION (pfile, cxx23_identifiers) = l->cxx23_identifiers; CPP_OPTION (pfile, std) = l->std; CPP_OPTION (pfile, digraphs) = l->digraphs; CPP_OPTION (pfile, uliterals) = l->uliterals; diff --git a/libcpp/lex.c b/libcpp/lex.c index 9c27d8b5a08..7e56edc2131 100644 --- a/libcpp/lex.c +++ b/libcpp/lex.c @@ -1838,7 +1838,7 @@ warn_about_normalization (cpp_reader *pfile, if (NORMALIZE_STATE_RESULT (s) == normalized_C) cpp_warning_at (pfile, CPP_W_NORMALIZE, &rich_loc, "`%.*s' is not in NFKC", (int) sz, buf); - else if (CPP_OPTION (pfile, cxx23_identifiers)) + else if (CPP_OPTION (pfile, cplusplus)) cpp_pedwarning_at (pfile, CPP_W_NORMALIZE, &rich_loc, "`%.*s' is not in NFC", (int) sz, buf); else