summaryrefslogtreecommitdiffstats
path: root/gdb/c-exp.y
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2012-07-19 15:38:18 +0000
committerTom Tromey <tromey@redhat.com>2012-07-19 15:38:18 +0000
commit608b49672edd92191a25a2c365def9d2f4f51db7 (patch)
tree0ecad22ba0bdc2504d989da1742810ccc34a69b0 /gdb/c-exp.y
parent274b54d7e28ed7bb6c03c9d3a27b43151548b8af (diff)
downloadppe42-binutils-608b49672edd92191a25a2c365def9d2f4f51db7.tar.gz
ppe42-binutils-608b49672edd92191a25a2c365def9d2f4f51db7.zip
PR exp/13206:
* ax-gdb.c (gen_expr) <OP_TYPEOF, OP_DECLTYPE>: New cases. * breakpoint.c (watchpoint_exp_is_const) <OP_TYPEOF, OP_DECLTYPE>: 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) <OP_TYPEOF, OP_DECLTYPE>: New case. * expprint.c (dump_subexp_body_standard) <OP_TYPEOF, OP_DECLTYPE>: New case. * parse.c (operator_length_standard) <OP_TYPEOF, OP_DECLTYPE>: 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.
Diffstat (limited to 'gdb/c-exp.y')
-rw-r--r--gdb/c-exp.y24
1 files changed, 23 insertions, 1 deletions
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index e721995a87..174a38c1e9 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -219,6 +219,8 @@ static void check_parameter_typelist (VEC (type_ptr) *);
%type <sval> operator
%token REINTERPRET_CAST DYNAMIC_CAST STATIC_CAST CONST_CAST
%token ENTRY
+%token TYPEOF
+%token DECLTYPE
/* Special type cases, put in to allow the parser to distinguish different
legal basetypes. */
@@ -268,6 +270,20 @@ type_exp: type
{ write_exp_elt_opcode(OP_TYPE);
write_exp_elt_type($1);
write_exp_elt_opcode(OP_TYPE);}
+ | TYPEOF '(' exp ')'
+ {
+ write_exp_elt_opcode (OP_TYPEOF);
+ }
+ | TYPEOF '(' type ')'
+ {
+ write_exp_elt_opcode (OP_TYPE);
+ write_exp_elt_type ($3);
+ write_exp_elt_opcode (OP_TYPE);
+ }
+ | DECLTYPE '(' exp ')'
+ {
+ write_exp_elt_opcode (OP_DECLTYPE);
+ }
;
/* Expressions, including the comma operator. */
@@ -2059,7 +2075,13 @@ static const struct token ident_tokens[] =
{"const_cast", CONST_CAST, OP_NULL, FLAG_CXX },
{"dynamic_cast", DYNAMIC_CAST, OP_NULL, FLAG_CXX },
{"static_cast", STATIC_CAST, OP_NULL, FLAG_CXX },
- {"reinterpret_cast", REINTERPRET_CAST, OP_NULL, FLAG_CXX }
+ {"reinterpret_cast", REINTERPRET_CAST, OP_NULL, FLAG_CXX },
+
+ {"__typeof__", TYPEOF, OP_TYPEOF, 0 },
+ {"__typeof", TYPEOF, OP_TYPEOF, 0 },
+ {"typeof", TYPEOF, OP_TYPEOF, FLAG_SHADOW },
+ {"__decltype", DECLTYPE, OP_DECLTYPE, FLAG_CXX },
+ {"decltype", DECLTYPE, OP_DECLTYPE, FLAG_CXX | FLAG_SHADOW }
};
/* When we find that lexptr (the global var defined in parse.c) is
OpenPOWER on IntegriCloud