]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
PR symtab/11462:
authorTom Tromey <tromey@redhat.com>
Mon, 25 Mar 2013 17:28:03 +0000 (17:28 +0000)
committerTom Tromey <tromey@redhat.com>
Mon, 25 Mar 2013 17:28:03 +0000 (17:28 +0000)
* 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.

gdb/ChangeLog
gdb/c-exp.y
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.cp/m-static.exp

index 4639417eedee29d4c20e8c1b6b54679839d14f5f..2b2a0895c6512e5c11b000a6aa6b8609def67c8d 100644 (file)
@@ -1,3 +1,10 @@
+2013-03-25  Tom Tromey  <tromey@redhat.com>
+
+       PR symtab/11462:
+       * c-exp.y (exp): Add new productions for destructors after '.' and
+       '->'.
+       (write_destructor_name): New function.
+
 2013-03-25  Tom Tromey  <tromey@redhat.com>
 
        PR c++/9197:
index 0ab1cde2224bb9a70807a8a5f6be44f4b84995bb..c3c7f1697baba2e32d346dcd7850fa272218729a 100644 (file)
@@ -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
index 6e8a0f4cd2e6379ec07b6b4f7186cd49086fa75b..ad4fd404833f886e0caca47b0e691128d1bae239 100644 (file)
@@ -1,3 +1,7 @@
+2013-03-25  Tom Tromey  <tromey@redhat.com>
+
+       * gdb.cp/m-static.exp: Add destructor-printing tests.
+
 2013-03-25  Tom Tromey  <tromey@redhat.com>
 
        * gdb.cp/m-static.exp: Add constructor ptype tests.
index b31922aae75506b8b559d9b61252930994ebc874..65ec6a000586efe1451e8832a38e4e2fb0e8e3f4 100644 (file)
@@ -79,6 +79,13 @@ gdb_test "ptype single_constructor::single_constructor" \
     {type = void \(single_constructor \* const\)} \
     "simple object class, ptype constructor"
 
+gdb_test "print test1.~gnu_obj_1" \
+    { = {void \(gnu_obj_1 \* const, int\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} \
+    "simple object instance, print destructor"
+gdb_test "ptype test1.~gnu_obj_1" \
+    {type = void \(gnu_obj_1 \* const, int\)} \
+    "simple object instance, ptype destructor"
+
 gdb_test "print test1.'~gnu_obj_1'" \
     { = {void \(gnu_obj_1 \*( const)?, int\)} 0x[0-9a-f]+ <gnu_obj_1::~gnu_obj_1\(\)>} \
     "simple object instance, print quoted destructor"