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 0B9113858D37 for ; Fri, 3 Nov 2023 03:04:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0B9113858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0B9113858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698980697; cv=none; b=ghQhHsOvIa9BHOFChXMNjjdamBuCSWZEi3lGYzIkgKyhYpthAg2pXE0WKxqfzWDOskGAewO8YeMF16uTz7PLJN0oWv22FSD2ciKNUIXjzlMvAADbTKiOR5QueK131CvgkmEyGIIs88M0DvpoYRxmqcBx/NHqHe6qk57qVbddl6Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698980697; c=relaxed/simple; bh=tuEZVB1VS4ooEdiDWQcjrHHFWX3pmLaVumY2hzhnGI4=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=pJeG82xnUFTVp+xQPupMs9SoHd3wBfR+UO04fgSImseQMsrITehRfMJ/X9GEHCYnHpmWmqUjWPlJQO77yZWYOEqJM8KkF2lprcwXdg31erM3NY06Ypz2szIEnyr5owv0S2IxQEZqZkiau5n7sYOSnh8ry9zh7ZoE7nO88YpyqCg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1698980686; 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=M7AvJk8+qpxtVhXhXnCTQ24otWMapu7rru4EAZumM5Y=; b=US/yQTKf28zKrXiyzh4q63emZ4AO5+0GdNAcXhtAg0ilbkkhZcGBXgULw9rs2l7LsmIWCr RcWFuT6iYPJ3xxkkUr9rNEqflUfOoPUhKTrqlMGBBvcVdSnd59P8hOSaQj81TUm/y2jYeQ /tsd90hCRS5FgFqzQydojiCx9o9Fts4= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-517-8KDvta3iMEmIpDtjSlg-LQ-1; Thu, 02 Nov 2023 23:04:45 -0400 X-MC-Unique: 8KDvta3iMEmIpDtjSlg-LQ-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-66d159f725cso18300436d6.2 for ; Thu, 02 Nov 2023 20:04:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698980684; x=1699585484; 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:subject:date:message-id:reply-to; bh=M7AvJk8+qpxtVhXhXnCTQ24otWMapu7rru4EAZumM5Y=; b=pR85+VmKAujHf/8KCI9DEdbrRoyi+di/ZirArRiMbF2XzSh9l7BJF5oz34Ga24YOg7 Bvqytr45XHm4+2A00PzC9H6FNrw3WLIEB/zgoZR+MTOnLmgO+NAKWX/H23h9YbhQaGsJ EvmPlio+ARIaqDdartGzmXgSwx3cnGsDuq+WlWm6IN+LQ8HH5eY/JhzA4Kd7Rmbj3LSZ XPMawV3kiKu/BdIltRCc6K2maqC1W03hD1D8KvU453sea9T1juAIriyFa84gbYwyOToj PwGOd5AP2OcFwU13jv3LIhxhArjPIA2LYKad9eC0v+MurcXeqqm0m+Nwm1QG2g7UlO7L qAyg== X-Gm-Message-State: AOJu0YwX6R11Vtn8LnRMPwzokcnnBfp81lPmaPifuHgHdia9lyiyaFWO Zolr4lAlw6IHmoEKZN2Y3NqHtWdPPWOT1GWNF6UUvwz4CKfHwAdkdWc0wd2Y+MNG7nIGmP0cCrz 1OjXEEEmzmVPT8Zjrlw== X-Received: by 2002:a05:6214:ca1:b0:671:f14f:bf6 with SMTP id s1-20020a0562140ca100b00671f14f0bf6mr18295790qvs.12.1698980684669; Thu, 02 Nov 2023 20:04:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEGTEstHr6l9jDxU2tbQKNDCGOcbapyGpOfnwfz2No9YAzTgIP8Qz52UhmWJOtxvaN3ZHu4WQ== X-Received: by 2002:a05:6214:ca1:b0:671:f14f:bf6 with SMTP id s1-20020a0562140ca100b00671f14f0bf6mr18295774qvs.12.1698980684308; Thu, 02 Nov 2023 20:04:44 -0700 (PDT) Received: from [192.168.1.108] (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id y20-20020ad445b4000000b00655d711180dsm334108qvu.17.2023.11.02.20.04.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Nov 2023 20:04:43 -0700 (PDT) Message-ID: <2f4020bf-3ef7-4627-9d92-c74676981f4b@redhat.com> Date: Thu, 2 Nov 2023 23:04:41 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 1/2] c++: Initial support for P0847R7 (Deducing This) [PR102609] To: waffl3x Cc: "gcc-patches@gcc.gnu.org" References: <0cc5b21d-4b27-4964-bec3-544c86307c74@redhat.com> <1fdadb6b-e4ca-40c1-bb1c-43a0f42826ba@redhat.com> <635f5d6d-2807-4dff-8a37-73d323d6ea97@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=-6.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,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.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 10/28/23 00:07, waffl3x wrote: > I wanted to change DECL_NONSTATIC_MEMBER_FUNCTION_P to include explicit > object member functions, but it had some problems when I made the > modification. I also noticed that it's used in cp-objcp-common.cc so > would making changes to it be a bad idea? > > -- cp-tree.h > ``` > /* Nonzero for FUNCTION_DECL means that this decl is a non-static > member function. */ > #define DECL_NONSTATIC_MEMBER_FUNCTION_P(NODE) \ > (TREE_CODE (TREE_TYPE (NODE)) == METHOD_TYPE) > ``` > I didn't want to investigate the problems as I was knee deep in > investigating the addressof bug. So I instead modified > DECL_FUNCTION_MEMBER_P to include explicit object member functions and > moved on. > > -- cp-tree.h > ``` > /* Nonzero for FUNCTION_DECL means that this decl is a member function > (static or non-static). */ > #define DECL_FUNCTION_MEMBER_P(NODE) \ > (DECL_NONSTATIC_MEMBER_FUNCTION_P (NODE) || DECL_STATIC_FUNCTION_P (NODE) \ > || DECL_IS_XOBJ_MEMBER_FUNC (NODE)) > ``` > I am mostly just mentioning this here in case it becomes more relevant > later. Looking at how much DECL_NONSTATIC_MEMBER_FUNCTION_P is used > throughout the code I now suspect that adding explicit object member > functions to it might cause xobj member functions to be treated as > regular member functions when they should not be. > > If this change were to stick it would cause a discrepancy in the > behavior of DECL_NONSTATIC_MEMBER_FUNCTION_P and it's name. If we were > to do this, I think it's important we document the discrepancy and why > it exists, and in the future, it should possibly be refactored. One > option would be to simply rename it to DECL_IOBJ_MEMBER_FUNCTION_P. > After all, I suspect that it's unlikely that the current macro > (DECL_NONSTATIC_MEMBER_FUNCTION_P) is being used in places that concern > explicit object member functions. So just adding explicit object member > functions to it will most likely just result in headaches. > > It seems to me that would be the best solution, so when and if it comes > up again, I think that route should be considered. Agreed, it sounds good to rename the current macro and then add a new macro that includes both implicit and explicit, assuming that's a useful category. > Secondly, there are some differences in the nodes describing an > explicit object member function from those describing static member > functions and implicit object member functions that I am not sure > should be present. > > I did my best to summarize the differences, if you want the logs of > tree_debug that I derived them from I can provide them. Most of my > understanding of the layout of the nodes is from reading print-tree.cc > and looking at debug_tree outputs, so it's possible I made a mistake. > > I am opting to use the names of members as they are output by > debug_tree, I recognize this is not always the actual name of the > member in the actual tree_node structures. > > Additionally, some of the differences listed are to be expected and are > most likely the correct values for each node. However, I wanted to be > exhaustive when listing them just in case I am mistaken in my opinion > on whether the differences should or should not occur. > > The following declarations were used as input to the compiler. > iobj decl: > struct S { void f() {} }; > xobj decl: > struct S { void f(this S&) {} }; > static decl: > struct S { static void f(S&) {} }; > > These differences can be observed in the return values of > grokdeclarator for each declaration. > > 1. function_decl::type::tree_code > iobj: method_type > xobj: function_type > stat: function_type > 2. function_decl::type::method basetype > iobj: > xobj: NULL/no output > stat: NULL/no output > 3. function_decl::type::arg-types::tree_list[0]::value > iobj: > xobj: > stat: > 4. function_decl::decl_6 > iobj: false/no output > xobj: false/no output > stat: true > 5. function_decl::align > iobj: 16 > xobj: 8 > stat: 8 > 6. function_decl::result::uid > iobj: D.2513 > xobj: D.2513 > stat: D.2512 > 7. function_decl::full-name > iobj: "void S::f()" > xobj: "void S::f(this S&)" > > Differences 1, 3, and 7 seem obviously correct to me for all 3 > declarations, 6 is a little bizarre to me, but since it's just a UID > it's merely an oddity, I doubt it is concerning. Agreed. > That leaves 2, 4, and 5. > > 2. I am pretty sure xobj functions should have the struct they are a > part of recorded as the method basetype member. I have already checked > that function_type and method_type are the same node type under the > hood and it does appear to be, so it should be trivial to set it. > However I do have to wonder why static member functions don't set it, > it seems to be that it would be convenient to use the same field. Can > you provide any insight into that? method basetype is only for METHOD_TYPE; if you want the containing type of the function, that's DECL_CONTEXT. > 4. I have no comment here, but it does concern me since I don't > understand it at all. In the list near the top of cp-tree.h, DECL_LANG_FLAG_6 for a FUNCTION_DECL is documented to be DECL_THIS_STATIC, which should only be set on the static member. > 5. I am pretty sure this is fine for now, but if xobj member functions > ever were to support virtual/override capabilities, then it would be a > problem. Is my understanding correct, or is there some other reason > that iobj member functions have a different value here? It is surprising that an iobj memfn would have a different DECL_ALIGN, but it shouldn't be a problem; the vtables only rely on alignment being at least 2. > There are also some differences in the arg param in > cp_build_addr_expr_1 that concerns me, but most of them are reflected > in the differences I have already noted. I had wanted to include these > differences as well but I have been spending too much time staring at > it, it's no longer productive. In short, the indirect_ref node for xobj > member functions has reference_to_this set, while iobj member functions > do not. That's a result of difference 3. > The baselink binfo field has the private flag set for xobj > member functions, iobj member functions does not. TREE_PRIVATE on a binfo is part of BINFO_ACCESS, which isn't a fixed value, but gets updated during member search. Perhaps the differences in consideration of conversion to a base led to it being set or cleared differently? I wouldn't worry too much about it unless you see differences in access control. > I've spent too much time on this write up, so I am calling it here, it > wasn't all a waste of time because half of what I was doing here are > things I was going to need to do anyway at least. I still feel like I > spent too much time on it. Hopefully it's of some value for me/others > later. I hope my responses are helpful as well. Jason