enum_idx_packed.exp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. # Copyright 2012-2022 Free Software Foundation, Inc.
  2. #
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; either version 3 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. load_lib "ada.exp"
  16. if { [skip_ada_tests] } { return -1 }
  17. standard_ada_testfile foo
  18. foreach_with_prefix scenario {all minimal} {
  19. set flags [list debug additional_flags=-fgnat-encodings=$scenario]
  20. if {[gdb_compile_ada "${srcfile}" "${binfile}" executable $flags] != ""} {
  21. return -1
  22. }
  23. clean_restart ${testfile}
  24. # GNAT 9 and 10 are known to fail.
  25. if {$scenario == "minimal" && ([test_compiler_info {gcc-9-*}] \
  26. || [test_compiler_info {gcc-10-*}])} {
  27. set old_compiler 1
  28. } else {
  29. set old_compiler 0
  30. }
  31. set bp_location [gdb_get_line_number "STOP" ${testdir}/foo.adb]
  32. runto "foo.adb:$bp_location"
  33. gdb_test "ptype full" \
  34. "type = array \\(black \\.\\. white\\) of boolean <packed: 1-bit elements>"
  35. gdb_test "print full" " = \\(false, true, false, true, false\\)"
  36. gdb_test "print full'first" " = black"
  37. gdb_test "ptype primary" \
  38. "type = array \\(red \\.\\. blue\\) of boolean <packed: 1-bit elements>"
  39. gdb_test "print primary" " = \\(red => false, true, false\\)"
  40. gdb_test "print primary'first" " = red"
  41. gdb_test "ptype cold" \
  42. "type = array \\(green \\.\\. blue\\) of boolean <packed: 1-bit elements>"
  43. gdb_test "print cold" " = \\(green => false, true\\)"
  44. gdb_test "print cold'first" " = green"
  45. # Note the bounds values are still not correctly displayed. So we get
  46. # the enum equivalent of "1 .. 0" (empty range) as the array ranges.
  47. # Accept that for now.
  48. # GNAT >= 11.0 has the needed fix here.
  49. if {$old_compiler} {
  50. setup_kfail "minimal encodings" *-*-*
  51. }
  52. gdb_test "ptype small" \
  53. "array \\(red \\.\\. green\\) of boolean <packed: 1-bit elements>"
  54. if {$old_compiler} {
  55. setup_kfail "minimal encodings" *-*-*
  56. }
  57. gdb_test "print small" " = \\(red => false, true\\)"
  58. if {$old_compiler} {
  59. setup_kfail "minimal encodings" *-*-*
  60. }
  61. gdb_test "print small'first" " = red"
  62. if {$old_compiler} {
  63. setup_kfail "minimal encodings" *-*-*
  64. }
  65. gdb_test "ptype multi" \
  66. "array \\(red \\.\\. green, low .. medium\\) of boolean <packed: 1-bit elements>"
  67. if {$old_compiler} {
  68. setup_kfail "minimal encodings" *-*-*
  69. }
  70. gdb_test "print multi" \
  71. " = \\(red => \\(low => true, false\\), \\(low => true, false\\)\\)"
  72. if {$old_compiler} {
  73. setup_kfail "minimal encodings" *-*-*
  74. }
  75. gdb_test "print multi'first" " = red"
  76. set base "\\(true, false, true, false, true, false, true, false, true, false\\)"
  77. set matrix "\\("
  78. foreach x {1 2 3 4 5 6 7} {
  79. if {$x > 1} {
  80. append matrix ", "
  81. }
  82. append matrix $base
  83. }
  84. append matrix "\\)"
  85. if {$old_compiler} {
  86. setup_kfail "minimal encodings" *-*-*
  87. }
  88. gdb_test "print multi_multi" " = \\($matrix, $matrix\\)"
  89. if {$old_compiler} {
  90. setup_kfail "minimal encodings" *-*-*
  91. }
  92. gdb_test "print multi_multi(1,3)" " = $base"
  93. if {$old_compiler} {
  94. setup_kfail "minimal encodings" *-*-*
  95. }
  96. gdb_test "print multi_multi(2)" " = $matrix"
  97. gdb_test "print multi_access.all" \
  98. " = \\(\\(8, 13, 21, 34, 55\\), \\(1, 1, 2, 3, 5\\)\\)"
  99. gdb_test "print confused_array(red, green)" " = 2"
  100. gdb_test "print confused_array(green, red)" " = 6"
  101. }