From patchwork Tue Feb 14 11:22:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 56885 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2912787wrn; Tue, 14 Feb 2023 03:30:17 -0800 (PST) X-Google-Smtp-Source: AK7set8LjJ7eWJvA4Ztuyo/4C0sLmJ8THWym/h/DONl2PZ95PZz+4cq+0cvchlm7wRiq2HnPkWW9 X-Received: by 2002:a17:906:209d:b0:878:7471:6da7 with SMTP id 29-20020a170906209d00b0087874716da7mr3772324ejq.66.1676374217802; Tue, 14 Feb 2023 03:30:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676374217; cv=none; d=google.com; s=arc-20160816; b=YjFtdOBvx0awxzzYT8Cy/AnL+21N5h7C7wj32ZnApZQt6Cm/a6HSc+t/JGTD4JE2NL 3lAx1Q+eTJie/kz3bNQ8J2nfzK2JrkUpxel+ecdWeQMnAqXxrqcaI+USvYYIvprTsaiW De/P74YDMueHLqL5jAkvmtcOmMYvoD/zuExyu9yF4Uw/fCcGXYbOLPNe2TkCVTV0rUKd 54f13Vdyw3k5UI6qZDufHqGVT0bPBZpTasZrGjkX2QKf2AGYCmCaZUUb/DtSIt2HfW3L 7yl1gyUHTUUj8D+Q489HcpnO1/Zjzg+cFuR+IrEQocKFfEkdB6+OOklx2JyxQ+Tj7vR8 vLmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :resent-to:resent-message-id:resent-date:resent-from:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=XVTPTa/TeROA3nJws6z5di0xf0BRv+HU+gQ14OdFt9c=; b=HL5CKCAARVIwhAiPG/H8JAcMucl4uXid/lUk3hrDsxKziUJg8B2b22Po1FELB5FAeB bIVkWVaU5xYRgk7mDu7c2xPPS1SmjzP3ndERoK/5BhCaaYSyuwMgiAhebs9Solt8kLf0 xcA+jKQ8CYtNRk4DE2/DUcRQQQrb6CmRrbIkCDC99Z24jXdw9+qntF0f0FXVw+AN4DQn sScHDP6InYLCrFF+au4TBuiVA52iIsuMoOLYO6xt1rVdhSBSNvKioEMYp9MKaZMWjhzJ oGhFICPH6vsTUKdXJmWR88Bu7CUrfm5Qf7NYNE4L84ts+bvlbZkRDdlTytC+lRyHrMyF Blbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=G+3Ykecr; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id fx34-20020a1709069ea200b0088e6b7aff2csi18367298ejc.159.2023.02.14.03.30.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Feb 2023 03:30:17 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=G+3Ykecr; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D23233858CDB for ; Tue, 14 Feb 2023 11:30:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D23233858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676374216; bh=XVTPTa/TeROA3nJws6z5di0xf0BRv+HU+gQ14OdFt9c=; h=Resent-From:Resent-Date:Resent-To:Date:To:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=G+3YkecrdN87MqQfdL75dLwgY0xC8i0BZYHVXAgRHMQQ2z0+MwcVXAgZXH+KcOyMJ 8Yb2Uhgr+6AwBa2cVcHaH0kpWYA4/e4iEmXxRkHFbxLt9cxczerioyGid2BkwaTGHC a05sMqVMk17bUXFm0D9QItRCGXe4eF+GfNsKOnJQ= 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 9FD703858D1E for ; Tue, 14 Feb 2023 11:29:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9FD703858D1E Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-132-R2p7VeZIOOWVxI5T5dNr9A-1; Tue, 14 Feb 2023 06:29:26 -0500 X-MC-Unique: R2p7VeZIOOWVxI5T5dNr9A-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E0EE985A588 for ; Tue, 14 Feb 2023 11:29:25 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.193.203]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 84144140EBF6; Tue, 14 Feb 2023 11:29:25 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 31EBTMsI566244 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 14 Feb 2023 12:29:23 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 31EBTMHd566243; Tue, 14 Feb 2023 12:29:22 +0100 Resent-From: Jakub Jelinek Resent-Date: Tue, 14 Feb 2023 12:29:22 +0100 Resent-Message-ID: Resent-To: Jason Merrill , gcc-patches@gcc.gnu.org Date: Tue, 14 Feb 2023 12:22:33 +0100 To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: Add testcases from some Issaquah DRs Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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 Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757805772145310925?= X-GMAIL-MSGID: =?utf-8?q?1757805772145310925?= Hi! The following patch adds testcases for 5 DRs. In the DR2475, DR2530 and DR2691 my understanding is we already implement the desired behavior, in DR2478 partially (I've added 2 dg-bogus there, I think we inherit rather than overwrite DECL_DECLARED_CONSTINIT_P for explicit specialization somewhere, still far better than clang++) and DR2673 on the other side the DR was to codify the clang++ behavior rather than GCC. Not 100% sure if it is better to commit the 2 with dg-bogus or just wait until the actual fixes are implemented. BTW, I've noticed register_specialization does: FOR_EACH_CLONE (clone, fn) { DECL_DECLARED_INLINE_P (clone) = DECL_DECLARED_INLINE_P (fn); DECL_SOURCE_LOCATION (clone) = DECL_SOURCE_LOCATION (fn); DECL_DELETED_FN (clone) = DECL_DELETED_FN (fn); } but not e.g. constexpr/consteval, have tried to cover that in a testcase but haven't managed to do so. Tested on x86_64-linux with GXX_TESTSUITE_STDS=98,11,14,17,20,2b make check-g++ RUNTESTFLAGS='--target_board=unix\{-m32,-m64\} dg.exp=DRs/*.C' ok for trunk (or ok just for the 1st, 3rd and 5th testcase)? 2023-02-14 Jakub Jelinek * g++.dg/DRs/dr2475.C: New test. * g++.dg/DRs/dr2478.C: New test. * g++.dg/DRs/dr2530.C: New test. * g++.dg/DRs/dr2673.C: New test. * g++.dg/DRs/dr2691.C: New test. Jakub --- gcc/testsuite/g++.dg/DRs/dr2475.C.jj 2023-02-14 10:14:18.300920099 +0100 +++ gcc/testsuite/g++.dg/DRs/dr2475.C 2023-02-14 11:24:38.676314439 +0100 @@ -0,0 +1,6 @@ +// DR 2475 - Object declarations of type cv void +// { dg-do compile } + +int f(), x; +extern void g(), + y; // { dg-error "variable or field 'y' declared void" } --- gcc/testsuite/g++.dg/DRs/dr2478.C.jj 2023-02-14 10:23:35.487795016 +0100 +++ gcc/testsuite/g++.dg/DRs/dr2478.C 2023-02-14 11:24:49.092162197 +0100 @@ -0,0 +1,74 @@ +// DR 2478 - Properties of explicit specializations of implicitly-instantiated class templates +// { dg-do compile { target c++20 } } + +template +struct S { + int foo () { return 0; } + constexpr int bar () { return 0; } + int baz () { return 0; } + consteval int qux () { return 0; } + constexpr S () {} + static constinit T x; + static T y; +}; + +template +T S::x = S ().foo (); // { dg-error "'constinit' variable 'S::x' does not have a constant initializer" } + // { dg-error "call to non-'constexpr' function" "" { target *-*-* } .-1 } + +template +T S::y = S ().foo (); + +template <> +constexpr int +S::foo () +{ + return 0; +} + +template <> +int +S::bar () +{ + return 0; +} + +template <> +consteval int +S::baz () +{ + return 0; +} + +template <> +int +S::qux () +{ + return 0; +} + +template <> +long S::x = S ().foo (); // { dg-bogus "'constinit' variable 'S::x' does not have a constant initializer" "" { xfail *-*-* } } + // { dg-bogus "call to non-'constexpr' function" "" { xfail *-*-* } .-1 } + +template <> +constinit long S::y = S ().foo (); // { dg-error "'constinit' variable 'S::y' does not have a constant initializer" } + // { dg-error "call to non-'constexpr' function" "" { target *-*-* } .-1 } + +constinit auto a = S ().foo (); // { dg-error "'constinit' variable 'a' does not have a constant initializer" } + // { dg-error "call to non-'constexpr' function" "" { target *-*-* } .-1 } +constinit auto b = S ().bar (); +constinit auto c = S ().foo (); +constinit auto d = S ().bar (); // { dg-error "'constinit' variable 'd' does not have a constant initializer" } + // { dg-error "call to non-'constexpr' function" "" { target *-*-* } .-1 } +constinit auto e = S ().baz (); +constinit auto f = S ().qux (); // { dg-error "'constinit' variable 'f' does not have a constant initializer" } + // { dg-error "call to non-'constexpr' function" "" { target *-*-* } .-1 } +constinit auto g = S ().baz (); // { dg-error "'constinit' variable 'g' does not have a constant initializer" } + // { dg-error "call to non-'constexpr' function" "" { target *-*-* } .-1 } +constinit auto h = S ().qux (); +auto i = S::x; +auto j = S::x; +auto k = S::x; +auto l = S::y; +auto m = S::y; --- gcc/testsuite/g++.dg/DRs/dr2530.C.jj 2023-02-14 11:23:14.306547587 +0100 +++ gcc/testsuite/g++.dg/DRs/dr2530.C 2023-02-14 11:25:58.557146894 +0100 @@ -0,0 +1,5 @@ +// DR 2530 - Multiple definitions of enumerators +// { dg-do compile } + +enum E { e, e }; // { dg-error "redefinition of 'e'" } +enum F { f = 0, f = 0 }; // { dg-error "redefinition of 'f'" } --- gcc/testsuite/g++.dg/DRs/dr2673.C.jj 2023-02-14 11:38:15.030394220 +0100 +++ gcc/testsuite/g++.dg/DRs/dr2673.C 2023-02-14 11:46:00.262604342 +0100 @@ -0,0 +1,24 @@ +// DR 2673 - User-declared spaceship vs. built-in operators +// { dg-do compile { target c++20 } } + +#include + +enum class E : int { E1, E2 }; +enum class F : int { F1, F2 }; + +constexpr auto +operator<=> (E lhs, E rhs) +{ + return (int) rhs <=> (int) lhs; +} + +constexpr bool +operator== (F lhs, F rhs) +{ + return (int) lhs != (int) rhs; +} + +static_assert ((E::E1 <=> E::E2) == (1 <=> 0)); +static_assert (E::E1 > E::E2); // { dg-bogus "static assertion failed" "" { xfail *-*-* } } +static_assert (F::F1 == F::F2); +static_assert (!(F::F1 != F::F2)); // { dg-bogus "static assertion failed" "" { xfail *-*-* } } --- gcc/testsuite/g++.dg/DRs/dr2691.C.jj 2023-02-14 11:48:35.841335492 +0100 +++ gcc/testsuite/g++.dg/DRs/dr2691.C 2023-02-14 11:57:21.538669133 +0100 @@ -0,0 +1,15 @@ +// DR 2691 - hexadecimal-escape-sequence is too greedy +// { dg-do run { target c++11 } } +// { dg-require-effective-target wchar } +// { dg-options "-pedantic" } + +extern "C" void abort (); + +const char32_t *a = U"\x{20}ab"; // { dg-warning "delimited escape sequences are only valid in" "" { target c++20_down } } + +int +main () +{ + if (a[0] != U'\x20' || a[1] != U'a' || a[2] != U'b' || a[3] != U'\0') + abort (); +}