binutils-gdb/gdb/testsuite/gdb.fortran/array-element.exp
Bhuvanendra Kumar N abb894a470 gdb/fortran: Breakpoint location is modified.
Breakpoint location is modified to "return" statement which is
outside the DO loop. Because the label 100 of DO loop should get
executed for each iteration as shared in this external link:
http://www-pnp.physics.ox.ac.uk/~gronbech/intfor/node18.html.
flang compiler is following this fortran standard, whereas gfortran
compiler is not following, hence the test case is passing with
gfortran and failing with flang. but to correct this gfortran
behavior, bug has been filed in bugzilla
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99816). As reported in
the bug, with gfortran, label 100 of DO loop is reached only after
the completion of the entire DO loop. Hence at label 100, all the
array elements are set and printing of array element a(2) succeeds.
whereas with flang, when we are at label 100 for first time, array
element a(2) is not yet set, only a(1) is set, hence moving the
breakpoint location to outside the DO loop, so that once we are
outside the DO loop, we can print any of the array elements. This
change in test case is done irrespective of any fortran compiler.

gdb/testsuite/ChangeLog:
        * gdb.fortran/array-element.exp: Breakpoint location is modified.
2021-05-11 17:50:00 +05:30

40 lines
1.3 KiB
Plaintext

# Copyright 2005-2021 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This file was written by Wu Zhou. (woodzltc@cn.ibm.com)
# This file is part of the gdb testsuite. It contains test for printing
# the elements of an array which is passed as pointer to a subroutine.
if { [skip_fortran_tests] } { return -1 }
standard_testfile .f
if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
return -1
}
if ![runto sub_] then {
perror "couldn't run to breakpoint sub_"
continue
}
gdb_breakpoint [gdb_get_line_number "return"]
gdb_continue_to_breakpoint "return"
gdb_test "print a(1)" ".*1 = 1.*" "print the first element of array a"
gdb_test "print a(2)" ".*2 = 2.*" "print the second element of array a"