This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH: use identifier_p instead of naked TREE_CODE == IDENTIFIER_NODE
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Miles Bader <miles at gnu dot org>
- Cc: Gabriel Dos Reis <gdr at axiomatics dot org>, gcc-patches at gcc dot gnu dot org, jason at redhat dot com
- Date: Thu, 21 Mar 2013 23:35:32 -0500
- Subject: Re: C++ PATCH: use identifier_p instead of naked TREE_CODE == IDENTIFIER_NODE
- References: <87vc8kjdou dot fsf at euclid dot axiomatics dot org> <87ehf86oxh dot fsf at catnip dot gol dot com>
On Thu, Mar 21, 2013 at 11:25 PM, Miles Bader <miles@gnu.org> wrote:
>
> Gabriel Dos Reis <gdr@axiomatics.org> writes:
> > in the C++ front-end. identifier_p is effectively LANG_IDENTIFIER_CAST
> > except that it returns a typed pointer instead of a boolean value.
>
> What's the point of returning a pointer when the name (and apparently,
> use, judging from the patch) suggest a boolean...?
consider it to be a generalized boolean, nothing out of ordinary.
In many places, we do thinks like:
1. test that we have a identifier.
2. immediately follow that with access to parts of the
tree as identifiers, but check again that we really
an identifier, etc.
Something best written as
if (lang_identifier *id = identifier_p (t))
access members of id with no more check please.
There is nothing silly about that.
-- Gaby