Thanks, Nathan! On 7/26/07, Nathan Sidwell wrote: > Index: cp/semantics.c > + case BIT_FIELD_REF: > + sorry ("bit-field accesses in a decltype expression"); > + return error_mark_node; > > + default: > + if (TYPE_P (expr) || DECL_P (expr)) > + error ("argument to decltype must be an expression"); > + else > + sorry ("unhandled decltype expression kind: %s", > + tree_code_name[(int) TREE_CODE (expr)]); > > why sorry and not gcc_assert or gcc_unreachable? 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? > + if (TREE_CODE (expr) == CALL_EXPR > + && (fndecl = get_callee_fndecl (expr)) > + && (fndecl != error_mark_node)) > > + else if ((type = is_bitfield_expr_with_lowered_type (expr))) > > ow :) can we avoid assignments in conditionals here? Heh, sure. > Index: cp/parser.c > +static tree > +cp_parser_decltype (cp_parser *parser) > > 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); else { /* 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 }, Updated patch attached, with those changes/fixes mention above. Regtested powerpc-apple-darwin8.10.0, no regressions. Okay? - Doug