From patchwork Mon Mar 28 13:33:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1610166 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=Phj45qZQ; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KRtxB6Y9Cz9sDX for ; Tue, 29 Mar 2022 00:35:26 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 45D41385DC37 for ; Mon, 28 Mar 2022 13:35:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 45D41385DC37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1648474524; bh=qh2+7JLT+EmudvTQZkbAnvVX7xlm1U12nqbRBMz3yBM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Phj45qZQfRkljKxFMfrv+HpBDeRVvTnRz8ifQP8idTq1tP2MHa3tg1OqvL26n9n63 lw9pFsi+PuvpRjnzoZlIIu4CoIJo+1LHurl/nzEQ6VgJ8qTZZOJ5puqXS5JkPf8c32 3+71wM33QD4YgnDrEsU+aH/mDpsrBaKdV4oKsuSY= 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 A967E385E00B for ; Mon, 28 Mar 2022 13:33:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org A967E385E00B Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-179-NY3pP0OcOaqa70AwjzVQdw-1; Mon, 28 Mar 2022 09:33:10 -0400 X-MC-Unique: NY3pP0OcOaqa70AwjzVQdw-1 Received: by mail-qv1-f72.google.com with SMTP id 94-20020a0c8167000000b004411702e935so11326451qvc.7 for ; Mon, 28 Mar 2022 06:33:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=qh2+7JLT+EmudvTQZkbAnvVX7xlm1U12nqbRBMz3yBM=; b=eHrmr6VFyo7pg4qpw9DntqRxbi/CpmTf/se+xfrIQ6MsW1VnH5D59agqNFLt0aA167 UNEQ46ptJiDx+zUyfdfGBO+kj0FVF51cRGGBg31wQcrGTkFCpxKHwz5r1RvhKs1bITgp An6oZBy4iYoxuDRJwNb6pRC9xxll3t8Jb2+7txrTtqddmQs/7XvVyqRFgPazmsDH4HyT EQYNqfoNKIaO2gHnPjQR5fwvBGvQ/96Aa7qvq490paCiGG2PNPBM8eEBZec5T60KdUwI cydm7fZC4W//SY8fPcwdbnri6j5Oh3Uqx+Bhr6OE2qKhOfrpx/s/EGee02tsap76jyNO 6zrg== X-Gm-Message-State: AOAM531UZ0yZo+QqntET4qeR7PnlZPe6ubPsXtB9t8garMyRtzi2KA9G W4JA70zlac5v72VIerNJJ8qOl6ABrDqdcH1dVXEMuHuRaRMgrz7KIypYwu46P9KsCtFccxzwvZd HZCwW1/mWuNjzDT1L+pOSllFE2TnNcjBdD/5caHkAvRXuJ2rIk368yufXB7UniTHboA== X-Received: by 2002:a05:622a:1188:b0:2e1:ce9c:a4aa with SMTP id m8-20020a05622a118800b002e1ce9ca4aamr21963486qtk.621.1648474389150; Mon, 28 Mar 2022 06:33:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxA3Oj7GgnygWH77ZlfD/f1gsrDHxUBBOkV8meYum3f40JCg8DTz4TbsoxYPVWFlW11rJGpbA== X-Received: by 2002:a05:622a:1188:b0:2e1:ce9c:a4aa with SMTP id m8-20020a05622a118800b002e1ce9ca4aamr21963427qtk.621.1648474388681; Mon, 28 Mar 2022 06:33:08 -0700 (PDT) Received: from barrymore.redhat.com (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id z8-20020ac87f88000000b002e1cecad0e4sm12239515qtj.33.2022.03.28.06.33.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 06:33:07 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: missing aggregate base ctor [PR102045] Date: Mon, 28 Mar 2022 09:33:06 -0400 Message-Id: <20220328133306.2583323-1-jason@redhat.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.0 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_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham 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: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" When make_base_init_ok changes a call to a complete constructor into a call to a base constructor, we were never marking the base ctor as used, so it didn't get emitted. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/102045 gcc/cp/ChangeLog: * call.cc (make_base_init_ok): Call make_used. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/aggr-base12.C: New test. --- gcc/cp/call.cc | 1 + gcc/testsuite/g++.dg/cpp1z/aggr-base12.C | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp1z/aggr-base12.C base-commit: bc86a86a4f2c057bc0e0be94dcbb8c128ae7f717 prerequisite-patch-id: 09e711b54e7911a4a04bd7808abc1b73ae4482ba prerequisite-patch-id: 566cf0772894d0c6a842b2e0ca62eb1d5ae8ad33 prerequisite-patch-id: b1def7e83e76c1652efb483cb2b67e472d15b720 diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc index dfe370d685d..73fede5a3df 100644 --- a/gcc/cp/call.cc +++ b/gcc/cp/call.cc @@ -8958,6 +8958,7 @@ make_base_init_ok (tree exp) call target. It would be possible to splice in the appropriate arguments, but probably not worth the complexity. */ return false; + mark_used (fn); AGGR_INIT_EXPR_FN (exp) = build_address (fn); return true; } diff --git a/gcc/testsuite/g++.dg/cpp1z/aggr-base12.C b/gcc/testsuite/g++.dg/cpp1z/aggr-base12.C new file mode 100644 index 00000000000..6f5a6b2056a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/aggr-base12.C @@ -0,0 +1,24 @@ +// PR c++/102045 +// { dg-do link { target c++17 } } + +template +struct span +{ + template + constexpr span(T (&a)[N]) : data(a), len(N) { } + constexpr bool empty() const { return len == 0; } + T* data; + unsigned long len; +}; + +struct byte_writer: span { + constexpr void do_something() noexcept { + (void)this->empty(); + } +}; + +int main() { + char array[1]; + auto writer = byte_writer{array}; + writer.do_something(); +}