From patchwork Tue Apr 12 03:57:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1616046 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=P4+AzpGj; 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 4KcsQS2Qkgz9sCD for ; Tue, 12 Apr 2022 13:58:22 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6A4B43857C46 for ; Tue, 12 Apr 2022 03:58:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6A4B43857C46 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1649735898; bh=hZfJbx8ES66leEJEmNHcpE6TaT6TKuiu4vL2vbp9nDg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=P4+AzpGjZnbEw9Ny8Cla9ZhHUwtiBhYe5GT9IZduNNQSy5eeJv1nMNC56HjHFAgPO aKP7KAGpw5GZF3oCeMm2aCgWfkgxTrcCepds0sHavCs/WzuxMR7/78jO8FkfrtnEPD IjRzr0uJQmv4C/0WSf8z6s1n2/w9i8DPWueJbjik= 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 2A4EE3858C52 for ; Tue, 12 Apr 2022 03:57:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2A4EE3858C52 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.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-655-QCiVqo7_PUmN_qPn5sD5tw-1; Mon, 11 Apr 2022 23:57:34 -0400 X-MC-Unique: QCiVqo7_PUmN_qPn5sD5tw-1 Received: by mail-qk1-f199.google.com with SMTP id v14-20020a05620a0f0e00b00699f4ea852cso8841990qkl.9 for ; Mon, 11 Apr 2022 20:57:34 -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=hZfJbx8ES66leEJEmNHcpE6TaT6TKuiu4vL2vbp9nDg=; b=4wtvlbhtfuVtjeybZHF7akrv7YV5QvKNce+Rx1acjPbwsnR5VHBY0yW6VLaKRwGOpS bS1p1FBh+JBAWUWDiTMW6lIvQ70LFwfyS7FGEDXcfhAmJB3NJJ4nVCos1taUtqLPnK93 jMeHFbzHfQ0qjL5CcjXn5+iOu87FD9Nv53oQ+LLX3sadrF3+LoragZOsPlGMb44Gl0Ob pwMnOZSJKeH1Vlo0gv7V+afu2+FXM25TQWL+FyPduD1J2wXDLqTQSeLohy6VYwXST41w EHptqCMN700oXUZh3v4MTlUnEA9k6rXMNDPd5Kfdrl2B73qvIf4jV3q6qIi4ezQLf700 5uJA== X-Gm-Message-State: AOAM532rcnFhtpYrlujbBQ2yxQJGgV1QXbAQoH8R84Fvr5HxSaGuIlik VJk2JTJNIofJrGV58H3tkf9wZswqIYfwMmb+ikGPMAAFoaOcmXXypzcOLncya14cT2FmvoUob/L qF0MCuIqNRYrcKvq7ykUDI6F3oFeHmNeKUW2b40i/eEFL8DFmSMQ3HPmKgKV/t6ErjA== X-Received: by 2002:ad4:5d48:0:b0:444:4327:4993 with SMTP id jk8-20020ad45d48000000b0044443274993mr7359906qvb.117.1649735853124; Mon, 11 Apr 2022 20:57:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHgXCU65OK2vzKIBim4XFVmHQlrzI5az6Xf0x7b6Sq30AXklFGDNu+mXgARtFtH3+3zXo6Iw== X-Received: by 2002:ad4:5d48:0:b0:444:4327:4993 with SMTP id jk8-20020ad45d48000000b0044443274993mr7359897qvb.117.1649735852741; Mon, 11 Apr 2022 20:57:32 -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 q123-20020a378e81000000b0067eb3d6f605sm19999761qkd.0.2022.04.11.20.57.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Apr 2022 20:57:31 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: using operator= [PR105223] Date: Mon, 11 Apr 2022 23:57:28 -0400 Message-Id: <20220412035728.2976497-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" In a template class A we normally add an implicit using A::operator= as a placeholder for the implicitly declared operator whose signature we don't know yet. In my patch for PR92918 I stopped doing that if the class has an explicit operator=, but that was wrong; an operator= taking an unrelated type doesn't prevent the implicit declaration. When I was working on that patch, the change was necessary to avoid another regression, but apparently it is no longer needed. PR c++/105223 PR c++/92918 gcc/cp/ChangeLog: * class.cc (finish_struct): Always using op=. gcc/testsuite/ChangeLog: * g++.dg/template/using31.C: New test. --- gcc/cp/class.cc | 19 ++++++++----------- gcc/testsuite/g++.dg/template/using31.C | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 11 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/using31.C base-commit: 6afb21b824dabf17c79e7b0a4230572f091307ec diff --git a/gcc/cp/class.cc b/gcc/cp/class.cc index 40e17140db5..bfda0065bf4 100644 --- a/gcc/cp/class.cc +++ b/gcc/cp/class.cc @@ -7723,17 +7723,14 @@ finish_struct (tree t, tree attributes) lookup not to fail or recurse into bases. This isn't added to the template decl list so we drop this at instantiation time. */ - if (!get_class_binding_direct (t, assign_op_identifier, false)) - { - tree ass_op = build_lang_decl (USING_DECL, assign_op_identifier, - NULL_TREE); - DECL_CONTEXT (ass_op) = t; - USING_DECL_SCOPE (ass_op) = t; - DECL_DEPENDENT_P (ass_op) = true; - DECL_ARTIFICIAL (ass_op) = true; - DECL_CHAIN (ass_op) = TYPE_FIELDS (t); - TYPE_FIELDS (t) = ass_op; - } + tree ass_op = build_lang_decl (USING_DECL, assign_op_identifier, + NULL_TREE); + DECL_CONTEXT (ass_op) = t; + USING_DECL_SCOPE (ass_op) = t; + DECL_DEPENDENT_P (ass_op) = true; + DECL_ARTIFICIAL (ass_op) = true; + DECL_CHAIN (ass_op) = TYPE_FIELDS (t); + TYPE_FIELDS (t) = ass_op; TYPE_SIZE (t) = bitsize_zero_node; TYPE_SIZE_UNIT (t) = size_zero_node; diff --git a/gcc/testsuite/g++.dg/template/using31.C b/gcc/testsuite/g++.dg/template/using31.C new file mode 100644 index 00000000000..bfeb94f2788 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/using31.C @@ -0,0 +1,16 @@ +// PR c++/105223 + +struct ServiceReferenceBase { + void operator=(int); +}; + +template +struct ServiceReference : ServiceReferenceBase { + void foo() { operator=(0); } + using ServiceReferenceBase::operator=; +}; + +int main() { + ServiceReference sr; + sr.foo(); +}