From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26288 invoked by alias); 13 Dec 2018 19:56:58 -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 26245 invoked by uid 89); 13 Dec 2018 19:56:57 -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=HContent-Transfer-Encoding:8bit 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 19:56:56 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 390155D5EA; Thu, 13 Dec 2018 19:56:55 +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 CE19F65923; Thu, 13 Dec 2018 19:56:54 +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 wBDJuqqH002957; Thu, 13 Dec 2018 20:56:52 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id wBDJupAX002956; Thu, 13 Dec 2018 20:56:51 +0100 Date: Thu, 13 Dec 2018 19:56: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: <20181213195651.GZ12380@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> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <688c62e2-966a-c950-ca63-b58003610c62@gmail.com> User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes X-SW-Source: 2018-12/txt/msg00975.txt.bz2 On Thu, Dec 13, 2018 at 12:48:18PM -0700, Martin Sebor wrote: > > The support is necessary in order to determine the attributes > > in expressions such as: > > > >   struct S { __attribute__ ((packed)) int a[32]; }; > > > >   extern struct S s; > > > >   _Static_assert (__builtin_has_attribute (s.a, packed)); > > An example involving types might be a better one: > > typedef __attribute__ ((may_alias)) int* BadInt; > > void f (BadInt *p) > { > _Static_assert (__builtin_has_attribute (*p, may_alias)); > } 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? Perhaps it would be better have two builtins, one would always take type from the expression, the other would only accept decls (or perhaps some syntax for the FIELD_DECLs). Jakub