summaryrefslogtreecommitdiff
path: root/gdb/c-exp.y
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2013-03-25 17:28:02 +0000
committerTom Tromey <tromey@redhat.com>2013-03-25 17:28:02 +0000
commit08b2773ea95d8fb09a7dab5838f86f6e24b03bfd (patch)
tree05a13cca5e012e92c499f8651a166aedaeb24c4e /gdb/c-exp.y
parent1f8a1ced4eefa4c6052a3e4566781527373eff45 (diff)
downloadgdb-08b2773ea95d8fb09a7dab5838f86f6e24b03bfd.tar.gz
PR symtab/11462:
* c-exp.y (exp): Add new productions for destructors after '.' and '->'. (write_destructor_name): New function. gdb/testsuite * gdb.cp/m-static.exp: Add destructor-printing tests.
Diffstat (limited to 'gdb/c-exp.y')
-rw-r--r--gdb/c-exp.y43
1 files changed, 43 insertions, 0 deletions
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 0ab1cde2224..c3c7f1697ba 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -167,6 +167,7 @@ void yyerror (char *);
static int parse_number (char *, int, int, YYSTYPE *);
static struct stoken operator_stoken (const char *);
static void check_parameter_typelist (VEC (type_ptr) *);
+static void write_destructor_name (struct stoken);
static void c_print_token (FILE *file, int type, YYSTYPE value);
#define YYPRINT(FILE, TYPE, VALUE) c_print_token (FILE, TYPE, VALUE)
@@ -372,6 +373,19 @@ exp : exp ARROW COMPLETE
write_exp_elt_opcode (STRUCTOP_PTR); }
;
+exp : exp ARROW '~' name
+ { write_exp_elt_opcode (STRUCTOP_PTR);
+ write_destructor_name ($4);
+ write_exp_elt_opcode (STRUCTOP_PTR); }
+ ;
+
+exp : exp ARROW '~' name COMPLETE
+ { mark_struct_expression ();
+ write_exp_elt_opcode (STRUCTOP_PTR);
+ write_destructor_name ($4);
+ write_exp_elt_opcode (STRUCTOP_PTR); }
+ ;
+
exp : exp ARROW qualified_name
{ /* exp->type::name becomes exp->*(&type::name) */
/* Note: this doesn't work if name is a
@@ -407,6 +421,19 @@ exp : exp '.' COMPLETE
write_exp_elt_opcode (STRUCTOP_STRUCT); }
;
+exp : exp '.' '~' name
+ { write_exp_elt_opcode (STRUCTOP_STRUCT);
+ write_destructor_name ($4);
+ write_exp_elt_opcode (STRUCTOP_STRUCT); }
+ ;
+
+exp : exp '.' '~' name COMPLETE
+ { mark_struct_expression ();
+ write_exp_elt_opcode (STRUCTOP_STRUCT);
+ write_destructor_name ($4);
+ write_exp_elt_opcode (STRUCTOP_STRUCT); }
+ ;
+
exp : exp '.' qualified_name
{ /* exp.type::name becomes exp.*(&type::name) */
/* Note: this doesn't work if name is a
@@ -1592,6 +1619,22 @@ name_not_typename : NAME
%%
+/* Like write_exp_string, but prepends a '~'. */
+
+static void
+write_destructor_name (struct stoken token)
+{
+ char *copy = alloca (token.length + 1);
+
+ copy[0] = '~';
+ memcpy (&copy[1], token.ptr, token.length);
+
+ token.ptr = copy;
+ ++token.length;
+
+ write_exp_string (token);
+}
+
/* Returns a stoken of the operator name given by OP (which does not
include the string "operator"). */
static struct stoken