case DW_TAG_enumeration_type:
/* Skip aggregate types without children, these are external
references. */
+ /* NOTE: carlton/2002-11-29: See comment in new_symbol about
+ static vs. global. */
if (pdi->has_children == 0)
return;
add_psymbol_to_list (actual_name, strlen (actual_name),
STRUCT_NAMESPACE, LOC_TYPEDEF,
- &objfile->static_psymbols,
+ &objfile->global_psymbols,
0, (CORE_ADDR) 0, cu_language, objfile);
if (cu_language == language_cplus)
/* For C++, these implicitly act as typedefs as well. */
add_psymbol_to_list (actual_name, strlen (actual_name),
VAR_NAMESPACE, LOC_TYPEDEF,
- &objfile->static_psymbols,
+ &objfile->global_psymbols,
0, (CORE_ADDR) 0, cu_language, objfile);
}
break;
case DW_TAG_enumerator:
add_psymbol_to_list (actual_name, strlen (actual_name),
VAR_NAMESPACE, LOC_CONST,
- &objfile->static_psymbols,
+ &objfile->global_psymbols,
0, (CORE_ADDR) 0, cu_language, objfile);
break;
default:
gdb_assert (SYMBOL_DEMANGLED_NAME (sym) == NULL);
}
}
-
- add_symbol_to_list (sym, list_in_scope);
- /* The semantics of C++ state that "struct foo { ... }" also
- defines a typedef for "foo". Synthesize a typedef symbol so
- that "ptype foo" works as expected. */
- if (cu_language == language_cplus)
- {
- struct symbol *typedef_sym = (struct symbol *)
- obstack_alloc (&objfile->symbol_obstack,
- sizeof (struct symbol));
- *typedef_sym = *sym;
- SYMBOL_NAMESPACE (typedef_sym) = VAR_NAMESPACE;
- if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0)
- TYPE_NAME (SYMBOL_TYPE (sym)) =
- obsavestring (SYMBOL_NAME (sym),
- strlen (SYMBOL_NAME (sym)),
- &objfile->type_obstack);
- add_symbol_to_list (typedef_sym, list_in_scope);
- }
+ {
+ /* NOTE: carlton/2002-11-29: Class symbols shouldn't
+ really ever be static objects: otherwise, if you try
+ to, say, break of a class's method and you're in a file
+ which doesn't mention that class, it won't work unless
+ the check for all static symbols in lookup_symbol_aux
+ saves you. Though perhaps C allows different files to
+ define different structs with the same name; if so,
+ this should be conditional on C++. See the
+ OtherFileClass tests in gdb.c++/namespace.exp. */
+
+ struct pending **list_to_add;
+
+ list_to_add = (list_in_scope == &file_symbols
+ ? &global_symbols : list_in_scope);
+
+ add_symbol_to_list (sym, list_to_add);
+
+ /* The semantics of C++ state that "struct foo { ... }" also
+ defines a typedef for "foo". Synthesize a typedef symbol so
+ that "ptype foo" works as expected. */
+ if (cu_language == language_cplus)
+ {
+ struct symbol *typedef_sym = (struct symbol *)
+ obstack_alloc (&objfile->symbol_obstack,
+ sizeof (struct symbol));
+ *typedef_sym = *sym;
+ SYMBOL_NAMESPACE (typedef_sym) = VAR_NAMESPACE;
+ if (TYPE_NAME (SYMBOL_TYPE (sym)) == 0)
+ TYPE_NAME (SYMBOL_TYPE (sym)) =
+ obsavestring (SYMBOL_NAME (sym),
+ strlen (SYMBOL_NAME (sym)),
+ &objfile->type_obstack);
+ add_symbol_to_list (typedef_sym, list_to_add);
+ }
+ }
break;
case DW_TAG_typedef:
if (processing_has_namespace_info
{
dwarf2_const_value (attr, sym, objfile, cu_header);
}
- add_symbol_to_list (sym, list_in_scope);
+ {
+ /* NOTE: carlton/2002-11-29: See comment above in the
+ DW_TAG_class_type, etc. block. */
+
+ struct pending **list_to_add;
+
+ list_to_add = (list_in_scope == &file_symbols
+ ? &global_symbols : list_in_scope);
+
+ add_symbol_to_list (sym, list_to_add);
+ }
break;
default:
/* Not a tag we recognize. Hopefully we aren't processing
set testfile "namespace"
set srcfile ${testfile}.cc
+set srcfile1 ${testfile}1.cc
set binfile ${objdir}/${subdir}/${testfile}
if [get_compiler_info ${binfile}] {
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${srcdir}/${subdir}/${srcfile1}" "${binfile}" executable {debug c++}] != "" } {
gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will a
utomatically fail."
}
gdb_test "ptype CClass" "type = class C::CClass \{\r\n public:\r\n int x;\r\n\}" "ptype CClass"
gdb_test "ptype CClass::NestedClass" "type = class C::CClass::NestedClass \{\r\n public:\r\n int y;\r\n\}" "ptype CClass::NestedClass"
gdb_test "ptype NestedClass" "No symbol \"NestedClass\" in current context." "ptype NestedClass"
-gdb_test "ptype ::C::CClass" "type = class C::CClass \{\r\n public:\r\n inty;\r\n\}" "ptype ::C::CClass"
+gdb_test "ptype ::C::CClass" "type = class C::CClass \{\r\n public:\r\n int x;\r\n\}" "ptype ::C::CClass"
gdb_test "ptype ::C::CClass::NestedClass" "type = class C::CClass::NestedClass \{\r\n public:\r\n int y;\r\n\}" "ptype ::C::CClass::NestedClass"
gdb_test "ptype ::C::NestedClass" "No symbol \"NestedClass\" in namespace \"C\"." "ptype ::C::NestedClass"
gdb_test "ptype C::CClass" "No symbol \"Class\" in namespace \"C::C\"" "ptype C::CClass"
gdb_test "ptype C::CClass::NestedClass" "No symbol \"Class\" in namespace \"C::C\"" "ptype C::CClass::NestedClass"
gdb_test "ptype C::NestedClass" "No symbol \"NestedClass\" in namespace \"C::C\"." "ptype C::NestedClass"
+# Tests involving multiple files
+
+gdb_test "ptype OtherFileClass" "type = class C::OtherFileClass \{\r\n public:\r\n int z;\r\n\}" "ptype OtherFileClass"
+gdb_test "ptype ::C::OtherFileClass" "type = class C::OtherFileClass \{\r\n public:\r\n int z;\r\n\}" "ptype ::C::OtherFileClass"
+gdb_test "ptype C::OtherFileClass" "No symbol \"Class\" in namespace \"C::C\"" "ptype C::OtherFileClass"
+
# Some anonymous namespace tests.
gdb_test "print cX" "\\$\[0-9\].* = 6" "print cX"