1# Copyright 2011-2023 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 16# This file is part of the gdb testsuite. It contains tests for evaluating 17# Fortran subarray expression. 18 19if { [skip_fortran_tests] } { return -1 } 20 21standard_testfile .f90 22load_lib "fortran.exp" 23 24if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} {debug f90}] } { 25 return -1 26} 27 28if ![fortran_runto_main] { 29 return 30} 31 32# Depending on the compiler being used, the type names can be printed differently. 33set int [fortran_int4] 34 35gdb_breakpoint [gdb_get_line_number "break-static"] 36gdb_continue_to_breakpoint "break-static" ".*break-static.*" 37 38gdb_test "print foo(2,3,4)" \ 39 " = 20" \ 40 "print valid static array element" 41 42gdb_test "print foo(0,0,0)" \ 43 "no such vector element" \ 44 "print an invalid array index (0,0,0)" 45 46gdb_test "print foo(2,3,5)" \ 47 "no such vector element" \ 48 "print an invalid array index (2,3,5)" 49 50gdb_test "print foo(2,4,4)" \ 51 "no such vector element" \ 52 "print an invalid array index (2,4,4)" 53 54gdb_test "print foo(3,3,4)" \ 55 "no such vector element" \ 56 "print an invalid array index (3,3,4)" 57 58gdb_test "print foo" \ 59 { = \(\(\(10, 10\) \(10, 10\) \(10, 10\)\) \(\(10, 10\) \(10, 10\) \(10, 10\)\) \(\(10, 10\) \(10, 10\) \(10, 10\)\) \(\(10, 10\) \(10, 10\) \(10, 20\)\)\)} \ 60 "print full contents of the array" 61 62gdb_breakpoint [gdb_get_line_number "break-variable"] 63gdb_continue_to_breakpoint "break-variable" ".*break-variable.*" 64 65gdb_test "print varbound(4)" \ 66 " = 2" \ 67 "print valid variable bound array element" 68 69gdb_test "ptype unbound" \ 70 "type = $int \\(\\*\\)" \ 71 "print type of unbound array" 72 73gdb_test "print unbound(4)" \ 74 " = 2" \ 75 "print valid unbound array element" 76