diff options
Diffstat (limited to 'gdb/testsuite/gdb.cp')
-rw-r--r-- | gdb/testsuite/gdb.cp/namespace.exp | 68 | ||||
-rw-r--r-- | gdb/testsuite/gdb.cp/namespace1.cc | 15 |
2 files changed, 81 insertions, 2 deletions
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 { |