From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 114595 invoked by alias); 13 Dec 2018 23:40:01 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 114554 invoked by uid 89); 13 Dec 2018 23:40:00 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS autolearn=no version=3.3.2 spammy=bools, Hx-languages-length:1539 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Dec 2018 23:39:59 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 187EA30034DE; Thu, 13 Dec 2018 23:39:58 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-117-214.ams2.redhat.com [10.36.117.214]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A7DC5608EE; Thu, 13 Dec 2018 23:39:57 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id wBDNdtcX009474; Fri, 14 Dec 2018 00:39:55 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id wBDNdsFv009473; Fri, 14 Dec 2018 00:39:54 +0100 Date: Thu, 13 Dec 2018 23:40:00 -0000 From: Jakub Jelinek To: Martin Sebor Cc: Jeff Law , Gcc Patch List Subject: Re: [PATCH] handle expressions in __builtin_has_attribute (PR 88383) Message-ID: <20181213233954.GH12380@tucnak> Reply-To: Jakub Jelinek References: <6b1f15b6-1446-21a2-54aa-b92ec6b5541f@redhat.com> <5599edd4-61ad-24ce-d19e-376dd9398183@gmail.com> <688c62e2-966a-c950-ca63-b58003610c62@gmail.com> <20181213195651.GZ12380@tucnak> <4e9198aa-3348-c45f-e3e7-7b3c23f94190@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4e9198aa-3348-c45f-e3e7-7b3c23f94190@gmail.com> User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes X-SW-Source: 2018-12/txt/msg01000.txt.bz2 On Thu, Dec 13, 2018 at 02:05:29PM -0700, Martin Sebor wrote: > > So how is the builtin defined then? Is the argument always an expression > > and you only return whether its type has the attribute, or do something > > different if the expression is of certain kind? > > For a DECL the built-in looks at both the DECL_ATTRIBUTES and > the DECL's type's TYPE_ATTRIBUTES. For expressions, it just > looks at TYPE_ATTRIBUTES of the expression's type. I'm not > sure that this is necessarily the cleanest design but it's > meant to follow how attributes are applied to DECLs. Sometimes > they get applied to the DECL itself and other times to its type. > This has been causing confusion to both users and GCC devs such > as myself so at some point I'd like to make this clearer somehow. > Not sure exactly how yet. But some users of the attribute look for the attribute on TYPE_ATTRIBUTES, other on DECL_ATTRIBUTES, and the attributes have bools which say to what they apply. So, I think the API need to be very clear whether the attribute is on a decl or on a type. If it is similar to say sizeof/__alignof__ etc., where it accepts either a type (for which one can use __typeof/decltype etc.), in which case it would check the type attributes, or an expression and in that case require it to be a decl and use decl attributes, one API is fine, but supporting arbitrary expressions and sometimes looking at type, other times at decl or both is not a good design. Jakub