From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailout2.rbg.tum.de (mailout2.rbg.tum.de [IPv6:2a09:80c0::202]) by sourceware.org (Postfix) with ESMTPS id 99B3B3858D1E for ; Wed, 17 Aug 2022 07:15:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 99B3B3858D1E Received: from mailrelay1.rbg.tum.de (mailrelay1.in.tum.de [131.159.254.14]) by mailout2.rbg.tum.de (Postfix) with ESMTPS id 8011E4C02BB; Wed, 17 Aug 2022 09:15:23 +0200 (CEST) Received: by mailrelay1.rbg.tum.de (Postfix, from userid 112) id 7A659543; Wed, 17 Aug 2022 09:15:23 +0200 (CEST) Received: from mailrelay1.rbg.tum.de (localhost [127.0.0.1]) by mailrelay1.rbg.tum.de (Postfix) with ESMTP id 4ECEA542; Wed, 17 Aug 2022 09:15:23 +0200 (CEST) Received: from mail.in.tum.de (vmrbg426.in.tum.de [131.159.0.73]) by mailrelay1.rbg.tum.de (Postfix) with ESMTPS id 4D377540; Wed, 17 Aug 2022 09:15:23 +0200 (CEST) Received: by mail.in.tum.de (Postfix, from userid 112) id 49DEC4A0193; Wed, 17 Aug 2022 09:15:23 +0200 (CEST) Received: from atkemper10.in.tum.de (atkemper10.in.tum.de [IPv6:2a09:80c0:16::1130]) by mail.in.tum.de (Postfix) with ESMTP id AC3EA4A0115; Wed, 17 Aug 2022 09:15:20 +0200 (CEST) From: fent@in.tum.de To: gdb-patches@sourceware.org Cc: tom@tromey.com, simon.marchi@polymtl.ca, Philipp Fent Subject: [PATCH] gdb: fix disas of destructors in nested namespaces Date: Wed, 17 Aug 2022 09:14:18 +0200 Message-Id: <20220817071417.349625-1-fent@in.tum.de> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Aug 2022 07:15:28 -0000 From: Philipp Fent Remove the destructor name validity check. The check did not properly handle nested namespaces or complex templates with nested angle brackets. Overload resolution already checks the name and reports any mismatches, so this check seems unnecessary. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=27045 Signed-off-by: Philipp Fent --- gdb/c-exp.y | 2 -- gdb/testsuite/gdb.cp/classes.cc | 8 ++++++++ gdb/testsuite/gdb.cp/classes.exp | 4 ++++ gdb/valops.c | 27 --------------------------- gdb/value.h | 2 -- 5 files changed, 12 insertions(+), 31 deletions(-) diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 61a61fcba09..7ef557bd38f 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -1151,8 +1151,6 @@ qualified_name: TYPENAME COLONCOLON name std::string name = "~" + std::string ($4.ptr, $4.length); - /* Check for valid destructor name. */ - destructor_name_p (name.c_str (), $1.type); pstate->push_new (type, std::move (name)); } diff --git a/gdb/testsuite/gdb.cp/classes.cc b/gdb/testsuite/gdb.cp/classes.cc index 3bb52d2433c..c59413cddbd 100644 --- a/gdb/testsuite/gdb.cp/classes.cc +++ b/gdb/testsuite/gdb.cp/classes.cc @@ -401,6 +401,13 @@ class Base1 { ~Base1 () { } }; +namespace nested { +class Base { +public: + ~Base () {} +}; +} + typedef Base1 base1; class Foo @@ -627,6 +634,7 @@ void use_methods () i = class_param.Aval_x (g_A); base1 b (3); + nested::Base nb; } struct Inner diff --git a/gdb/testsuite/gdb.cp/classes.exp b/gdb/testsuite/gdb.cp/classes.exp index 7b8b315ac1f..14c2e04e492 100644 --- a/gdb/testsuite/gdb.cp/classes.exp +++ b/gdb/testsuite/gdb.cp/classes.exp @@ -654,6 +654,10 @@ proc do_tests {} { "print dtor of typedef class" gdb_test "list ByAnyOtherName::times" ".*int Foo::times.*" + + gdb_test "disassemble nested::Base::~Base" \ + "Dump of assembler code for function.*Base.*" \ + "disassemble dtor in nested namespace" } do_tests diff --git a/gdb/valops.c b/gdb/valops.c index 27e84d9f6b3..59b8cf04fbf 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -3315,33 +3315,6 @@ classify_oload_match (const badness_vector &oload_champ_bv, return worst; } -/* C++: return 1 is NAME is a legitimate name for the destructor of - type TYPE. If TYPE does not have a destructor, or if NAME is - inappropriate for TYPE, an error is signaled. Parameter TYPE should not yet - have CHECK_TYPEDEF applied, this function will apply it itself. */ - -int -destructor_name_p (const char *name, struct type *type) -{ - if (name[0] == '~') - { - const char *dname = type_name_or_error (type); - const char *cp = strchr (dname, '<'); - unsigned int len; - - /* Do not compare the template part for template classes. */ - if (cp == NULL) - len = strlen (dname); - else - len = cp - dname; - if (strlen (name + 1) != len || strncmp (dname, name + 1, len) != 0) - error (_("name of destructor must equal name of class")); - else - return 1; - } - return 0; -} - /* Find an enum constant named NAME in TYPE. TYPE must be an "enum class". If the name is found, return a value representing it; otherwise throw an exception. */ diff --git a/gdb/value.h b/gdb/value.h index 7e1eec22413..4f2bf9d4c99 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -1062,8 +1062,6 @@ extern int binop_user_defined_p (enum exp_opcode op, struct value *arg1, extern int unop_user_defined_p (enum exp_opcode op, struct value *arg1); -extern int destructor_name_p (const char *name, struct type *type); - extern value_ref_ptr release_value (struct value *val); extern int record_latest_value (struct value *val); -- 2.37.2