From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 825A63858C60 for ; Fri, 10 Mar 2023 15:44:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 825A63858C60 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 60D591FD7C; Fri, 10 Mar 2023 15:44:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1678463050; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AlBhpufIBjP6L8Nep0Rd6kZUvzgi+v8qpg9d4eEK+oc=; b=C5V17ghXHZ8gz4dTeIPldTZXohjGYnh/6k0h1yQyWOujtol8DBAg7bAiGc8Y6GGHBEiVpe bsQ/TZJbv1l0mMyX+MtERkRvrJnFtBy0wI6FEnlMcNm5UNFHiaxAN1hxHjMuFY9OlcNXHY dnaZyqBH9LnRuctj6aXBmesctbyiXFc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1678463050; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AlBhpufIBjP6L8Nep0Rd6kZUvzgi+v8qpg9d4eEK+oc=; b=jbqSDvjg9Xv1NSx6TnDG0gNOWs82hKrbmdcy4agy9OEDXvGPmHReAbN54x7TdvsQb3CZBe IpCLhzgc/S8s6gCQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 542FF134F7; Fri, 10 Mar 2023 15:44:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 2qh8FEpQC2RhDQAAMHmgww (envelope-from ); Fri, 10 Mar 2023 15:44:10 +0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Richard Biener Mime-Version: 1.0 (1.0) Subject: Re: [PATCH] gcc: Add deleted assignment operators to non-copyable types Date: Fri, 10 Mar 2023 16:43:59 +0100 Message-Id: References: <20230310153513.2330396-1-jwakely@redhat.com> Cc: Jakub Jelinek In-Reply-To: <20230310153513.2330396-1-jwakely@redhat.com> To: Jonathan Wakely via Gcc-patches X-Mailer: iPhone Mail (20D67) X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,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 List-Id: > Am 10.03.2023 um 16:36 schrieb Jonathan Wakely via Gcc-patches : >=20 > =EF=BB=BFBootstrapped and regtested on powerpc64le-linux. >=20 > OK for trunk? Ok. Thanks, Richard=20 > It's safe to do now rather than waiting for Stage 1, because if we were > actually relying on copy-assigning these types it would have failed to > compile with this change. So it has no functional change, but will help > prevent any future misuse of these types. >=20 > -- >8 -- >=20 > The auto_timevar and auto_cond_timevar classes are supposed to be > non-copyable, but they have implicit assignment operators. Define their > assignment operators as deleted. >=20 > The auto_bitmap declares private copy/move constructors/assignments, > which can be replced with deleted copies to get the same effect but > using more idiomatic C++11 style. >=20 > gcc/ChangeLog: >=20 > * bitmap.h (class auto_bitmap): Replace private-and-undefined > copy and move special member functions with deleted copies. > * timevar.h (class auto_timevar): Delete assignment operator. > (class auto_cond_timevar): Likewise. > --- > gcc/bitmap.h | 11 ++++------- > gcc/timevar.h | 6 ++++-- > 2 files changed, 8 insertions(+), 9 deletions(-) >=20 > diff --git a/gcc/bitmap.h b/gcc/bitmap.h > index 43337d2e9d9..ccb484651ab 100644 > --- a/gcc/bitmap.h > +++ b/gcc/bitmap.h > @@ -945,7 +945,7 @@ bmp_iter_and_compl (bitmap_iterator *bi, unsigned *bit= _no) > /* A class that ties the lifetime of a bitmap to its scope. */ > class auto_bitmap > { > - public: > +public: > auto_bitmap (ALONE_CXX_MEM_STAT_INFO) > { bitmap_initialize (&m_bits, &bitmap_default_obstack PASS_MEM_STAT); }= > explicit auto_bitmap (bitmap_obstack *o CXX_MEM_STAT_INFO) > @@ -954,12 +954,9 @@ class auto_bitmap > // Allow calling bitmap functions on our bitmap. > operator bitmap () { return &m_bits; } >=20 > - private: > - // Prevent making a copy that references our bitmap. > - auto_bitmap (const auto_bitmap &); > - auto_bitmap &operator =3D (const auto_bitmap &); > - auto_bitmap (auto_bitmap &&); > - auto_bitmap &operator =3D (auto_bitmap &&); > + // Prevent shallow copies. > + auto_bitmap (const auto_bitmap &) =3D delete; > + auto_bitmap &operator =3D (const auto_bitmap &) =3D delete; >=20 > bitmap_head m_bits; > }; > diff --git a/gcc/timevar.h b/gcc/timevar.h > index ad465731609..b2d13d44190 100644 > --- a/gcc/timevar.h > +++ b/gcc/timevar.h > @@ -247,8 +247,9 @@ class auto_timevar > m_timer->pop (m_tv); > } >=20 > - // Disallow copies. > + // Prevent shallow copies. > auto_timevar (const auto_timevar &) =3D delete; > + auto_timevar &operator=3D (const auto_timevar &) =3D delete; >=20 > private: > timer *m_timer; > @@ -279,8 +280,9 @@ class auto_cond_timevar > m_timer->cond_stop (m_tv); > } >=20 > - // Disallow copies. > + // Prevent shallow copies. > auto_cond_timevar (const auto_cond_timevar &) =3D delete; > + auto_cond_timevar &operator=3D (const auto_cond_timevar &) =3D delete; >=20 > private: > void start() > --=20 > 2.39.2 >=20