RE: [ping] [PATCH v2 0/6] fortran: multi-dimensional subarrays with strides https://sourceware.org/ml/gdb-patches/2016-07/msg00009.html From 982d582ee738cbcf252ba8eab59a9514edda75b9 Mon Sep 17 00:00:00 2001 From: Christoph Weinmann Date: Wed, 4 Dec 2013 11:47:15 +0000 Subject: [PATCH 6/6] fortran: test cases for subarray strides and slices Add test cases for subarray creation with range, literal and stride value permutations for one, two, and three dimensional arrays. 2013-12-04 Christoph Weinmann testsuite/gdb.fortran/ * static-arrays.exp: New test. * static-arrays.f90: New file. Signed-off-by: Christoph Weinmann --- gdb/testsuite/gdb.fortran/static-arrays.exp | 421 ++++++++++++++++++++++++++++ gdb/testsuite/gdb.fortran/static-arrays.f90 | 55 ++++ 2 files changed, 476 insertions(+) create mode 100644 gdb/testsuite/gdb.fortran/static-arrays.exp create mode 100644 gdb/testsuite/gdb.fortran/static-arrays.f90 diff --git a/gdb/testsuite/gdb.fortran/static-arrays.exp b/gdb/testsuite/gdb.fortran/static-arrays.exp new file mode 100644 index 0000000..cc9ecc0 --- /dev/null +++ b/gdb/testsuite/gdb.fortran/static-arrays.exp @@ -0,0 +1,421 @@ +# Copyright 2015 Free Software Foundation, Inc. +# +# Contributed by Intel Corp. +# +# 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 . + +standard_testfile static-arrays.f90 + +if { [prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}] } { + return -1 +} + +if ![runto MAIN__] then { + perror "couldn't run to breakpoint MAIN__" + continue +} + +gdb_breakpoint [gdb_get_line_number "BP1"] +gdb_continue_to_breakpoint "BP1" ".*BP1.*" + +# Tests subarrays of one dimensional arrays with subrange variations +gdb_test "print ar1" "\\$\[0-9\]+ = \\(1, 2, 3, 4, 5, 6, 7, 8, 9\\)" \ + "print ar1." +gdb_test "print ar1\(4:7\)" "\\$\[0-9\]+ = \\(4, 5, 6, 7\\)" \ + "print ar1\(4:7\)" +gdb_test "print ar1\(8:\)" "\\$\[0-9\]+ = \\(8, 9\\).*" \ + "print ar1\(8:\)" +gdb_test "print ar1\(:3\)" "\\$\[0-9\]+ = \\(1, 2, 3\\).*" \ + "print ar1\(:3\)" +gdb_test "print ar1\(:\)" "\\$\[0-9\]+ = \\(1, 2, 3, 4, 5, 6, 7, 8, 9\\)" \ + "print ar1\(:\)" + +# Check assignment +gdb_test_no_output "set \$my_ary = ar1\(3:8\)" +gdb_test "print \$my_ary" \ + "\\$\[0-9\]+ = \\(3, 4, 5, 6, 7, 8\\)" \ + "Assignment of subarray to variable" +gdb_test_no_output "set ar1\(5\) = 42" + gdb_test "print ar1\(3:8\)" \ + "\\$\[0-9\]+ = \\(3, 4, 42, 6, 7, 8\\)" \ + "print ar1\(3:8\) after assignment" +gdb_test "print \$my_ary" \ + "\\$\[0-9\]+ = \\(3, 4, 5, 6, 7, 8\\)" \ + "Assignment of subarray to variable after original array changed" + +# Test for subarrays of one dimensional arrays with literals + gdb_test "print ar1\(3\)" "\\$\[0-9\]+ = 3" \ + "print ar1\(3\)" + +# Tests for subranges of 2 dimensional arrays with subrange variations +gdb_test "print ar2\(2:3, 3:4\)" \ + "\\$\[0-9\]+ = \\(\\( 23, 33\\) \\( 24, 34\\) \\)" \ + "print ar2\(2:3, 3:4\)." +gdb_test "print ar2\(8:9,8:\)" \ + "\\$\[0-9\]+ = \\(\\( 88, 98\\) \\( 89, 99\\) \\)" \ + "print ar2\(8:9,8:\)" +gdb_test "print ar2\(8:9,:2\)" \ + "\\$\[0-9\]+ = \\(\\( 81, 91\\) \\( 82, 92\\) \\)" \ + "print ar2\(8:9,:2\)" + +gdb_test "print ar2\(8:,8:9\)" \ + "\\$\[0-9\]+ = \\(\\( 88, 98\\) \\( 89, 99\\) \\)" \ + "print ar2\(8:,8:9\)" +gdb_test "print ar2\(8:,8:\)" \ + "\\$\[0-9\]+ = \\(\\( 88, 98\\) \\( 89, 99\\) \\)" \ + "print ar2\(8:,8:\)" +gdb_test "print ar2\(8:,:2\)" \ + "\\$\[0-9\]+ = \\(\\( 81, 91\\) \\( 82, 92\\) \\)" \ + "print ar2\(8:,:2\)" + +gdb_test "print ar2\(:2,2:3\)" \ + "\\$\[0-9\]+ = \\(\\( 12, 22\\) \\( 13, 23\\) \\)" \ + "print ar2\(:2,2:3\)" +gdb_test "print ar2\(:2,8:\)" \ + "\\$\[0-9\]+ = \\(\\( 18, 28\\) \\( 19, 29\\) \\)" \ + "print ar2\(:2,8:\)" +gdb_test "print ar2\(:2,:2\)" \ + "\\$\[0-9\]+ = \\(\\( 11, 21\\) \\( 12, 22\\) \\)" \ + "print ar2\(:2,:2\)" + +# Test subranges of 2 dimensional arrays with literals and subrange variations +gdb_test "print ar2\(7, 3:6\)" \ + "\\$\[0-9\]+ = \\(73, 74, 75, 76\\)" \ + "print ar2\(7, 3:6\)" +gdb_test "print ar2\(7,8:\)" \ + "\\$\[0-9\]+ = \\(78, 79\\)" \ + "print ar2\(7,8:\)" +gdb_test "print ar2\(7,:2\)" \ + "\\$\[0-9\]+ = \\(71, 72\\)" \ + "print ar2\(7,:2\)" + +gdb_test "print ar2\(7:8,4\)" \ + "\\$\[0-9\]+ = \\(74, 84\\)" \ + "print ar2(7:8,4\)" +gdb_test "print ar2\(8:,4\)" \ + "\\$\[0-9\]+ = \\(84, 94\\)" \ + "print ar2\(8:,4\)" +gdb_test "print ar2\(:2,4\)" \ + "\\$\[0-9\]+ = \\(14, 24\\)" \ + "print ar2\(:2,4\)" +gdb_test "print ar2\(3,4\)" \ + "\\$\[0-9\]+ = 34" \ + "print ar2\(3,4\)" + +# Test subarrays of 3 dimensional arrays with literals and subrange variations +gdb_test "print ar3\(2:4,3:4,7:8\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 237, 337, 437\\) \\( 247, 347, 447\\)\ + \\) \\( \\( 238, 338, 438\\) \\( 248, 348, 448\\) \\) \\)" \ + "print ar3\(2:4,3:4,7:8\)" +gdb_test "print ar3\(2:3,4:5,8:\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 248, 348\\) \\( 258, 358\\) \\) \\(\ + \\( 249, 349\\) \\( 259, 359\\) \\) \\)" \ + "print ar3\(2:3,4:5,8:\)" +gdb_test "print ar3\(2:3,4:5,:2\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 241, 341\\) \\( 251, 351\\) \\) \\(\ + \\( 242, 342\\) \\( 252, 352\\) \\) \\)" \ + "print ar3\(2:3,4:5,:2\)" + +gdb_test "print ar3\(2:3,8:,7:8\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 287, 387\\) \\( 297, 397\\) \\) \\(\ + \\( 288, 388\\) \\( 298, 398\\) \\) \\)" \ + "print ar3\(2:3,8:,7:8\)" +gdb_test "print ar3\(2:3,8:,8:\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 288, 388\\) \\( 298, 398\\) \\) \\(\ + \\( 289, 389\\) \\( 299, 399\\) \\) \\)" \ + "print ar3\(2:3,8:,8:\)" +gdb_test "print ar3\(2:3,8:,:2\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 281, 381\\) \\( 291, 391\\) \\) \\(\ + \\( 282, 382\\) \\( 292, 392\\) \\) \\)" \ + "print ar3\(2:3,8:,:2\)" + +gdb_test "print ar3\(2:3,:2,7:8\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 217, 317\\) \\( 227, 327\\) \\) \\(\ + \\( 218, 318\\) \\( 228, 328\\) \\) \\)" \ + "print ar3\(2:3,:2,7:8\)" +gdb_test "print ar3\(2:3,:2,8:\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 218, 318\\) \\( 228, 328\\) \\) \\(\ + \\( 219, 319\\) \\( 229, 329\\) \\) \\)" \ + "print ar3\(2:3,:2,8:\)" +gdb_test "print ar3\(2:3,:2,:2\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 211, 311\\) \\( 221, 321\\) \\) \\(\ + \\( 212, 312\\) \\( 222, 322\\) \\) \\)" \ + "print ar3\(2:3,:2,:2\)" + +gdb_test "print ar3\(8:,3:4,7:8\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 837, 937\\) \\( 847, 947\\) \\) \\(\ + \\( 838, 938\\) \\( 848, 948\\) \\) \\)" \ + "print ar3\(8:,3:4,7:8\)" +gdb_test "print ar3\(8:,4:5,8:\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 848, 948\\) \\( 858, 958\\) \\) \\(\ + \\( 849, 949\\) \\( 859, 959\\) \\) \\)" \ + "print ar3\(8:,4:5,8:\)" +gdb_test "print ar3\(8:,4:5,:2\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 841, 941\\) \\( 851, 951\\) \\) \\(\ + \\( 842, 942\\) \\( 852, 952\\) \\) \\)" \ + "print ar3\(8:,4:5,:2\)" + +gdb_test "print ar3\(8:,8:,7:8\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 887, 987\\) \\( 897, 997\\) \\) \\(\ + \\( 888, 988\\) \\( 898, 998\\) \\) \\)" \ + "print ar3\(8:,8:,7:8\)" +gdb_test "print ar3\(8:,8:,8:\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 888, 988\\) \\( 898, 998\\) \\) \\(\ + \\( 889, 989\\) \\( 899, 999\\) \\) \\)" \ + "print ar3\(8:,8:,8:\)" +gdb_test "print ar3\(8:,8:,:2\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 881, 981\\) \\( 891, 991\\) \\) \\(\ + \\( 882, 982\\) \\( 892, 992\\) \\) \\)" \ + "print ar3\(8:,8:,:2\)" + +gdb_test "print ar3\(8:,:2,7:8\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 817, 917\\) \\( 827, 927\\) \\) \\(\ + \\( 818, 918\\) \\( 828, 928\\) \\) \\)" \ + "print ar3\(8:,:2,7:8\)" +gdb_test "print ar3\(8:,:2,8:\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 818, 918\\) \\( 828, 928\\) \\) \\(\ + \\( 819, 919\\) \\( 829, 929\\) \\) \\)" \ + "print ar3\(8:,:2,8:\)" +gdb_test "print ar3\(8:,:2,:2\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 811, 911\\) \\( 821, 921\\) \\) \\(\ + \\( 812, 912\\) \\( 822, 922\\) \\) \\)" \ + "print ar3\(8:,:2,:2\)" + + +gdb_test "print ar3\(:2,3:4,7:8\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 137, 237\\) \\( 147, 247\\) \\) \\(\ + \\( 138, 238\\) \\( 148, 248\\) \\) \\)" \ + "print ar3 \(:2,3:4,7:8\)." +gdb_test "print ar3\(:2,3:4,8:\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 138, 238\\) \\( 148, 248\\) \\) \\(\ + \\( 139, 239\\) \\( 149, 249\\) \\) \\)" \ + "print ar3\(:2,3:4,8:\)" +gdb_test "print ar3\(:2,3:4,:2\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 131, 231\\) \\( 141, 241\\) \\) \\(\ + \\( 132, 232\\) \\( 142, 242\\) \\) \\)" \ + "print ar3\(:2,3:4,:2\)" + +gdb_test "print ar3\(:2,8:,7:8\)" "\\$\[0-9\]+ = \\(\\( \\( 187, 287\\) \\(\ + 197, 297\\) \\) \\( \\( 188, 288\\) \\( 198, 298\\) \\) \\)" \ + "print ar3\(:2,8:,7:8\)" +gdb_test "print ar3\(:2,8:,8:\)" "\\$\[0-9\]+ = \\(\\( \\( 188, 288\\) \\( 198,\ + 298\\) \\) \\( \\( 189, 289\\) \\( 199, 299\\) \\) \\)" \ + "print ar3\(:2,8:,8:\)" +gdb_test "print ar3\(:2,8:,:2\)" "\\$\[0-9\]+ = \\(\\( \\( 181, 281\\) \\( 191,\ + 291\\) \\) \\( \\( 182, 282\\) \\( 192, 292\\) \\) \\)" \ + "print ar3\(:2,8:,:2\)" + +gdb_test "print ar3\(:2,:2,7:8\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 117, 217\\) \\( 127, 227\\) \\) \\(\ + \\( 118, 218\\) \\( 128, 228\\) \\) \\)" \ + "print ar3\(:2,:2,7:8\)" +gdb_test "print ar3\(:2,:2,8:\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 118, 218\\) \\( 128, 228\\) \\) \\(\ + \\( 119, 219\\) \\( 129, 229\\) \\) \\)" \ + "print ar3\(:2,:2,8:\)" +gdb_test "print ar3\(:2,:2,:2\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 111, 211\\) \\( 121, 221\\) \\) \\(\ + \\( 112, 212\\) \\( 122, 222\\) \\) \\)" \ + "print ar3\(:2,:2,:2\)" + +#Tests for subarrays of 3 dimensional arrays with literals and subranges +gdb_test "print ar3\(3,3:4,7:8\)" \ + "\\$\[0-9\]+ = \\(\\( 337, 347\\) \\( 338, 348\\) \\)" \ + "print ar3\(3,3:4,7:8\)" +gdb_test "print ar3\(3,4:5,8:\)" \ + "\\$\[0-9\]+ = \\(\\( 348, 358\\) \\( 349, 359\\) \\)" \ + "print ar3\(3,4:5,8:\)" +gdb_test "print ar3\(3,4:5,:2\)" \ + "\\$\[0-9\]+ = \\(\\( 341, 351\\) \\( 342, 352\\) \\)" \ + "print ar3\(3,4:5,:2\)" +gdb_test "print ar3\(3,4:5,3\)" \ + "\\$\[0-9\]+ = \\(343, 353\\)" \ + "print ar3\(3,4:5,3\)" + +gdb_test "print ar3\(2,8:,7:8\)" \ + "\\$\[0-9\]+ = \\(\\( 287, 297\\) \\( 288, 298\\) \\)" \ + "print ar3\(2,8:,7:8\)" +gdb_test "print ar3\(2,8:,8:\)" \ + "\\$\[0-9\]+ = \\(\\( 288, 298\\) \\( 289, 299\\) \\)" \ + "print ar3\(2,8:,8:\)" +gdb_test "print ar3\(2,8:,:2\)"\ + "\\$\[0-9\]+ = \\(\\( 281, 291\\) \\( 282, 292\\) \\)" \ + "print ar3\(2,8:,:2\)" +gdb_test "print ar3\(2,8:,3\)" \ + "\\$\[0-9\]+ = \\(283, 293\\)" \ + "print ar3\(2,8:,3\)" + +gdb_test "print ar3\(2,:2,7:8\)" \ + "\\$\[0-9\]+ = \\(\\( 217, 227\\) \\( 218, 228\\) \\)" \ + "print ar3\(2,:2,7:8\)" +gdb_test "print ar3\(2,:2,8:\)" \ + "\\$\[0-9\]+ = \\(\\( 218, 228\\) \\( 219, 229\\) \\)" \ + "print ar3\(2,:2,8:\)" +gdb_test "print ar3\(2,:2,:2\)" \ + "\\$\[0-9\]+ = \\(\\( 211, 221\\) \\( 212, 222\\) \\)" \ + "print ar3\(2,:2,:2\)" +gdb_test "print ar3\(2,:2,3\)" \ + "\\$\[0-9\]+ = \\(213, 223\\)" \ + "print ar3\(2,:2,3\)" + +gdb_test "print ar3\(3,4,7:8\)" \ + "\\$\[0-9\]+ = \\(347, 348\\)" \ + "print ar3\(3,4,7:8\)" +gdb_test "print ar3\(3,4,8:\)" \ + "\\$\[0-9\]+ = \\(348, 349\\)" \ +i "print ar3\(3,4,8:\)" +gdb_test "print ar3\(3,4,:2\)" \ + "\\$\[0-9\]+ = \\(341, 342\\)" \ + "print ar3\(3,4,:2\)" +gdb_test "print ar3\(5,6,7\)" \ + "\\$\[0-9\]+ = 567" \ + "print ar3\(5,6,7\)" + +gdb_test "print ar3\(3:4,6,7:8\)" \ + "\\$\[0-9\]+ = \\(\\( 367, 467\\) \\( 368, 468\\) \\)" \ + "print ar3\(3:4,6,7:8\)" +gdb_test "print ar3\(3:4,6,8:\)" \ + "\\$\[0-9\]+ = \\(\\( 368, 468\\) \\( 369, 469\\) \\)" \ + "print ar3\(3:4,6,8:\)" +gdb_test "print ar3\(3:4,6,:2\)" \ + "\\$\[0-9\]+ = \\(\\( 361, 461\\) \\( 362, 462\\) \\)" \ + "print ar3\(3:4,6,:2\)" +gdb_test "print ar3\(3:4,6,5\)" \ + "\\$\[0-9\]+ = \\(365, 465\\)" \ + "print ar3\(3:4,6,5\)" + +gdb_test "print ar3\(8:,6,7:8\)" \ + "\\$\[0-9\]+ = \\(\\( 867, 967\\) \\( 868, 968\\) \\)" \ + "print ar3\(8:,6,7:8\)" +gdb_test "print ar3\(8:,6,8:\)" \ + "\\$\[0-9\]+ = \\(\\( 868, 968\\) \\( 869, 969\\) \\)" \ + "print ar3\(8:,6,8:\)" +gdb_test "print ar3\(8:,6,:2\)" \ + "\\$\[0-9\]+ = \\(\\( 861, 961\\) \\( 862, 962\\) \\)" \ + "print ar3\(8:,6,:2\)" +gdb_test "print ar3\(8:,6,5\)" \ + "\\$\[0-9\]+ = \\(865, 965\\)" \ + "print ar3\(8:,6,5\)" + +gdb_test "print ar3\(:2,6,7:8\)" \ + "\\$\[0-9\]+ = \\(\\( 167, 267\\) \\( 168, 268\\) \\)" \ + "print ar3\(:2,6,7:8\)" +gdb_test "print ar3\(:2,6,8:\)" \ + "\\$\[0-9\]+ = \\(\\( 168, 268\\) \\( 169, 269\\) \\)" \ + "print ar3\(:2,6,8:\)" +gdb_test "print ar3\(:2,6,:2\)" \ + "\\$\[0-9\]+ = \\(\\( 161, 261\\) \\( 162, 262\\) \\)" \ + "print ar3\(:2,6,:2\)" +gdb_test "print ar3\(:2,6,5\)" \ + "\\$\[0-9\]+ = \\(165, 265\\)" \ + "print ar3\(:2,6,5\)" + +gdb_test "print ar3\(3:4,5:6,4\)" \ + "\\$\[0-9\]+ = \\(\\( 354, 454\\) \\( 364, 464\\) \\)" \ + "print ar2\(3:4,5:6,4\)" +gdb_test "print ar3\(8:,5:6,4\)" \ + "\\$\[0-9\]+ = \\(\\( 854, 954\\) \\( 864, 964\\) \\)" \ + "print ar2\(8:,5:6,4\)" +gdb_test "print ar3\(:2,5:6,4\)" \ + "\\$\[0-9\]+ = \\(\\( 154, 254\\) \\( 164, 264\\) \\)" \ + "print ar2\(:2,5:6,4\)" + +# Stride > 1 +gdb_test "print ar1\(2:6:2\)" \ + "\\$\[0-9\]+ = \\(2, 4, 6\\)" \ + "print ar1\(2:6:2\)" +gdb_test "print ar2\(2:6:2,3:4\)" \ + "\\$\[0-9\]+ = \\(\\( 23, 43, 63\\) \\( 24, 44, 64\\) \\)" \ + "print ar2\(2:6:2,3:4\)" +gdb_test "print ar2\(2:6:2,3\)" \ + "\\$\[0-9\]+ = \\(23, 43, 63\\)" \ + "print ar2\(2:6:2,3\)" +gdb_test "print ar3\(2:6:2,3:5:2,4:7:3\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 234, 434, 634\\) \\( 254, 454, 654\\)\ + \\) \\( \\( 237, 437, 637\\) \\( 257, 457, 657\\) \\) \\)" \ + "print ar3\(2:6:2,3:5:2,4:7:3\)" +gdb_test "print ar3\(2:6:2,5,4:7:3\)" \ + "\\$\[0-9\]+ = \\(\\( 254, 454, 654\\) \\( 257, 457, 657\\)\ + \\)" \ + "print ar3\(2:6:2,5,4:7:3\)" + +# Stride < 0 +gdb_test "print ar1\(8:2:-2\)" \ + "\\$\[0-9\]+ = \\(8, 6, 4, 2\\)" \ + "print ar1\(8:2:-2\)" +gdb_test "print ar2\(8:2:-2,3:4\)" \ + "\\$\[0-9\]+ = \\(\\( 83, 63, 43, 23\\) \\( 84, 64, 44, 24\\)\ + \\)" \ + "print ar2\(8:2:-2,3:4\)" +gdb_test "print ar2\(2:6:2,3\)" \ + "\\$\[0-9\]+ = \\(23, 43, 63\\)" \ + "print ar2\(2:6:2,3\)" +gdb_test "print ar3\(2:3,7:3:-4,4:7:3\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 274, 374\\) \\( 234, 334\\) \\) \\(\ + \\( 277, 377\\) \\( 237, 337\\) \\) \\)" \ + "print ar3\(2:3,7:3:-4,4:7:3\)" +gdb_test "print ar3\(2:6:2,5,7:4:-3\)" \ + "\\$\[0-9\]+ = \\(\\( 257, 457, 657\\) \\( 254, 454, 654\\)\ + \\)" \ + "print ar3\(2:6:2,5,7:4:-3\)" + +# Tests with negative and mixed indices +gdb_test "p ar4\(2:4, -2:1, -15:-14\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 261, 361, 461\\) \\( 271, 371, 471\\)\ + \\( 281, 381, 481\\) \\( 291, 391, 491\\) \\) \\( \\( 262,\ + 362, 462\\) \\( 272, 372, 472\\) \\( 282, 382, 482\\) \\( 292,\ + 392, 492\\) \\) \\)" \ + "print ar4(2:4, -2:1, -15:-14)" + +gdb_test "p ar4\(7,-6:2:3,-7\)" \ + "\\$\[0-9\]+ = \\(729, 759, 789\\)" \ + "print ar4(7,-6:2:3,-7)" + +gdb_test "p ar4\(9:2:-2, -6:2:3, -6:-15:-3\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 930, 730, 530, 330\\) \\( 960, 760,\ + 560, 360\\) \\( 990, 790, 590, 390\\) \\) \\( \\( 927, 727,\ + 527, 327\\) \\( 957, 757, 557, 357\\) \\( 987, 787, 587,\ + 387\\) \\) \\( \\( 924, 724, 524, 324\\) \\( 954, 754, 554,\ + 354\\) \\( 984, 784, 584, 384\\) \\) \\( \\( 921, 721, 521,\ + 321\\) \\( 951, 751, 551, 351\\) \\( 981, 781, 581, 381\\) \\)\ + \\)" \ + "print ar4(9:2:-2, -6:2:3, -6:-15:-3)" + +gdb_test "p ar4\(:,:,:\)" \ + "\\$\[0-9\]+ = \\(\\( \\( 111, 211, 311, 411, 511, 611, 711,\ + 811, .*" \ + "print ar4(:,:,:)" + +# Provoke error messages for bad user input +gdb_test "print ar1\(0:4\)" \ + "provided bound\\(s\\) outside array bound\\(s\\)" \ + "print ar1\(0:4\)" +gdb_test "print ar1\(8:12\)" \ + "provided bound\\(s\\) outside array bound\\(s\\)" \ + "print ar1\(8:12\)" +gdb_test "print ar1\(8:2:\)" \ + "A syntax error in expression, near `\\)'." \ + "print ar1\(8:2:\)" +gdb_test "print ar1\(8:2:2\)" \ + "Wrong value provided for stride and boundaries" \ + "print ar1\(8:2:2\)" +gdb_test "print ar1\(2:8:-2\)" \ + "Wrong value provided for stride and boundaries" \ + "print ar1\(2:8:-2\)" +gdb_test "print ar1\(2:7:0\)" \ + "Stride must not be 0" \ + "print ar1\(2:7:0\)" +gdb_test "print ar1\(3:7\) = 42" \ + "Invalid cast." \ + "Assignment of value to subarray" diff --git a/gdb/testsuite/gdb.fortran/static-arrays.f90 b/gdb/testsuite/gdb.fortran/static-arrays.f90 new file mode 100644 index 0000000..f22fcbe --- /dev/null +++ b/gdb/testsuite/gdb.fortran/static-arrays.f90 @@ -0,0 +1,55 @@ +! Copyright 2015 Free Software Foundation, Inc. +! +! Contributed by Intel Corp. +! +! 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 . + +subroutine sub + integer, dimension(9) :: ar1 + integer, dimension(9,9) :: ar2 + integer, dimension(9,9,9) :: ar3 + integer, dimension(10,-7:3, -15:-5) :: ar4 + integer :: i,j,k + + ar1 = 1 + ar2 = 1 + ar3 = 1 + ar4 = 4 + + ! Resulting array ar3 looks like ((( 111, 112, 113, 114,...))) + do i = 1, 9, 1 + ar1(i) = i + do j = 1, 9, 1 + ar2(i,j) = i*10 + j + do k = 1, 9, 1 + ar3(i,j,k) = i*100 + j*10 + k + end do + end do + end do + + do i = 1, 10, 1 + do j = -7, 3, 1 + do k = -15, -5, 1 + ar4(i,j,k) = i*100 + (j+8)*10 + (k+16) + end do + end do + end do + + ar1(1) = 11 !BP1 + return +end + +program testprog + call sub +end -- 2.5.5