]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Introduce null_block_symbol
authorPedro Alves <palves@redhat.com>
Tue, 17 Nov 2015 13:12:23 +0000 (13:12 +0000)
committerPedro Alves <palves@redhat.com>
Tue, 17 Nov 2015 15:30:33 +0000 (15:30 +0000)
... 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 <anonymous>'

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  <palves@redhat.com>

* 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
gdb/cp-namespace.c
gdb/d-namespace.c
gdb/symtab.c
gdb/symtab.h

index 57451bcdab6da48071060e67ddd5183758875139..1dc2ab0cba699b8d87281c872ea920e0a75214d9 100644 (file)
@@ -1,3 +1,15 @@
+2015-11-17  Pedro Alves  <palves@redhat.com>
+
+       * 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  <palves@redhat.com>
 
        * common/common-exceptions.h (GDB_XCPT_SJMP, GDB_XCPT_TRY)
index 989544be0c8b7bbd7f4224540c14721376abf4b6..6890001b9b41651e8cf19284f4a13cbca5adb7d1 100644 (file)
@@ -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__,
index e8f4c6f64f1ad1e0229fd0519876810669021025..170bddc17697313f25dd7f19da26c9027f85eaa5 100644 (file)
@@ -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
index 16190c49394f7ce517012dd8043c1b8e0f7f72de..c42f5b6cbdf0b617a4cdabbf378c020e2bbb00be 100644 (file)
@@ -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".  */
index 27b27c8a2dae363334d8b38500aec67059fe8f34..37c8c937e676c8e8f92bd8c5d92c2cd94849a8a6 100644 (file)
@@ -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".  */