C++ PATCH: use identifier_p instead of naked TREE_CODE == IDENTIFIER_NODE

Gabriel Dos Reis gdr@integrable-solutions.net
Fri Mar 22 04:36:00 GMT 2013


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



More information about the Gcc-patches mailing list