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.133.124]) by sourceware.org (Postfix) with ESMTPS id 560593858D28 for ; Fri, 3 Nov 2023 18:05:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 560593858D28 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 560593858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699034709; cv=none; b=UIDz8cQOq7y6oSvSt2/Z/XwpXnIOqueQVlWAk7rn4DC29udT9F6sLqhK0mULZtqdAuM3b39ow2MDTe5c7NSPBiQHvg5sGbOOAIbLN1Auxk/UFUKGNaJbK1Grpa0c6jVahlJxfmjdralNVP3yH4cPHtBTHR/tp3t4sdX3ehHojKo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699034709; c=relaxed/simple; bh=KUuURktNkHudUcrWz2jCMNwH5e3Y47BaD5MKBcPlgXc=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=c5xNVNTWd/TF0ePNE/NP6baxe+IJiMSHBUWr5OT0vZkDLHbkvAln7WtE05V2UkTuAM7QFc2Pfpa10mwJP0mDuO54Tpcv4i0i+CWxnrIM3dkIdiuh02qrIp6JzNiTWeHhVWwGKysXMSYoVADdn6F8TWI9cHrtGzSKTpyYgxKmFTU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699034707; 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=MYrHFCsaUmNLmMbwywOoHaahVuNqvXUwh2P3YjSlKuE=; b=hYRN2pX3tnZ/kU6CYlwNBlO48V10UYmpHLatwz8M+21aou1YklYG45ZH12TJYCuwl1d0mv 6WjazIPH80+UCicMYlYuEIqsY5RKUaIb+LQQpxTPAnqz38ngfi+gz1qR8H3RVJqbokZAqC pE2MPX+ZIitQoMNlmxWnTe3caRA9VAI= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-318-AhW3fsrDOSeAkioE435ZOA-1; Fri, 03 Nov 2023 14:05:05 -0400 X-MC-Unique: AhW3fsrDOSeAkioE435ZOA-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-7789577b4e0so230109085a.2 for ; Fri, 03 Nov 2023 11:05:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699034705; x=1699639505; 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=MYrHFCsaUmNLmMbwywOoHaahVuNqvXUwh2P3YjSlKuE=; b=L1Six0455g8IizTOH9ZbGyXwbOn4L+QY8h8WWUXUIky2geTWUyFxge23yhc9VfjsX8 1EPtdjKVfnKCQ2HJMnzasJ9/gvsDMRu5qPNGOtohe8VLsi95QsDlZqLI7h2hrAcX02Zq 07Opu3ZuN6Ol7fxyebApektj4qL7XNAlFlQO6Jdrgdmf1BdEGp3TYGIPU7K6EMnAbVl0 xTSa+T0zvCVtXl/DjfbZ00sUwk0Wtet9b4rlVVBQEz73GN99hX6ys3nIinhueaZAAN8Q PRHTC+JskpzJXRdcIiNCE9FksHAkB8r5uw3T+64r6fn1Fp+s+Bd8gJZaqbuTaqsTnsmA LnfA== X-Gm-Message-State: AOJu0Yz2FuTruxupLiYjzwa1ATl+3fCU9igN+9AkHxX93iNlwYf2XPs3 kpOPVFVk4r9NSkjRy5S/T2Qa77Arj7YReJd+3+w1Po6HLo2Roem1cCP4fDI2A7yqOrbPWdiWemt 8XKMKt0fwUuKTGBiWtYigPAZ3bg== X-Received: by 2002:a05:6214:d68:b0:66d:63b3:690d with SMTP id 8-20020a0562140d6800b0066d63b3690dmr32517235qvs.52.1699034704911; Fri, 03 Nov 2023 11:05:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEPMElWuBHq0ZqOJoiZqV5J2wMeCTB2DfY1WNKh+TRpd7KXQu4fVWabFOaOj22DdggGVdA70g== X-Received: by 2002:a05:6214:d68:b0:66d:63b3:690d with SMTP id 8-20020a0562140d6800b0066d63b3690dmr32517200qvs.52.1699034704561; Fri, 03 Nov 2023 11:05:04 -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 ei8-20020ad45a08000000b0066db331b4cdsm953158qvb.86.2023.11.03.11.05.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 03 Nov 2023 11:05:03 -0700 (PDT) Message-ID: Date: Fri, 3 Nov 2023 14:05:02 -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: <1fdadb6b-e4ca-40c1-bb1c-43a0f42826ba@redhat.com> <635f5d6d-2807-4dff-8a37-73d323d6ea97@redhat.com> <2f4020bf-3ef7-4627-9d92-c74676981f4b@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=-5.8 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_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_SORBS_WEB,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no 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 11/3/23 00:44, waffl3x wrote: >>> 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. > > -- gcc/tree.h:530 > #define FUNC_OR_METHOD_CHECK(T) TREE_CHECK2 (T, FUNCTION_TYPE, METHOD_TYPE) > -- gcc/tree.h:2518 > #define TYPE_METHOD_BASETYPE(NODE) \ > (FUNC_OR_METHOD_CHECK (NODE)->type_non_common.maxval) > > The code doesn't seem to reflect that, perhaps since the underlying > node type is the same (as far as I can tell, they both inherit from > tree_type_non_common) it wasn't believed to be necessary. Curious. It might also be a remnant of how older code dealt with how sometimes a member function changes between FUNCTION_TYPE and METHOD_TYPE during parsing. > Upon looking at DECL_CONTEXT though I see it seems you were thinking of > FUNCTION_DECL. I haven't observed DECL_CONTEXT being set for > FUNCTION_DECL nodes though, perhaps it should be? Although it's more > likely that it is being set and I just haven't noticed, but if that's > the case I'll have to make a note to make sure it is being set for xobj > member functions. I would certainly expect it to be getting set already. > I was going to say that this seems like a redundancy, but I realized > that the type of a member function pointer is tied to the struct, so it > actually ends up relevant for METHOD_TYPE nodes. I would hazard a guess > that when forming member function pointers the FUNCTION_DECL node was > not as easily accessed. If I remember correctly that is not the case > right now so it might be worthwhile to refactor away from > TYPE_METHOD_BASETYPE and replace uses of it with DECL_CONTEXT. For a pointer-to-member, the class type is part of the type, so trying to remove it from the type doesn't sound like an improvement to me. Specifically, TYPE_PTRMEM_CLASS_TYPE refers to TYPE_METHOD_BASETYPE for a pointer to member function. > I'm getting ahead of myself though, I'll stop here and avoid going on > too much of a refactoring tangent. I do want this patch to make it into > GCC14 after all. Good plan. :) >>> 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. > > Right, I'll try to remember to check this area in the future, but yeah > that tracks because I did remove that flag. Removing that flag just so > happened to be the start of this saga of bug fixes but alas, it had to > be done. > >>> 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. > > I'll put a note for myself to look into it in the future, it's an > oddity at minimum and oddities interest me :^). > >>> 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. > > Okay, makes sense, I'm mildly concerned about any possible side effects > this might have since we have a function_type node suddenly going > through execution paths that only method_type went through before. The > whole "reference_to_this" "pointer_to_this" thing is a little confusing > because I'm pretty sure that doesn't refer to the actual `this` object > argument or parameter since I've seen it all over the place. Hopefully > it's benign. Yes, "pointer_to_this" is just a cache of the type that is a pointer to the type you're looking at. You are correct that it has nothing to do with the C++ 'this'. >>> 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. > > Unfortunately I don't have any tests for private/public access yet, > it's one of the area's I've neglected. Unfortunately I probably won't > put too much effort into writing TOO many more right now as it takes up > a lot of my time. I still have to clean up the ones I currently have > and I have a few I wanted to write that are not yet written. Makes sense. I wouldn't expect access control to need specific changes. >>> 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. > > Very much so, thank you! > > An update on the regression testing, I had one test fail comparing > against commit a4d2b108cf234e7893322a32a7956ca24e283b05 (GCC13) and I'm > not sure if I need to be concerned about it. > libgomp.c++/../libgomp.c-c++-common/for-16.c execution test No, that test has been pretty flaky for me, you can ignore it. > I'm going to be starting tests for my patch against trunk now, once > that is finished I should be ready to format a patch for review. Great! Jason