This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]