diff options
author | Jan Kratochvil <jan.kratochvil@redhat.com> | 2010-06-28 20:35:52 +0000 |
---|---|---|
committer | Jan Kratochvil <jan.kratochvil@redhat.com> | 2010-06-28 20:35:52 +0000 |
commit | 41f62f3939b1c69e68ef5652feb44fef90eb85c9 (patch) | |
tree | b3af0713fd6e2bc24b1554eaaab7c5716ea903f9 /gdb/testsuite | |
parent | af53d23161e42735bc2adbb8236d411a307b574c (diff) | |
download | gdb-41f62f3939b1c69e68ef5652feb44fef90eb85c9.zip gdb-41f62f3939b1c69e68ef5652feb44fef90eb85c9.tar.gz gdb-41f62f3939b1c69e68ef5652feb44fef90eb85c9.tar.bz2 |
gdb/
* cp-namespace.c (cp_lookup_nested_type): New variable
concatenated_name. Turn the current return condition into a reverse
one. Call also lookup_static_symbol_aux on the constructed qualified
name.
* symtab.c (lookup_symbol_aux): Move variable objfile and searching in
other files into a called ...
(lookup_static_symbol_aux): ... new function here.
* symtab.h (lookup_static_symbol_aux): New prototype.
* valops.c (value_maybe_namespace_elt): Call also
lookup_static_symbol_aux if we failed otherwise.
gdb/testsuite/
* gdb.cp/namespace.exp (whatis C::cOtherFileType)
(whatis ::C::cOtherFileType, whatis C::cOtherFileVar)
(whatis ::C::cOtherFileVar, print C::cOtherFileVar)
(print ::C::cOtherFileVar)
(whatis C::OtherFileClass::cOtherFileClassType)
(whatis ::C::OtherFileClass::cOtherFileClassType)
(print C::OtherFileClass::cOtherFileClassVar)
(print ::cOtherFileClassVar)
(print ::C::OtherFileClass::cOtherFileClassVar): New tests.
(ptype OtherFileClass, ptype ::C::OtherFileClass): Permit arbitrary
trailing content.
* gdb.cp/namespace1.cc (C::OtherFileClass::cOtherFileClassType)
(C::OtherFileClass::cOtherFileClassVar)
(C::OtherFileClass::cOtherFileClassVar_use, C::cOtherFileType)
(C::cOtherFileVar, C::cOtherFileVar_use): New.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 18 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/namespace.exp | 68 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/namespace1.cc | 15 |
3 files changed, 99 insertions, 2 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 05a5131..9f89500 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,23 @@ 2010-06-28 Jan Kratochvil <jan.kratochvil@redhat.com> + * gdb.cp/namespace.exp (whatis C::cOtherFileType) + (whatis ::C::cOtherFileType, whatis C::cOtherFileVar) + (whatis ::C::cOtherFileVar, print C::cOtherFileVar) + (print ::C::cOtherFileVar) + (whatis C::OtherFileClass::cOtherFileClassType) + (whatis ::C::OtherFileClass::cOtherFileClassType) + (print C::OtherFileClass::cOtherFileClassVar) + (print ::cOtherFileClassVar) + (print ::C::OtherFileClass::cOtherFileClassVar): New tests. + (ptype OtherFileClass, ptype ::C::OtherFileClass): Permit arbitrary + trailing content. + * gdb.cp/namespace1.cc (C::OtherFileClass::cOtherFileClassType) + (C::OtherFileClass::cOtherFileClassVar) + (C::OtherFileClass::cOtherFileClassVar_use, C::cOtherFileType) + (C::cOtherFileVar, C::cOtherFileVar_use): New. + +2010-06-28 Jan Kratochvil <jan.kratochvil@redhat.com> + Test PR c++/11703 and PR gdb/1448. * gdb.cp/namespace.exp (ptype ::C::NestedClass): Remove KFAIL for gdb/1448. diff --git a/gdb/testsuite/gdb.cp/namespace.exp b/gdb/testsuite/gdb.cp/namespace.exp index 95038fd..452dcdc 100644 --- a/gdb/testsuite/gdb.cp/namespace.exp +++ b/gdb/testsuite/gdb.cp/namespace.exp @@ -165,6 +165,70 @@ gdb_test "print BBB::Class::xyzq" \ gdb_test "break BBB::Class::xyzq" \ "Breakpoint.*at $hex: file.*namespace.cc, line 68\\." +# Tests accessing static elements in namespace of other file. + +gdb_test "whatis C::cOtherFileType" "type = short" +gdb_test "whatis ::C::cOtherFileType" "type = short" +gdb_test "whatis C::cOtherFileVar" "type = const C::cOtherFileType" +gdb_test "whatis ::C::cOtherFileVar" "type = const C::cOtherFileType" +gdb_test "print C::cOtherFileVar" "\\$\[0-9\].* = 319" +gdb_test "print ::C::cOtherFileVar" "\\$\[0-9\].* = 319" + +if {[test_compiler_info {gcc-[0-3]-*}] + || [test_compiler_info {gcc-4-[0-4]-*}]} { + # The type in class is missing in older GCCs. + setup_xfail *-*-* +} +gdb_test "whatis C::OtherFileClass::cOtherFileClassType" "type = short" +if {[test_compiler_info {gcc-[0-3]-*}] + || [test_compiler_info {gcc-4-[0-4]-*}]} { + # The type in class is missing in older GCCs. + setup_xfail *-*-* +} +gdb_test "whatis ::C::OtherFileClass::cOtherFileClassType" "type = short" + +set test "print C::OtherFileClass::cOtherFileClassVar" +gdb_test_multiple $test $test { + -re "\\$\[0-9\].* = 318\r\n$gdb_prompt $" { + pass $test + } + -re "static field cOtherFileClassVar has been optimized out\r\n$gdb_prompt $" { + setup_kfail "c++/11702" "*-*-*" + fail $test + } +} + +# FSF GCC <=4.4 creates unqualified DIE "cOtherFileClassVar" ignoring the +# namespace the same way older GDB did. +set test "print ::cOtherFileClassVar" +set test2 "print ::C::OtherFileClass::cOtherFileClassVar" +gdb_test_multiple $test $test { + -re "No symbol \"cOtherFileClassVar\" in current context\\.\r\n$gdb_prompt $" { + pass $test + + gdb_test_multiple $test2 $test2 { + -re "\\$\[0-9\].* = 318\r\n$gdb_prompt $" { + pass $test2 + } + -re "static field cOtherFileClassVar has been optimized out\r\n$gdb_prompt $" { + setup_kfail "c++/11702" "*-*-*" + fail $test2 + } + } + + } + -re "\\$\[0-9\].* = 318\r\n$gdb_prompt $" { + if {[test_compiler_info {gcc-[0-3]-*}] + || [test_compiler_info {gcc-4-[0-4]-*}]} { + # Do not permit to XFAIL on recent GCCs. + setup_xfail *-*-* + } + fail $test + + unresolved $test2 + } +} + # Test to see if the appropriate namespaces are in scope when trying # to print out stuff from within a function defined within a # namespace. @@ -200,8 +264,8 @@ gdb_test "ptype C::NestedClass" "No symbol \"NestedClass\" in namespace \"C::C\" # Tests involving multiple files gdb_test "print cOtherFile" "\\$\[0-9\].* = 316" -gdb_test "ptype OtherFileClass" "type = (class C::OtherFileClass \{\r\n public:|struct C::OtherFileClass \{)\r\n int z;\r\n\}" -gdb_test "ptype ::C::OtherFileClass" "type = class C::OtherFileClass \{\r\n public:\r\n int z;\r\n\}" +gdb_test "ptype OtherFileClass" "type = (class C::OtherFileClass \{\r\n public:|struct C::OtherFileClass \{)\r\n int z;\r\n.*\}" +gdb_test "ptype ::C::OtherFileClass" "type = class C::OtherFileClass \{\r\n public:\r\n int z;\r\n.*\}" gdb_test "ptype C::OtherFileClass" "No symbol \"OtherFileClass\" in namespace \"C::C\"." # Some anonymous namespace tests. diff --git a/gdb/testsuite/gdb.cp/namespace1.cc b/gdb/testsuite/gdb.cp/namespace1.cc index af0ec29..928e357 100644 --- a/gdb/testsuite/gdb.cp/namespace1.cc +++ b/gdb/testsuite/gdb.cp/namespace1.cc @@ -21,7 +21,15 @@ namespace C class OtherFileClass { public: int z; + + typedef short cOtherFileClassType; + static const cOtherFileClassType cOtherFileClassVar = 318; + cOtherFileClassType cOtherFileClassVar_use (); }; + OtherFileClass::cOtherFileClassType OtherFileClass::cOtherFileClassVar_use () + { + return cOtherFileClassVar; + } namespace { int cXOtherFile = 29; @@ -35,6 +43,13 @@ namespace C static OtherFileClass *c = new OtherFileClass(); c->z = cOtherFile + cXOtherFile; } + + typedef short cOtherFileType; + static const cOtherFileType cOtherFileVar = 319; + cOtherFileType cOtherFileVar_use () + { + return cOtherFileVar; + } } namespace { |