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 ESMTP id 9A47B3861035 for ; Thu, 1 Jul 2021 15:18:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9A47B3861035 Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-368-FMWcLyd3Pd2MavRHrcBjRA-1; Thu, 01 Jul 2021 11:18:29 -0400 X-MC-Unique: FMWcLyd3Pd2MavRHrcBjRA-1 Received: by mail-qt1-f199.google.com with SMTP id t15-20020a05622a180fb029024f88c5e9b0so3490768qtc.17 for ; Thu, 01 Jul 2021 08:18:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=voU0ymBOe9qw6jN+oyn5i3EgpyeaOXy3revPrJ4F6oU=; b=UutaF4O0vWcTfuZPe2K/oXGEPbBuC1WFc319vWFoHazfOYB5w/kM6hYMpj8HGZCyZ8 lmGWOR9sS73P7EnwSSnad9f2PJ9s7Nkm7YtwCDbe59xNJJlUrwwtr8ZgN/nNQXqrCOg2 5J2bMV+Z3OXBfrzsd23pvvFH1hQ6ndnhUtNl8Ib/a6fl2AaSPhUh4z/jY9qsuOtPEEtZ /xS/VENrNOplxegEEtdpLLNI0wlgFSbXR/hpEUH4brwCIqauLb2kLo59u8P4WXqoe3wy G8g2eDwpf4vfkDsE6/vGaBpnI3LWRBzuv1hRPMUzEhswNxm+bbJNdjkcr8LXfCBkS+xC SXgw== X-Gm-Message-State: AOAM531vTJ4MNoXelzHhqlnylKmq8VvU1WcHqVnLQdbzS8LeraFIQee1 9TJB1/vIQP+3aU9/tEQAN5SMi0ZMCB62w0zIpP+H3XyNQduJnfE14TI4TSyAW/YOBzylqELPCnz d0EGYZ2deQAk2y/MOjDGqmHOzyEhHg+YR0qbVHRuLV305/y4QEbN67J8XHwVAGr1tXg== X-Received: by 2002:a05:6214:90e:: with SMTP id dj14mr416556qvb.10.1625152708321; Thu, 01 Jul 2021 08:18:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/HhsNEwudOO8kdr1BVy9QgWnGz4HABcmpD3rY5/owmO1KB5YJVSH23J3hEdadfHmZMbeQag== X-Received: by 2002:a05:6214:90e:: with SMTP id dj14mr416536qvb.10.1625152708106; Thu, 01 Jul 2021 08:18:28 -0700 (PDT) Received: from [192.168.1.148] (130-44-159-43.s11817.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id g21sm89938qts.90.2021.07.01.08.18.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Jul 2021 08:18:27 -0700 (PDT) Subject: Re: [PATCH] Add gnu::diagnose_as attribute To: Matthias Kretz , gcc-patches@gcc.gnu.org References: <14205410.xuKvIAzr1H@excalibur> <8436091.EvYhyI6sBW@minbar> <2984128.Mn6ktlgx0N@excalibur> From: Jason Merrill Message-ID: <16bf94b5-cda3-08df-144b-739fa1c0ce3f@redhat.com> Date: Thu, 1 Jul 2021 11:18:26 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <2984128.Mn6ktlgx0N@excalibur> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.2 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, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP 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-List-Received-Date: Thu, 01 Jul 2021 15:18:31 -0000 On 7/1/21 5:28 AM, Matthias Kretz wrote: > On Tuesday, 22 June 2021 22:12:42 CEST Jason Merrill wrote: >> On 6/22/21 4:01 PM, Matthias Kretz wrote: >>> On Tuesday, 22 June 2021 21:52:16 CEST Jason Merrill wrote: >>>> For alias templates, you probably want the attribute only on the >>>> templated class, not on the instantiations. >>> >>> Oh good point. My current patch does not allow the attribute on alias >>> templates. Consider: >>> >>> template >>> >>> struct X {}; >>> >>> template >>> >>> using foo [[gnu::diagnose_as]] = X; >>> >>> I have no idea how this could work. I would have to set the attribute for >>> an implicit partial specialization (not that I know of the existence of >>> such a thing)? I.e. X would have to be diagnosed as foo, >>> but X would have to be diagnosed as X, not foo. >>> >>> So if anything it should only support alias templates if they are strictly >>> "renaming" the type. I.e. their template parameters must match up exactly. >>> Can I constrain the attribute like this? >> >> Yes. You can check that with get_underlying_template. >> >> Or you could support the above by putting the attribute on the >> instantiation with the TEMPLATE_INFO for foo rather than a simple name. > > Question, given: > > template using foo = bar; > > The diagnose_as attribute handler isn't called until e.g. `foo` is > instantiated. You probably want to adjust is_late_template_attribute to change that. > Meaning that even after the declaration of the alias template > `bar` will not be diagnosed as `foo`, which happens only after the > first use of `foo`. I find that more confusing than helpful, even if the > expectation would be that users only use the alias template. > > So do you still expect alias templates to support diagnose_as? And if yes, how > could I handle the attribute so that the diagnose_as attribute is applied to > `bar` on declaration of `foo`? >