From patchwork Tue Nov 30 18:19:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 48303 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 35678385C406 for ; Tue, 30 Nov 2021 18:20:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 35678385C406 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1638296448; bh=szoWdC8SKFBO/ppFUTdOSJHw3SkKuriB5ZOocO0rhqc=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=DDwjpkLSAr0vb5xSgsmKjrAfkFBMMWkN0oma/iCMld4Qdwa6mW/soqhhD+Sch9uwS FXy0r8RuGqNjBt5Ymmy5UabWe9YIHSfuY63WHlzN0eEXZgBbh8fJottr/NHEcv2jtU R04k/I3VvFkeUtrtS98gNy9V3OXNHy29hqUDZVqc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id A1B6B3858D28 for ; Tue, 30 Nov 2021 18:20:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A1B6B3858D28 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-338-VxUtpyTTMX2KvFOIOGBDSQ-1; Tue, 30 Nov 2021 13:20:15 -0500 X-MC-Unique: VxUtpyTTMX2KvFOIOGBDSQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1910B192AB6E for ; Tue, 30 Nov 2021 18:20:15 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.194.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7115E79451; Tue, 30 Nov 2021 18:20:14 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 1AUIJtXr2951978 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 30 Nov 2021 19:19:56 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 1AUIJtv22951977; Tue, 30 Nov 2021 19:19:55 +0100 Date: Tue, 30 Nov 2021 19:19:55 +0100 To: Jason Merrill Subject: [PATCH] libcpp: Enable P1949R7 for C++98 too [PR100977] Message-ID: <20211130181955.GR2646553@tucnak> References: <20211129112413.GE2646553@tucnak> <717296d8-1c1f-2c6c-c99a-4ca7deaf70a1@redhat.com> MIME-Version: 1.0 In-Reply-To: <717296d8-1c1f-2c6c-c99a-4ca7deaf70a1@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SCC_10_SHORT_WORD_LINES, SCC_20_SHORT_WORD_LINES, SCC_35_SHORT_WORD_LINES, SCC_5_SHORT_WORD_LINES, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: Jonathan Wakely , gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2021-11-30 Jakub Jelinek * 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. Jakub --- gcc/init.c.jj 2021-11-29 22:54:46.503750631 +0100 +++ gcc/init.c 2021-11-30 01:06:31.704473882 +0100 @@ -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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, 1, 0, 0, 0 }, - /* GNUCXX14 */ { 1, 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, 1, 0, 0, 1, 0, 0, 0 }, - /* GNUCXX17 */ { 1, 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, 1, 0, 1, 0, 1, 0, 0, 0 }, - /* GNUCXX20 */ { 1, 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, 1, 0, 1, 1, 1, 0, 0, 0 }, - /* GNUCXX23 */ { 1, 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, 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, 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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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_ 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; --- gcc/include/cpplib.h.jj 2021-11-17 20:08:18.359724792 +0100 +++ gcc/include/cpplib.h 2021-11-30 01:06:12.325741705 +0100 @@ -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; --- gcc/lex.c.jj 2021-11-23 23:09:03.404339391 +0100 +++ gcc/lex.c 2021-11-30 01:07:20.713796544 +0100 @@ -1838,7 +1838,7 @@ warn_about_normalization (cpp_reader *pf 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 --- gcc/charset.c.jj 2021-11-01 23:01:30.582702315 +0100 +++ gcc/charset.c 2021-11-30 01:08:13.651064928 +0100 @@ -955,14 +955,12 @@ ucn_valid_in_identifier (cpp_reader *pfi 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 *pfi 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; --- gcc/testsuite/g++.dg/cpp/ucnid-1.C.jj 2020-01-14 20:02:46.702611047 +0100 +++ gcc/testsuite/g++.dg/cpp/ucnid-1.C 2021-11-30 18:40:00.664865172 +0100 @@ -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 --- gcc/testsuite/g++.dg/cpp/ucnid-1-utf8.C.jj 2020-01-14 20:02:46.702611047 +0100 +++ gcc/testsuite/g++.dg/cpp/ucnid-1-utf8.C 2021-11-30 18:40:51.641121457 +0100 @@ -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๙