From ffdbe8642e74527795b695988a176f0920d58f96 Mon Sep 17 00:00:00 2001 From: Yao Qi Date: Wed, 22 Mar 2017 12:35:31 +0000 Subject: Wrap locally used classes in anonymous namespace Both aarch64-tdep.c and arm-tdep.c defines a class instruction_reader, which violates ODR, but linker doesn't an emit error. I fix this issue by wrapping them by anonymous namespace, but I think it is better to apply this for all locally used classes. If it is a good idea to put locally used class into anonymous namespace, we should document this rule into GDB coding convention, or even GCC coding convention. Note that anonymous namespace has been used in GCC but GCC coding convention doesn't mention the it. gdb: 2017-03-22 Yao Qi * aarch64-tdep.c: Wrap locally used classes in anonymous namespace. * arm-tdep.c: Likewise. * linespec.c: Likewise. * ui-out.c: Likewise. --- gdb/linespec.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gdb/linespec.c') diff --git a/gdb/linespec.c b/gdb/linespec.c index 72bcd60..a3cb0cb 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -2793,6 +2793,8 @@ decode_objc (struct linespec_state *self, linespec_p ls, const char *arg) return values; } +namespace { + /* A function object that serves as symbol_found_callback_ftype callback for iterate_over_symbols. This is used by lookup_prefix_sym to collect type symbols. */ @@ -2859,6 +2861,8 @@ decode_compound_collector::operator () (symbol *sym) return true; /* Continue iterating. */ } +} // namespace + /* Return any symbols corresponding to CLASS_NAME in FILE_SYMTABS. */ static VEC (symbolp) * @@ -3095,6 +3099,8 @@ find_method (struct linespec_state *self, VEC (symtab_ptr) *file_symtabs, +namespace { + /* This function object is a callback for iterate_over_symtabs, used when collecting all matching symtabs. */ @@ -3148,6 +3154,8 @@ symtab_collector::operator () (struct symtab *symtab) return false; } +} // namespace + /* Given a file name, return a VEC of all matching symtabs. If SEARCH_PSPACE is not NULL, the search is restricted to just that program space. */ -- cgit v1.1