This is the mail archive of the 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: PING: C++0x decltype patch

The first sorry(), for BIT_FIELD_REF, should be a gcc_unreachable; it
just can't happen here. The second "sorry" I'd like to keep... if we
get here, it means that I somehow missed a particular member-access
expression node. So, apologize to the user and when they report the
bug, we'll see what the expression code is to fix the bug. Perhaps
internal_error would be better?

IMHO that's exactly what
gcc_assert (TYPE_P (expr) || DECL_P (expr))
is for :) sorry is for pieces we _know_ we've not implemented. Here we _think_ we've covered all the cases, so an assert is appropriate.

here you parse tentatively, but don't appear to be committing to the tentative
parse when it succeeds.

Ah, thanks. The fix is:

  if (id_expression_or_member_access_p)
    /* We have parsed the complete id-expression or member access.  */
    cp_parser_parse_definitely (parser);
      /* Abort our attempt to parse an id-expression or member access
         expression.  */
      cp_parser_abort_tentative_parse (parser);

      /* Parse a full expression.  */
      expr = cp_parser_expression (parser, /*cast_p=*/false);

Essentially, by the time we reach this spot, we've either parsed an
id-expression or class member access expression, in which case there
is nothing left to tentatively parse (so we commit); or, we need to
abort the previous attempts and parse a full expression.


Also, I can't see where decltype is gated on using c++0x extensions

In lex.c, if the keyword is only available when in C++0x mode, then the feature is only available in C++0x mode:

{ "decltype", RID_DECLTYPE, D_CXX0X },

That said, decltype can save us (and the compiler) a LOT of work in
libstdc++, so I would suggest also:

{ "__decltype", RID_DECLTYPE, 0 },

I'm fine with this.

Updated patch attached, with those changes/fixes mention above.
Regtested powerpc-apple-darwin8.10.0, no regressions. Okay?

I would still like the other sorry turned into gcc_assert, for the reasons I mentioned.

Nathan Sidwell    ::   ::         CodeSourcery    ::

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