-# Copyright 2005, 2007, 2008 Free Software Foundation, Inc.
+# Copyright 2005-2018 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
# This file is part of the gdb testsuite. It contains tests for evaluating
# Fortran subarray expression.
-if $tracelevel then {
- strace $tracelevel
-}
+if { [skip_fortran_tests] } { return -1 }
-set testfile "subarray"
-set srcfile ${testfile}.f
-set binfile ${objdir}/${subdir}/${testfile}
+standard_testfile .f
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f77 quiet}] != "" } {
- untested "Couldn't compile ${srcfile}"
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug f90}]} {
return -1
}
# Test four different kinds of subarray expression evaluation.
-gdb_test "print str(2:4)" ".*1 = \\(98 'b', 99 'c', 100 'd'\\).*" "print str(2:4)"
-gdb_test "print str(:3)" ".*2 = \\(97 'a', 98 'b', 99 'c'\\).*" "print str(:3)"
-gdb_test "print str(5:)" ".*3 = \\(101 'e', 102 'f', 103 'g'\\).*" "print str(5:)"
-gdb_test "print str(:)" ".*4 = \\(97 'a', 98 'b', 99 'c', 100 'd', 101 'e', 102 'f', 103 'g'\\).*" "print str(:)"
+set test "print str(2:4)"
+gdb_test_multiple $test $test {
+ -re "\\$\[0-9\]+ = 'bcd'\r\n$gdb_prompt $" {
+ pass $test
+ }
+ -re "\\$\[0-9\]+ = \\(98 'b', 99 'c', 100 'd'\\)\r\n$gdb_prompt $" {
+ # Compiler should produce string, not an array of characters.
+ setup_xfail "*-*-*"
+ fail $test
+ }
+}
+
+set test "print str(:3)"
+gdb_test_multiple $test $test {
+ -re "\\$\[0-9\]+ = 'abc'\r\n$gdb_prompt $" {
+ pass $test
+ }
+ -re "\\$\[0-9\]+ = \\(97 'a', 98 'b', 99 'c'\\)\r\n$gdb_prompt $" {
+ # Compiler should produce string, not an array of characters.
+ setup_xfail "*-*-*"
+ fail $test
+ }
+}
-gdb_test "print array(2:4)" ".*5 = \\(2, 3, 4\\).*" "print array(2:4)"
-gdb_test "print array(:3)" ".*6 = \\(1, 2, 3\\).*" "print array(:3)"
-gdb_test "print array(5:)" ".*7 = \\(5, 6, 7\\).*" "print array(5:)"
-gdb_test "print array(:)" ".*8 = \\(1, 2, 3, 4, 5, 6, 7\\).*" "print array(:)"
+set test "print str(5:)"
+gdb_test_multiple $test $test {
+ -re "\\$\[0-9\]+ = 'efg'\r\n$gdb_prompt $" {
+ pass $test
+ }
+ -re "\\$\[0-9\]+ = \\(101 'e', 102 'f', 103 'g'\\)\r\n$gdb_prompt $" {
+ # Compiler should produce string, not an array of characters.
+ setup_xfail "*-*-*"
+ fail $test
+ }
+}
+
+set test "print str(:)"
+gdb_test_multiple $test $test {
+ -re "\\$\[0-9\]+ = 'abcdefg'\r\n$gdb_prompt $" {
+ pass $test
+ }
+ -re "\\$\[0-9\]+ = \\(97 'a', 98 'b', 99 'c', 100 'd', 101 'e', 102 'f', 103 'g'\\)\r\n$gdb_prompt $" {
+ # Compiler should produce string, not an array of characters.
+ setup_xfail "*-*-*"
+ fail $test
+ }
+}
+gdb_test "print array(2:4)" "\\$\[0-9\]+ = \\(2, 3, 4\\)"
+gdb_test "print array(:3)" "\\$\[0-9\]+ = \\(1, 2, 3\\)"
+gdb_test "print array(5:)" "\\$\[0-9\]+ = \\(5, 6, 7\\)"
+gdb_test "print array(:)" "\\$\[0-9\]+ = \\(1, 2, 3, 4, 5, 6, 7\\)"