This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Need help: Is a VAR_DECL type builtin or not?
- From: Dominik Vogt <vogt at linux dot vnet dot ibm dot com>
- To: GCC Development <gcc at gcc dot gnu dot org>
- Cc: Richard Biener <richard dot guenther at gmail dot com>
- Date: Mon, 17 Feb 2014 13:15:42 +0100
- Subject: Re: Need help: Is a VAR_DECL type builtin or not?
- Authentication-results: sourceware.org; auth=none
- References: <20140214085908 dot GA5228 at linux dot vnet dot ibm dot com> <CAFiYyc1HbvtrmGjoBA1DXtFNtkdbJAVbC6inpG_TNz_pTjfhGg at mail dot gmail dot com>
- Reply-to: vogt at linux dot vnet dot ibm dot com
On Fri, Feb 14, 2014 at 02:40:44PM +0100, Richard Biener wrote:
> On Fri, Feb 14, 2014 at 9:59 AM, Dominik Vogt <vogt@linux.vnet.ibm.com> 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