From: Sami Wagiaalla Date: Mon, 7 Jun 2010 17:51:03 +0000 (+0000) Subject: Fix operator doubly nested namespace search. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=245040d756e6e32bb26e82597834ea6aa1546da8;p=binutils-gdb.git Fix operator doubly nested namespace search. 2010-06-07 Sami Wagiaalla * cp-support.c (make_symbol_overload_list_namespace): Only search static and global blocks. (make_symbol_overload_list_block): New function. (make_symbol_overload_list): Separate namespace search from block search. (make_symbol_overload_list_qualified): Use make_symbol_overload_list_block. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 78d3199ff59..9544c617feb 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +2010-06-07 Sami Wagiaalla + + * cp-support.c (make_symbol_overload_list_namespace): Only search + static and global blocks. + (make_symbol_overload_list_block): New function. + (make_symbol_overload_list): Separate namespace search from block + search. + (make_symbol_overload_list_qualified): Use + make_symbol_overload_list_block. + 2010-06-07 Sami Wagiaalla * value.h: Created oload_search_type enum. diff --git a/gdb/cp-support.c b/gdb/cp-support.c index d9a59f31e32..41af7ae0f07 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -693,6 +693,7 @@ make_symbol_overload_list (const char *func_name, const char *namespace) { struct cleanup *old_cleanups; + const char *name; sym_return_val_size = 100; sym_return_val_index = 0; @@ -704,19 +705,54 @@ make_symbol_overload_list (const char *func_name, make_symbol_overload_list_using (func_name, namespace); + if (namespace[0] == '\0') + name = func_name; + else + { + char *concatenated_name + = alloca (strlen (namespace) + 2 + strlen (func_name) + 1); + strcpy (concatenated_name, namespace); + strcat (concatenated_name, "::"); + strcat (concatenated_name, func_name); + name = concatenated_name; + } + + make_symbol_overload_list_qualified (name); + discard_cleanups (old_cleanups); return sym_return_val; } +/* Add all symbols with a name matching NAME in BLOCK to the overload + list. */ + +static void +make_symbol_overload_list_block (const char *name, + const struct block *block) +{ + struct dict_iterator iter; + struct symbol *sym; + + const struct dictionary *dict = BLOCK_DICT (block); + + for (sym = dict_iter_name_first (dict, name, &iter); + sym != NULL; + sym = dict_iter_name_next (name, &iter)) + overload_list_add_symbol (sym, name); +} + /* Adds the function FUNC_NAME from NAMESPACE to the overload set. */ static void make_symbol_overload_list_namespace (const char *func_name, const char *namespace) { + const char *name; + const struct block *block = NULL; + if (namespace[0] == '\0') - make_symbol_overload_list_qualified (func_name); + name = func_name; else { char *concatenated_name @@ -725,8 +761,17 @@ make_symbol_overload_list_namespace (const char *func_name, strcpy (concatenated_name, namespace); strcat (concatenated_name, "::"); strcat (concatenated_name, func_name); - make_symbol_overload_list_qualified (concatenated_name); + name = concatenated_name; } + + /* Look in the static block. */ + block = block_static_block (get_selected_block (0)); + make_symbol_overload_list_block (name, block); + + /* Look in the global block. */ + block = block_global_block (block); + make_symbol_overload_list_block (name, block); + } /* Search the namespace of the given type and namespace of and public base @@ -855,16 +900,7 @@ make_symbol_overload_list_qualified (const char *func_name) complete on local vars. */ for (b = get_selected_block (0); b != NULL; b = BLOCK_SUPERBLOCK (b)) - { - dict = BLOCK_DICT (b); - - for (sym = dict_iter_name_first (dict, func_name, &iter); - sym; - sym = dict_iter_name_next (func_name, &iter)) - { - overload_list_add_symbol (sym, func_name); - } - } + make_symbol_overload_list_block (func_name, b); surrounding_static_block = block_static_block (get_selected_block (0)); @@ -875,14 +911,7 @@ make_symbol_overload_list_qualified (const char *func_name) { QUIT; b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK); - dict = BLOCK_DICT (b); - - for (sym = dict_iter_name_first (dict, func_name, &iter); - sym; - sym = dict_iter_name_next (func_name, &iter)) - { - overload_list_add_symbol (sym, func_name); - } + make_symbol_overload_list_block (func_name, b); } ALL_PRIMARY_SYMTABS (objfile, s) @@ -892,14 +921,7 @@ make_symbol_overload_list_qualified (const char *func_name) /* Don't do this block twice. */ if (b == surrounding_static_block) continue; - dict = BLOCK_DICT (b); - - for (sym = dict_iter_name_first (dict, func_name, &iter); - sym; - sym = dict_iter_name_next (func_name, &iter)) - { - overload_list_add_symbol (sym, func_name); - } + make_symbol_overload_list_block (func_name, b); } }