From 608b49672edd92191a25a2c365def9d2f4f51db7 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Thu, 19 Jul 2012 15:38:18 +0000 Subject: PR exp/13206: * ax-gdb.c (gen_expr) : New cases. * breakpoint.c (watchpoint_exp_is_const) : New cases. * c-exp.y (TYPEOF, DECLTYPE): New tokens. (type_exp): Add new productions. (ident_tokens): Add __typeof__, typeof, __typeof, __decltype, and decltype. * eval.c (evaluate_subexp_standard) : New case. * expprint.c (dump_subexp_body_standard) : New case. * parse.c (operator_length_standard) : New case. * std-operator.def (OP_TYPEOF, OP_DECLTYPE): New constants. * varobj.c (varobj_create): Handle OP_TYPEOF, OP_DECLTYPE. gdb/testsuite * gdb.cp/casts.exp: Add tests for typeof and decltype. * gdb.cp/casts.cc (decltype): New function. (main): Use it. --- gdb/eval.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'gdb/eval.c') diff --git a/gdb/eval.c b/gdb/eval.c index a012873..4253820 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -2900,6 +2900,45 @@ evaluate_subexp_standard (struct type *expect_type, else error (_("Attempt to use a type name as an expression")); + case OP_TYPEOF: + case OP_DECLTYPE: + if (noside == EVAL_SKIP) + { + evaluate_subexp (NULL_TYPE, exp, pos, EVAL_SKIP); + goto nosideret; + } + else if (noside == EVAL_AVOID_SIDE_EFFECTS) + { + enum exp_opcode sub_op = exp->elts[*pos].opcode; + struct value *result; + + result = evaluate_subexp (NULL_TYPE, exp, pos, + EVAL_AVOID_SIDE_EFFECTS); + + /* 'decltype' has special semantics for lvalues. */ + if (op == OP_DECLTYPE + && (sub_op == BINOP_SUBSCRIPT + || sub_op == STRUCTOP_MEMBER + || sub_op == STRUCTOP_MPTR + || sub_op == UNOP_IND + || sub_op == STRUCTOP_STRUCT + || sub_op == STRUCTOP_PTR + || sub_op == OP_SCOPE)) + { + struct type *type = value_type (result); + + if (TYPE_CODE (check_typedef (type)) != TYPE_CODE_REF) + { + type = lookup_reference_type (type); + result = allocate_value (type); + } + } + + return result; + } + else + error (_("Attempt to use a type as an expression")); + default: /* Removing this case and compiling with gcc -Wall reveals that a lot of cases are hitting this case. Some of these should -- cgit v1.1