From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 39595 invoked by alias); 14 Dec 2018 07:41:33 -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 39465 invoked by uid 89); 14 Dec 2018 07:41:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= 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; Fri, 14 Dec 2018 07:41:31 +0000 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D0C1B2D7E4; Fri, 14 Dec 2018 07:41:29 +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 7192626E71; Fri, 14 Dec 2018 07:41:29 +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 wBE7fQsn010113; Fri, 14 Dec 2018 08:41:27 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id wBE7fONF010111; Fri, 14 Dec 2018 08:41:24 +0100 Date: Fri, 14 Dec 2018 07:41: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: <20181214074124.GI12380@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> <20181213233954.GH12380@tucnak> <5c5214f3-3165-707b-4e43-bfac000851a6@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5c5214f3-3165-707b-4e43-bfac000851a6@gmail.com> User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes X-SW-Source: 2018-12/txt/msg01017.txt.bz2 On Thu, Dec 13, 2018 at 09:03:57PM -0700, Martin Sebor wrote: > It's as good as the design of GCC attributes allows. Based on No. > the manual a function declaration like > > __attribute__ ((alloc_size (1), malloc)) > void* allocate (unsigned); > > should have those two attributes applied to it. Yet, alloc_size > is actually applied to its type (but not to its decl) while malloc > to the function's decl but not its type (bug 88397). > > I'm pretty sure most users still expect the following to pass: > > _Static_assert (__builtin_has_attribute (allocate, alloc_size)); > _Static_assert (__builtin_has_attribute (allocate, malloc)); Users shouldn't expect this. If anything, we should document what attributes are type attributes and which attributes are declaration attributes. With the way you're proposing, users could check the type attributes simply through __typeof/decltype etc., but couldn't test solely the declaration attributes. Jakub