%token <voidval> KW_EXTERN
%token <voidval> KW_CONST
%token <voidval> KW_FN
+%token <voidval> KW_SIZEOF
/* Operator tokens. */
%token <voidval> DOTDOT
| array_expr
| idx_expr
| range_expr
-| unop_expr
+| unop_expr /* Must precede call_expr because of ambiguity with sizeof. */
| binop_expr
| paren_expr
| call_expr
}
;
-/* S{} is documented as valid but seems to be an unstable feature, so
- it is left out here. */
struct_expr_list:
- struct_expr_tail
+ /* %empty */
+ {
+ VEC (set_field) **result
+ = OBSTACK_ZALLOC (&work_obstack, VEC (set_field) *);
+ $$ = result;
+ }
+| struct_expr_tail
{
VEC (set_field) **result
= OBSTACK_ZALLOC (&work_obstack, VEC (set_field) *);
| '&' KW_MUT expr %prec UNARY
{ $$ = ast_unary (UNOP_ADDR, $3); }
-
+| KW_SIZEOF '(' expr ')' %prec UNARY
+ { $$ = ast_unary (UNOP_SIZEOF, $3); }
;
binop_expr:
{ "true", KW_TRUE, OP_NULL },
{ "extern", KW_EXTERN, OP_NULL },
{ "fn", KW_FN, OP_NULL },
+ { "sizeof", KW_SIZEOF, OP_NULL },
};
/* Operator tokens, sorted longest first. */
int i;
int len;
VEC (int) *offsets = NULL;
- unsigned int current_len, previous_len;
+ unsigned int current_len;
struct cleanup *cleanup;
cleanup = make_cleanup (VEC_cleanup (int), &offsets);
current_len = cp_find_first_component (scope);
- previous_len = 0;
while (scope[current_len] != '\0')
{
VEC_safe_push (int, offsets, current_len);
gdb_assert (scope[current_len] == ':');
- previous_len = current_len;
/* The "::". */
current_len += 2;
current_len += cp_find_first_component (scope
case UNOP_COMPLEMENT:
case UNOP_IND:
case UNOP_ADDR:
+ case UNOP_SIZEOF:
convert_ast_to_expression (state, operation->left.op, top);
write_exp_elt_opcode (state, operation->opcode);
break;