From patchwork Tue Nov 17 15:39:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 9705 Received: (qmail 45159 invoked by alias); 17 Nov 2015 15:39:16 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 45144 invoked by uid 89); 17 Nov 2015 15:39:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL, BAYES_00, KAM_STOCKGEN, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 17 Nov 2015 15:39:13 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 1E15842E5B4; Tue, 17 Nov 2015 15:39:12 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tAHFdALq029664; Tue, 17 Nov 2015 10:39:11 -0500 Message-ID: <564B4A1E.3060803@redhat.com> Date: Tue, 17 Nov 2015 15:39:10 +0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Simon Marchi , gdb-patches@sourceware.org Subject: Re: [PATCH] Fix C++ build errors on OpenBSD References: <1447689865-25969-1-git-send-email-simon.marchi@ericsson.com> <564B2ABB.4070803@redhat.com> <564B398C.2090802@ericsson.com> In-Reply-To: <564B398C.2090802@ericsson.com> On 11/17/2015 02:28 PM, Simon Marchi wrote: > Yes, this looks much better. Will you push it yourself? > Done, like below. Thanks. From: Pedro Alves Subject: [PATCH] Introduce null_block_symbol ... in the spirit of null_ptid, null_frame_id, etc. Fixes two instances of: /root/binutils-gdb/gdb/cp-namespace.c: In function 'block_symbol cp_lookup_nested_symbol(type*, const char*, const block*, domain_enum)': /root/binutils-gdb/gdb/cp-namespace.c:1010: warning: jump to case label /root/binutils-gdb/gdb/cp-namespace.c:1008: error: crosses initialization of 'block_symbol ' Compiler info: Reading specs from /usr/lib/gcc-lib/amd64-unknown-openbsd5.8/4.2.1/specs Target: amd64-unknown-openbsd5.8 Configured with: OpenBSD/amd64 system compiler Thread model: posix gcc version 4.2.1 20070719 gdb/ChangeLog: 2015-11-17 Pedro Alves * cp-namespace.c (cp_lookup_bare_symbol) (cp_search_static_and_baseclasses, cp_lookup_symbol_via_imports) (cp_lookup_symbol_via_all_imports, cp_lookup_nested_symbol_1) (cp_lookup_nested_symbol): Use null_block_symbol. * d-namespace.c (d_lookup_symbol, d_lookup_nested_symbol) (d_lookup_symbol_imports, d_lookup_symbol_module): Use null_block_symbol. * symtab.c (null_block_symbol): New global. * symtab.h (null_block_symbol): Declare. --- gdb/ChangeLog | 12 ++++++++++++ gdb/cp-namespace.c | 14 +++++++------- gdb/d-namespace.c | 10 +++++----- gdb/symtab.c | 3 +++ gdb/symtab.h | 4 ++++ 5 files changed, 31 insertions(+), 12 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 57451bc..1dc2ab0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,17 @@ 2015-11-17 Pedro Alves + * cp-namespace.c (cp_lookup_bare_symbol) + (cp_search_static_and_baseclasses, cp_lookup_symbol_via_imports) + (cp_lookup_symbol_via_all_imports, cp_lookup_nested_symbol_1) + (cp_lookup_nested_symbol): Use null_block_symbol. + * d-namespace.c (d_lookup_symbol, d_lookup_nested_symbol) + (d_lookup_symbol_imports, d_lookup_symbol_module): Use + null_block_symbol. + * symtab.c (null_block_symbol): New global. + * symtab.h (null_block_symbol): Declare. + +2015-11-17 Pedro Alves + * common/common-exceptions.h (GDB_XCPT_SJMP, GDB_XCPT_TRY) (GDB_XCPT_RAW_TRY, GDB_XCPT): Define. Replace __cplusplus checks with GDB_XCPT checks throughout. diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c index 989544b..6890001 100644 --- a/gdb/cp-namespace.c +++ b/gdb/cp-namespace.c @@ -208,14 +208,14 @@ cp_lookup_bare_symbol (const struct language_defn *langdef, lang_this = lookup_language_this (language_def (language_cplus), block); if (lang_this.symbol == NULL) - return (struct block_symbol) {NULL, NULL}; + return null_block_symbol; type = check_typedef (TYPE_TARGET_TYPE (SYMBOL_TYPE (lang_this.symbol))); /* If TYPE_NAME is NULL, abandon trying to find this symbol. This can happen for lambda functions compiled with clang++, which outputs no name for the container class. */ if (TYPE_NAME (type) == NULL) - return (struct block_symbol) {NULL, NULL}; + return null_block_symbol; /* Look for symbol NAME in this class. */ sym = cp_lookup_nested_symbol (type, name, block, domain); @@ -273,7 +273,7 @@ cp_search_static_and_baseclasses (const char *name, if (klass_sym.symbol == NULL) { do_cleanups (cleanup); - return (struct block_symbol) {NULL, NULL}; + return null_block_symbol; } klass_type = SYMBOL_TYPE (klass_sym.symbol); @@ -492,7 +492,7 @@ cp_lookup_symbol_via_imports (const char *scope, } } - return (struct block_symbol) {NULL, NULL}; + return null_block_symbol; } /* Helper function that searches an array of symbols for one named NAME. */ @@ -640,7 +640,7 @@ cp_lookup_symbol_via_all_imports (const char *scope, const char *name, block = BLOCK_SUPERBLOCK (block); } - return (struct block_symbol) {NULL, NULL}; + return null_block_symbol; } /* Searches for NAME in the current namespace, and by applying @@ -928,7 +928,7 @@ cp_lookup_nested_symbol_1 (struct type *container_type, return sym; } - return (struct block_symbol) {NULL, NULL}; + return null_block_symbol; } /* Look up a symbol named NESTED_NAME that is nested inside the C++ @@ -1005,7 +1005,7 @@ cp_lookup_nested_symbol (struct type *parent_type, "cp_lookup_nested_symbol (...) = NULL" " (func/method)\n"); } - return (struct block_symbol) {NULL, NULL}; + return null_block_symbol; default: internal_error (__FILE__, __LINE__, diff --git a/gdb/d-namespace.c b/gdb/d-namespace.c index e8f4c6f..170bddc 100644 --- a/gdb/d-namespace.c +++ b/gdb/d-namespace.c @@ -132,7 +132,7 @@ d_lookup_symbol (const struct language_defn *langdef, if (lang_this.symbol == NULL) { do_cleanups (cleanup); - return (struct block_symbol) {NULL, NULL}; + return null_block_symbol; } type = check_typedef (TYPE_TARGET_TYPE (SYMBOL_TYPE (lang_this.symbol))); @@ -159,7 +159,7 @@ d_lookup_symbol (const struct language_defn *langdef, if (class_sym.symbol == NULL) { do_cleanups (cleanup); - return (struct block_symbol) {NULL, NULL}; + return null_block_symbol; } /* Look for a symbol named NESTED in this class. */ @@ -370,7 +370,7 @@ d_lookup_nested_symbol (struct type *parent_type, case TYPE_CODE_FUNC: case TYPE_CODE_METHOD: - return (struct block_symbol) {NULL, NULL}; + return null_block_symbol; default: gdb_assert_not_reached ("called with non-aggregate type."); @@ -530,7 +530,7 @@ d_lookup_symbol_imports (const char *scope, const char *name, } } - return (struct block_symbol) {NULL, NULL}; + return null_block_symbol; } /* Searches for NAME in the current module, and by applying relevant @@ -562,7 +562,7 @@ d_lookup_symbol_module (const char *scope, const char *name, block = BLOCK_SUPERBLOCK (block); } - return (struct block_symbol) {NULL, NULL}; + return null_block_symbol; } /* The D-specific version of name lookup for static and global names diff --git a/gdb/symtab.c b/gdb/symtab.c index 16190c4..c42f5b6 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -85,6 +85,9 @@ static struct block_symbol lookup_symbol_in_objfile (struct objfile *objfile, int block_index, const char *name, const domain_enum domain); +/* See symtab.h. */ +const struct block_symbol null_block_symbol = { NULL, NULL }; + extern initialize_file_ftype _initialize_symtab; /* Program space key for finding name and language of "main". */ diff --git a/gdb/symtab.h b/gdb/symtab.h index 27b27c8..37c8c93 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -832,6 +832,10 @@ struct block_symbol extern const struct symbol_impl *symbol_impls; +/* For convenience. All fields are NULL. This means "there is no + symbol". */ +extern const struct block_symbol null_block_symbol; + /* Note: There is no accessor macro for symbol.owner because it is "private". */