From abb894a4703ddf1d2f4b9c103d63f911c017e26a Mon Sep 17 00:00:00 2001 From: Bhuvanendra Kumar N Date: Tue, 11 May 2021 17:26:46 +0530 Subject: [PATCH] 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. --- gdb/testsuite/ChangeLog | 4 ++++ gdb/testsuite/gdb.fortran/array-element.exp | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index c188719cd57..ee963ee6ab2 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2021-05-11 Bhuvanendra Kumar + + * gdb.fortran/array-element.exp: Breakpoint location is modified. + 2021-05-10 Lancelot Six PR gdb/27614 diff --git a/gdb/testsuite/gdb.fortran/array-element.exp b/gdb/testsuite/gdb.fortran/array-element.exp index 28b0e6f348c..9518b87a623 100644 --- a/gdb/testsuite/gdb.fortran/array-element.exp +++ b/gdb/testsuite/gdb.fortran/array-element.exp @@ -31,8 +31,8 @@ if ![runto sub_] then { continue } -gdb_breakpoint [gdb_get_line_number "continue"] -gdb_continue_to_breakpoint "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" -- 2.30.2