Hi, This bug is easily demonstrated: enum e { A, B } e; int main (void) { } (gdb) p e Attempt to use a type name as an expression This is happening because of the following commit: commit 5eeb2539423ce5e7241bce403f48b8babb3670b0 Author: Aleksandar Ristovski Date: Mon May 5 14:37:32 2008 +0000 * ada-lang.c: Update throughout to use symbol_matches_domain instead of matching the symbol domain explictly. * dwarf2read.c (add_partial_symbol): Do not add new psym for STRUCT_DOMAIN. Make sure you recognize c++ struct and java and ada class as typedefs. See lookup_partial_symbol function. (new_symbol): Similar to add_partial_symbol, do not create symbol for the typedef. See lookup_block_symbol. * symtab.c (symbol_matches_domain): New function, takes care of dual meaning of STRUCT_DOMAIN symbol for c++, ada and java. (lookup_partial_symbol): Use symbol_matches_domain to see if the found psym domain matches the given domain. (lookup_block_symbol): Likewise. That change attempted to address languages in which the tag name of an elaborated type also defines a type of the same name (e.g., "class A {};" -> "A object;". It did this by introducing a new function, symbol_matches_domain, which would allow STRUCT_DOMAIN symbol matches for VAR_DOMAIN searches in C++, Java, Ada, and D. That is the crux of the problem, though. When lookup_block_symbol starts searching for a match, it uses symbol_matches_domain to restrict the search to the given domain. As a result, it is a race between the VAR_DOMAIN and STRUCT_DOMAIN symbols -- whichever is found in the symbol table first is the symbol returned, obscurring the symbol in the other domain. I propose the following patch to address this issue. It involves some tweaks to lookup_symbol{,_in_language} and other symbol table API functions. The change isn't all that considerable, but this patch formalizes exactly what to expect from these functions. Summary: For those languages which define types of elaborated types (C++, Java, Ada, D), a lookup of a VAR_DOMAIN symbol will first search for a VAR_DOMAIN symbol. The function will fallback to a STRUCT_DOMAIN symbol only if that fails. For other languages, only the given domain will be searched. Additionally, lookup_block_symbol ONLY searches the given domain. In other words, lookup_symbol does "what you think it should." Or at least what *I* think it should. I have updated the comments/documentation preceding each (exported) lookup symbol function to explain exactly what to expect. I must also give a shout out to Joel -- I've largely avoided hacking with/at Ada. In fact, Ada *largely* remains unchanged. However, it now must explicitly search STRUCT_DOMAIN in a few places itself (an analogous change to the other symbol table API changes I've made). Joel, if you could run this through your internal AdaCore test harness, that would be most helpful. I've also had to tweak a few DWARF tests to set the language explicitly. This is because those tests are actually testing something c++-ish but not specifying the actual language. There are no regressions on native x86_64 linux and native-gdbserver. Keith ChangeLog 2014-03-20 Keith Seitz PR c++/16253 * ada-lang.c (ada_symbol_matches_domain): Moved here and renamed from symbol_matches_domain in symtab.c. All local callers of symbol_matches_domain updated. (standard_lookup): If DOMAIN is VAR_DOMAIN and no symbol is found, search STRUCT_DOMAIN. (ada_find_any_type_symbol): Do not search STRUCT_DOMAIN independently. standard_lookup will do that automatically. * ada-tasks.c (get_tcb_types_info): Search STRUCT_DOMAIN for types, not VAR_DOMAIN. * cp-namespace.c (cp_lookup_symbol_nonlocal): Explain when/why VAR_DOMAIN searches may return a STRUCT_DOMAIN match. (cp_lookup_symbol_in_namespace): Likewise. If no VAR_DOMAIN symbol is found, search STRUCT_DOMAIN. (cp_lookup_symbol_exports): Explain when/why VAR_DOMAIN searches may return a STRUCT_DOMAIN match. (lookup_symbol_file): Search for the class name in STRUCT_DOMAIN. * cp-support.c: Include language.h. (inspect_type): Explicitly search STRUCT_DOMAIN before searching VAR_DOMAIN. * psymtab.c (match_partial_symbol): Compare the requested domain with the symbol's domain directly. (lookup_partial_symbol): Likewise. * symtab.c (lookup_symbol_in_language): Explain when/why VAR_DOMAIN searches may return a STRUCT_DOMAIN match. If no VAR_DOMAIN symbol is found, search STRUCT_DOMAIN for appropriate languages. (symbol_matches_domain): Renamed `ada_symbol_matches_domain' and moved to ada-lang.c (lookup_block_symbol): Explain that this function only returns symbol matching the requested DOMAIN. Compare the requested domain with the symbol's domain directly. (iterate_over_symbols): Compare the requested domain with the symbol's domain directly. * symtab.h (symbol_matches_domain): Remove. testsuite/ChangeLog 2014-03-20 Keith Seitz PR c++/16253 * gdb.cp/var-tag.cc: New file. * gdb.cp/var-tag.exp: New file. * gdb.dwarf2/dw2-ada-ffffffff.exp: Set the language to C++. * gdb.dwarf2/dw2-anon-mptr.exp: Likewise. * gdb.dwarf2/dw2-double-set-die-type.exp: Likewise. * gdb.dwarf2/dw2-inheritance.exp: Likewise.