From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17451 invoked by alias); 17 Feb 2014 12:15:49 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 17439 invoked by uid 89); 17 Feb 2014 12:15:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.7 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: e06smtp13.uk.ibm.com Received: from e06smtp13.uk.ibm.com (HELO e06smtp13.uk.ibm.com) (195.75.94.109) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 17 Feb 2014 12:15:47 +0000 Received: from /spool/local by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 17 Feb 2014 12:15:43 -0000 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 17 Feb 2014 12:15:43 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id F34F2219005E for ; Mon, 17 Feb 2014 12:15:39 +0000 (GMT) Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by b06cxnps4075.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s1HCFUYu40173668 for ; Mon, 17 Feb 2014 12:15:30 GMT Received: from d06av01.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s1HCFgJI006682 for ; Mon, 17 Feb 2014 05:15:42 -0700 Received: from bl3ahm9f.de.ibm.com (dyn-9-152-212-25.boeblingen.de.ibm.com [9.152.212.25]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s1HCFfxN006613 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO); Mon, 17 Feb 2014 05:15:41 -0700 Received: from dvogt by bl3ahm9f.de.ibm.com with local (Exim 4.76) (envelope-from ) id 1WFN6s-0004ej-Sw; Mon, 17 Feb 2014 13:15:42 +0100 Date: Mon, 17 Feb 2014 12:15:00 -0000 From: Dominik Vogt To: GCC Development Cc: Richard Biener Subject: Re: Need help: Is a VAR_DECL type builtin or not? Message-ID: <20140217121542.GA17780@linux.vnet.ibm.com> Reply-To: vogt@linux.vnet.ibm.com References: <20140214085908.GA5228@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14021712-2966-0000-0000-00000A4C75F6 X-SW-Source: 2014-02/txt/msg00252.txt.bz2 On Fri, Feb 14, 2014 at 02:40:44PM +0100, Richard Biener wrote: > On Fri, Feb 14, 2014 at 9:59 AM, Dominik Vogt wrote: > > Given a specific VAR_DECL tree node, I need to find out whether > > its type is built in or not. Up to now I have > > > > tree tn = TYPE_NAME (TREE_TYPE (var_decl)); > > if (tn != NULL_TREE && TREE_CODE (tn) == TYPE_DECL && DECL_NAME (tn)) > > { > > ... > > } > > > > This if-condition is true for both, > > > > int x; > > const int x; > > ... > > > > and > > > > typedef int i_t; > > i_t x; > > const i_t x; > > ... > > > > I need to weed out the class of VAR_DECLs that directly use built > > in types. > > Try DECL_IS_BUILTIN. But I question how you define "builtin" here? Well, actually I'm working on the variable output function in godump.c. At the moment, if the code comes across typedef char c_t chat c1; c_t c2; it emits type _c_t byte var c1 byte var c2 byte This is fine for c1, but for c2 it should really use the type: var c2 _c_t So the rule I'm trying to implement is: Given a Tree node that is a VAR_DECL, if its type is an "alias" (defined with typedef/union/struct/class etc.), use the name of the alias, otherwise resolve the type recursively until only types built into the language are left. It's really only about the underlying data types (int, float, _Complex etc.), not about storage classes, pointers, attributes, qualifiers etc. Well, since godump.c already caches all declarations it has come across, I could assume that these declarations are not built-in and use that in the "rule" above. Ciao Dominik ^_^ ^_^ -- Dominik Vogt IBM Germany