From patchwork Thu Nov 3 12:33:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 14843 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp499629wru; Thu, 3 Nov 2022 05:34:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7CdGF6ioAupvmoh/0tr4UbE8dU4OzzanwTFzjsdWoF5Mty+E/vVPdLphR1W6+YWoMjUai1 X-Received: by 2002:a17:906:6a26:b0:7ad:975c:9785 with SMTP id qw38-20020a1709066a2600b007ad975c9785mr31064981ejc.25.1667478890390; Thu, 03 Nov 2022 05:34:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667478890; cv=none; d=google.com; s=arc-20160816; b=sUYlblowKmjSmK1jf11qYXg5Y5CHlSagH8lkc8jnUZ8Zx/XLJwDK06T5MrKAL7a5cb FIdLSEbyVrze8JV9X8VUg9hmMIjdepl5wXNfz/uErpcHd3kbZx3K0vHd3q80WQ7uJLD9 yprzylJVPoeqf1edqxXlK+WQLz48Az09pF74r/fsgNtideTGy5ObMG6ZrQkT8WPza8Ak MB+h9ND7Nb7E2NBboRD2c37tdAzLtc5b53nIK0UkuVvkV0ffgjD4e5q4sDLHkDQNwTxg yk1dTGLeVF/v92cvWbqo5S4FKOrGNnMaL5zwt9ibWpWLSaskBj4zaRrqaqlc81WEtDp5 6kNA== 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-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=t1V23dHJEnQ8Xvg9P79jZ8MCG2RoeOK59stJkXlLDjg=; b=j2+w8ILe12kOqQesxeGB+yqYRb+OJFkcV+9nhp6BBlUZ12TwRih7tRPVO5GeOrWSzB KIapubPCGnsGxmcugCFZ+3osUKlvLNP7XuzOUAtVuBJnUTSm1sZXCJsvwU8NbjuLvyL0 YtUsw93MeFKCD62po4Pw3pv3UbqLixjhTYYjc1QvxJOc6yZzX4ovSd3nxQI9pIeAGS6K UtrjzTsNTJDzEL4KOgBkSY7HCVoDgA9JePbY69806DrV42MQnLW91fUSTaBSzRcSVvAj xW7cgo2Ws0Xg09ETFRPXpU3kVFPxPwjI9pzD2nfVbfQz3GXKG8l048H+d+e9ecR/8GBw aJFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="NGd/wp8i"; 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id o3-20020aa7c503000000b00452697eda4csi1003972edq.58.2022.11.03.05.34.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 05:34:50 -0700 (PDT) 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="NGd/wp8i"; 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 4E253385840D for ; Thu, 3 Nov 2022 12:34:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4E253385840D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667478889; bh=t1V23dHJEnQ8Xvg9P79jZ8MCG2RoeOK59stJkXlLDjg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=NGd/wp8iAyExjRkKHUFOOC8XyvyaQiZsiAQP9AuzFmkGu70a1CMpJb+Q7BWbUqDiL 6Ktzm/XwxwLds5vl6COQk/8619wToizu0a+uuGSlOMX6VMLu7A3fx93yJGzr4LdajT rxzafyxOVSMr9k1RTPY1KeqLyxtEps5/dyvj1Y4c= 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.129.124]) by sourceware.org (Postfix) with ESMTPS id 1F9023858C62 for ; Thu, 3 Nov 2022 12:34:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1F9023858C62 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-482-RAR44OpkNguFU_Pb8gI3jA-1; Thu, 03 Nov 2022 08:33:44 -0400 X-MC-Unique: RAR44OpkNguFU_Pb8gI3jA-1 Received: by mail-qk1-f199.google.com with SMTP id u6-20020a05620a430600b006e47fa02576so1787118qko.22 for ; Thu, 03 Nov 2022 05:33:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=t1V23dHJEnQ8Xvg9P79jZ8MCG2RoeOK59stJkXlLDjg=; b=nuM9ceE/YMGAzxRWs+1df8k4UJZELEJlP336uuFaJtzbfRw7bK6rEr4VtIfHC0ZP2C ALRDCPSSKNwiL3/tvYJD7zzCsAX4zczGMNEbaRom+JJ98dhG6UdwPgESB75cyN8XLkZ3 Z9AafJxQAia2lg+2eV6Q5TDJlFaerNbFgNYX+TvgGHzIBGD2/w2c5KFzNv34Icm9ccyj 4ilZcrMijhSSeLyXgduEP9d6nwuvT/4Uem41bfhWKPF+urssduBpGrSi4EGoqGoeOZt+ tg1sG4v+2NYlc8lXuayfB9IEXFnbmtRIDVnbyfzmZssdFkCM+NCz3rCJMOqIkDc2iCqt coLw== X-Gm-Message-State: ACrzQf32iq8oJDft82jjHSknqSzywVzFMPyOq0f6tbGFK9v8iTxlzGf0 Qidb8r67yeCu7AsUVbzO3K8X7j9VRuk84khRkUoFmjmGCBff8A6lD5zPVsXfczS2a1zKbpychFc 9kIboTI53snRcD6O4FUfWRa8Vc0EWtzwSltfifWd5bb905HcXrtFbmTmzMtQaHJ8j96M= X-Received: by 2002:a05:6214:2342:b0:473:e142:f758 with SMTP id hu2-20020a056214234200b00473e142f758mr26540295qvb.83.1667478823267; Thu, 03 Nov 2022 05:33:43 -0700 (PDT) X-Received: by 2002:a05:6214:2342:b0:473:e142:f758 with SMTP id hu2-20020a056214234200b00473e142f758mr26540268qvb.83.1667478822987; Thu, 03 Nov 2022 05:33:42 -0700 (PDT) Received: from localhost.localdomain (ool-457670bb.dyn.optonline.net. [69.118.112.187]) by smtp.gmail.com with ESMTPSA id cc9-20020a05622a410900b0039442ee69c5sm416862qtb.91.2022.11.03.05.33.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 05:33:42 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: constexpr error with defaulted virtual dtor [PR93413] Date: Thu, 3 Nov 2022 08:33:40 -0400 Message-Id: <20221103123340.1402161-1-ppalka@redhat.com> X-Mailer: git-send-email 2.38.1.381.gc03801e19c MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-14.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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: Patrick Palka via Gcc-patches From: Patrick Palka Reply-To: Patrick Palka 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?1748478344967954611?= X-GMAIL-MSGID: =?utf-8?q?1748478344967954611?= We're rejecting the below testcase with error: 'virtual constexpr Base::~Base()' used before its definition error: 'virtual constexpr Derived::~Derived()' used before its definition due to an early exit added to mark_used by r181272 to defer synthesis of virtual destructors until EOF where we can set their linkage. This makes them effectively unusable for constexpr evaluation since that needs to be done immediately and can't also be deferred. Fortunately, this early exit seems to no longer be necessary ever since r208030 enabled us to tentatively set linkage of all defaulted virtual destructors, including templated ones. So this patch just gets rid of this early exit. Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk? PR c++/93413 gcc/cp/ChangeLog: * decl2.cc (mark_used): Don't defer synthesis of virtual functions. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/constexpr-virtual21.C: New test. --- gcc/cp/decl2.cc | 8 -------- gcc/testsuite/g++.dg/cpp2a/constexpr-virtual21.C | 10 ++++++++++ 2 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp2a/constexpr-virtual21.C diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc index e6779268ad4..eeb59eae64f 100644 --- a/gcc/cp/decl2.cc +++ b/gcc/cp/decl2.cc @@ -5788,14 +5788,6 @@ mark_used (tree decl, tsubst_flags_t complain /* = tf_warning_or_error */) && !DECL_DEFAULTED_OUTSIDE_CLASS_P (decl) && ! DECL_INITIAL (decl)) { - /* Defer virtual destructors so that thunks get the right - linkage. */ - if (DECL_VIRTUAL_P (decl) && !at_eof) - { - note_vague_linkage_fn (decl); - return true; - } - /* Remember the current location for a function we will end up synthesizing. Then we can inform the user where it was required in the case of error. */ diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-virtual21.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-virtual21.C new file mode 100644 index 00000000000..8b70c5f538b --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-virtual21.C @@ -0,0 +1,10 @@ +// PR c++/93413 +// { dg-do compile { target c++20 } } + +struct Base { + virtual ~Base() = default; +}; +constexpr Base b; + +struct Derived : Base { }; +constexpr Derived d;