From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 68E753858283 for ; Fri, 26 Aug 2022 00:53:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 68E753858283 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661475182; h=from:from:reply-to:subject:subject: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=I77l4B0eeGN6tCBNp6Jwy6/R51Gn8E6i+PN7K91RA+g=; b=KS5IJqBPIPpGMM6rS+PkqdGyUW3i7Qem/wyb8QpWps5IpA/DmLeR51B5z7aHT6HKN8SHWH I81+Lmdp4fNOuKKMlEwhlRhZl6Kxw1dBpWC9adK4sv/eRYG2l18o4iXRa/TkHmJl0cETgH e1WU82fBIzV+utau2G/BX6BMEBob7Zw= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-455-3T4xkVszMB2cHJK7kerR3Q-1; Thu, 25 Aug 2022 20:53:01 -0400 X-MC-Unique: 3T4xkVszMB2cHJK7kerR3Q-1 Received: by mail-qk1-f197.google.com with SMTP id az11-20020a05620a170b00b006bc374c71e8so96058qkb.17 for ; Thu, 25 Aug 2022 17:53:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc; bh=I77l4B0eeGN6tCBNp6Jwy6/R51Gn8E6i+PN7K91RA+g=; b=EEkJIvWVANvuHXsLTArFPmWnWy0jrMOjdEJokhUTtrGkHWfgI9jvXY4PnGlzjJBNHT l1nZXC+xWNGRKPmJZlllGrzuICPjXBRPPFo+KGKJVS94IYTcPWzkV6bd/xuEXLN5KxKb 8u02AN/piWIey0DEklv7//5Dy2T1Hg15JcuyZcaYK39glCYpLmg1GE2qZrWPkFYCkEUR Emssyvmf/49TYGTOunoWhaSsjxu7EROOy74asqMnvaupFau9Efi1LowJ2EayjORlB38O XT13CgPrL2D0Bikq5sIzrcWA8IpFNOp+nKEL2+q2zS7CxH4PPBREmK0AEacwdQ9/uBD9 /OMA== X-Gm-Message-State: ACgBeo1tfmosJGACp2wI02xogeEuI8SJO1bi7FIf4M10hpG1VR3/W0mw ZdEUeqfjAil7fE+G+OdqRz117wPts+A7uxiFKl0orQCJWJMXdZE9QE0nDp+zkjW/i0gwUbFL75j LqdR8f+LS+YVzWgjASA== X-Received: by 2002:a05:620a:1232:b0:6bb:fc73:cf80 with SMTP id v18-20020a05620a123200b006bbfc73cf80mr4931565qkj.464.1661475180627; Thu, 25 Aug 2022 17:53:00 -0700 (PDT) X-Google-Smtp-Source: AA6agR4beN8U8pfa/a5jF9HF4mVsVICxcY9u4A35FI9gUquZXXgwmMOrpDA1S5hphAZwN42PpudJIw== X-Received: by 2002:a05:620a:1232:b0:6bb:fc73:cf80 with SMTP id v18-20020a05620a123200b006bbfc73cf80mr4931558qkj.464.1661475180359; Thu, 25 Aug 2022 17:53:00 -0700 (PDT) Received: from [192.168.1.101] (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 h10-20020a05620a284a00b006b945519488sm807744qkp.88.2022.08.25.17.52.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 25 Aug 2022 17:52:59 -0700 (PDT) Message-ID: Date: Thu, 25 Aug 2022 20:52:58 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: Re: [PATCH v4] c++: Implement -Wself-move warning [PR81159] To: Marek Polacek Cc: GCC Patches References: <20220809163719.381319-1-polacek@redhat.com> <1ca5b35f-0fa6-be28-290f-701c5ac43807@redhat.com> <3e9dea44-1e0e-e329-575a-aa621d19deeb@redhat.com> <9e980813-7ab7-25dc-7f74-56faaafafb84@redhat.com> From: Jason Merrill In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE 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: On 8/25/22 17:49, Marek Polacek wrote: > On Thu, Aug 25, 2022 at 09:25:43AM -0400, Jason Merrill wrote: >> On 8/24/22 17:30, Marek Polacek wrote: >>> On Tue, Aug 23, 2022 at 05:27:00PM -0400, Jason Merrill wrote: >>>> On 8/23/22 09:39, Marek Polacek wrote: >>>>> + tree arg = CALL_EXPR_ARG (fn, 0); >>>>> + extract_op (arg); >>>>> + if (TREE_CODE (arg) == ADDR_EXPR) >>>>> + arg = TREE_OPERAND (arg, 0); >>>>> + tree type = TREE_TYPE (lhs); >>>>> + lhs = maybe_undo_parenthesized_ref (lhs); >>>>> + STRIP_ANY_LOCATION_WRAPPER (lhs); >>>>> + const bool print_var_p = (DECL_P (lhs) >>>>> + || REFERENCE_REF_P (lhs) >>>>> + || TREE_CODE (lhs) == COMPONENT_REF); >>>> >>>> Why include REFERENCE_REF_P and COMPONENT_REF? Reference refs should be >>>> stripped before this test, member refs aren't variables. >>> >>> I'm checking REFERENCE_REF_P and COMPONENT_REF to say "moving a variable" >>> in #1 and #3. The REFERENCE_REF_P check means that we also say "variable" >>> for #2. Sure, "A variable is introduced by the declaration of a reference >>> other than a non-static data member", but I'm not sure if users care about >>> that here? >>> >>> If I strip REFERENCE_REFs before the check then the result will be the >>> same. >> >> That's what I was suggesting, yes: Strip the REFERENCE_REF so DECL_P can see >> the decl. > > Ok, I've added the REFERENCE_REF stripping. But I've still left the > COMPONENT_REF in. Perhaps we could say "moving a member" to itself for > COMPONENT_REFs. Or just say "moving 'x' of type 'int' to itself" and > avoid all of this. :) Sure, that would be simpler. In any case, we shouldn't call member references variables. Jason