+++ /dev/null
-From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
-From: Fedora GDB patches <invalid@email.com>
-Date: Fri, 27 Oct 2017 21:07:50 +0200
-Subject: gdb-archer-vla-tests.patch
-
-;;=fedoratest
-
-diff --git a/gdb/testsuite/gdb.ada/packed_array.exp b/gdb/testsuite/gdb.ada/packed_array.exp
---- a/gdb/testsuite/gdb.ada/packed_array.exp
-+++ b/gdb/testsuite/gdb.ada/packed_array.exp
-@@ -53,5 +53,11 @@ gdb_test_multiple "$test" "$test" {
- # are. Observed with (FSF GNU Ada 4.5.3 20110124).
- xfail $test
- }
-+ -re "= \\(\\)\[\r\n\]+$gdb_prompt $" {
-+ # archer-jankratochvil-vla resolves it as a dynamic type resolved as an
-+ # empty array [0..-1].
-+ # DW_AT_upper_bound : (DW_OP_fbreg: -48; DW_OP_deref)
-+ xfail $test
-+ }
- }
-
-diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S b/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer-foo.S
-@@ -0,0 +1,358 @@
-+ .file "x86_64-vla-pointer.c"
-+ .text
-+.Ltext0:
-+ .globl foo
-+ .type foo, @function
-+foo:
-+.LFB0:
-+ .file 1 "gdb.arch/x86_64-vla-pointer.c"
-+ # gdb.arch/x86_64-vla-pointer.c:22
-+ .loc 1 22 0
-+ .cfi_startproc
-+# BLOCK 2 seq:0
-+# PRED: ENTRY (FALLTHRU)
-+ pushq %rbp
-+ .cfi_def_cfa_offset 16
-+ .cfi_offset 6, -16
-+ movq %rsp, %rbp
-+ .cfi_def_cfa_register 6
-+ pushq %rbx
-+ subq $56, %rsp
-+ .cfi_offset 3, -24
-+ movl %edi, -52(%rbp)
-+ # gdb.arch/x86_64-vla-pointer.c:22
-+ .loc 1 22 0
-+ movq %rsp, %rax
-+ movq %rax, %rsi
-+ # gdb.arch/x86_64-vla-pointer.c:23
-+ .loc 1 23 0
-+ movl -52(%rbp), %eax
-+ movslq %eax, %rdx
-+ subq $1, %rdx
-+ movq %rdx, -32(%rbp)
-+ movslq %eax, %rdx
-+ movq %rdx, %r8
-+ movl $0, %r9d
-+ # gdb.arch/x86_64-vla-pointer.c:24
-+ .loc 1 24 0
-+ movslq %eax, %rdx
-+ movq %rdx, %rcx
-+ movl $0, %ebx
-+ cltq
-+ movl $16, %edx
-+ subq $1, %rdx
-+ addq %rdx, %rax
-+ movl $16, %ebx
-+ movl $0, %edx
-+ divq %rbx
-+ imulq $16, %rax, %rax
-+ subq %rax, %rsp
-+ movq %rsp, %rax
-+ addq $0, %rax
-+ movq %rax, -40(%rbp)
-+ # gdb.arch/x86_64-vla-pointer.c:27
-+ .loc 1 27 0
-+ movl $0, -20(%rbp)
-+# SUCC: 4 [100.0%]
-+ jmp .L2
-+# BLOCK 3 seq:1
-+# PRED: 4
-+.L3:
-+ # gdb.arch/x86_64-vla-pointer.c:28
-+ .loc 1 28 0 discriminator 3
-+ movl -20(%rbp), %eax
-+ movl %eax, %ecx
-+ movq -40(%rbp), %rdx
-+ movl -20(%rbp), %eax
-+ cltq
-+ movb %cl, (%rdx,%rax)
-+# SUCC: 4 (FALLTHRU,DFS_BACK)
-+ # gdb.arch/x86_64-vla-pointer.c:27
-+ .loc 1 27 0 discriminator 3
-+ addl $1, -20(%rbp)
-+# BLOCK 4 seq:2
-+# PRED: 3 (FALLTHRU,DFS_BACK) 2 [100.0%]
-+.L2:
-+ # gdb.arch/x86_64-vla-pointer.c:27
-+ .loc 1 27 0 is_stmt 0 discriminator 1
-+ movl -20(%rbp), %eax
-+ cmpl -52(%rbp), %eax
-+# SUCC: 3 5 (FALLTHRU)
-+ jl .L3
-+# BLOCK 5 seq:3
-+# PRED: 4 (FALLTHRU)
-+ # gdb.arch/x86_64-vla-pointer.c:30
-+ .loc 1 30 0 is_stmt 1
-+ movq -40(%rbp), %rax
-+ movb $0, (%rax)
-+ movq %rsi, %rsp
-+ # gdb.arch/x86_64-vla-pointer.c:31
-+ .loc 1 31 0
-+ nop
-+ movq -8(%rbp), %rbx
-+ leave
-+ .cfi_def_cfa 7, 8
-+# SUCC: EXIT [100.0%]
-+ ret
-+ .cfi_endproc
-+.LFE0:
-+ .size foo, .-foo
-+.Letext0:
-+ .section .debug_info,"",@progbits
-+.Ldebug_info0:
-+ .long 0xa5 # Length of Compilation Unit Info
-+ .value 0x4 # DWARF version number
-+ .long .Ldebug_abbrev0 # Offset Into Abbrev. Section
-+ .byte 0x8 # Pointer Size (in bytes)
-+ .uleb128 0x1 # (DIE (0xb) DW_TAG_compile_unit)
-+ .long .LASF3 # DW_AT_producer: "GNU C11 6.2.1 20160916 (Red Hat 6.2.1-2) -mtune=generic -march=x86-64 -g"
-+ .byte 0xc # DW_AT_language
-+ .long .LASF4 # DW_AT_name: "gdb.arch/x86_64-vla-pointer.c"
-+ .long .LASF5 # DW_AT_comp_dir: "/home/jkratoch/redhat/fedora/gdb/master/gdb-7.12/gdb/testsuite"
-+ .quad .Ltext0 # DW_AT_low_pc
-+ .quad .Letext0-.Ltext0 # DW_AT_high_pc
-+ .long .Ldebug_line0 # DW_AT_stmt_list
-+ .uleb128 0x2 # (DIE (0x2d) DW_TAG_subprogram)
-+ # DW_AT_external
-+ .ascii "foo\0" # DW_AT_name
-+ .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c)
-+ .byte 0x15 # DW_AT_decl_line
-+ # DW_AT_prototyped
-+ .quad .LFB0 # DW_AT_low_pc
-+ .quad .LFE0-.LFB0 # DW_AT_high_pc
-+ .uleb128 0x1 # DW_AT_frame_base
-+ .byte 0x9c # DW_OP_call_frame_cfa
-+ # DW_AT_GNU_all_call_sites
-+ .long 0x80 # DW_AT_sibling
-+ .uleb128 0x3 # (DIE (0x4a) DW_TAG_formal_parameter)
-+ .long .LASF6 # DW_AT_name: "size"
-+ .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c)
-+ .byte 0x15 # DW_AT_decl_line
-+ .long 0x80 # DW_AT_type
-+ .uleb128 0x3 # DW_AT_location
-+ .byte 0x91 # DW_OP_fbreg
-+ .sleb128 -68
-+ .uleb128 0x4 # (DIE (0x59) DW_TAG_typedef)
-+ .long .LASF7 # DW_AT_name: "array_t"
-+ .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c)
-+ .byte 0x17 # DW_AT_decl_line
-+ .long 0x87 # DW_AT_type
-+ .uleb128 0x5 # (DIE (0x64) DW_TAG_variable)
-+ .long .LASF0 # DW_AT_name: "array"
-+ .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c)
-+ .byte 0x18 # DW_AT_decl_line
-+ .long 0x59 # DW_AT_type
-+ .uleb128 0x3 # DW_AT_location
-+ .byte 0x91 # DW_OP_fbreg
-+ .sleb128 -56
-+ .byte 0x6 # DW_OP_deref
-+ .uleb128 0x6 # (DIE (0x73) DW_TAG_variable)
-+ .ascii "i\0" # DW_AT_name
-+ .byte 0x1 # DW_AT_decl_file (gdb.arch/x86_64-vla-pointer.c)
-+ .byte 0x19 # DW_AT_decl_line
-+ .long 0x80 # DW_AT_type
-+ .uleb128 0x2 # DW_AT_location
-+ .byte 0x91 # DW_OP_fbreg
-+ .sleb128 -36
-+ .byte 0 # end of children of DIE 0x2d
-+ .uleb128 0x7 # (DIE (0x80) DW_TAG_base_type)
-+ .byte 0x4 # DW_AT_byte_size
-+ .byte 0x5 # DW_AT_encoding
-+ .ascii "int\0" # DW_AT_name
-+ .uleb128 0x8 # (DIE (0x87) DW_TAG_array_type)
-+ .long 0xa1 # DW_AT_type
-+ .long 0x9a # DW_AT_sibling
-+ .uleb128 0x9 # (DIE (0x90) DW_TAG_subrange_type)
-+ .long 0x9a # DW_AT_type
-+ .uleb128 0x3 # DW_AT_upper_bound
-+ .byte 0x91 # DW_OP_fbreg
-+ .sleb128 -48
-+ .byte 0x6 # DW_OP_deref
-+ .byte 0 # end of children of DIE 0x87
-+ .uleb128 0xa # (DIE (0x9a) DW_TAG_base_type)
-+ .byte 0x8 # DW_AT_byte_size
-+ .byte 0x7 # DW_AT_encoding
-+ .long .LASF1 # DW_AT_name: "sizetype"
-+ .uleb128 0xa # (DIE (0xa1) DW_TAG_base_type)
-+ .byte 0x1 # DW_AT_byte_size
-+ .byte 0x6 # DW_AT_encoding
-+ .long .LASF2 # DW_AT_name: "char"
-+ .byte 0 # end of children of DIE 0xb
-+ .section .debug_abbrev,"",@progbits
-+.Ldebug_abbrev0:
-+ .uleb128 0x1 # (abbrev code)
-+ .uleb128 0x11 # (TAG: DW_TAG_compile_unit)
-+ .byte 0x1 # DW_children_yes
-+ .uleb128 0x25 # (DW_AT_producer)
-+ .uleb128 0xe # (DW_FORM_strp)
-+ .uleb128 0x13 # (DW_AT_language)
-+ .uleb128 0xb # (DW_FORM_data1)
-+ .uleb128 0x3 # (DW_AT_name)
-+ .uleb128 0xe # (DW_FORM_strp)
-+ .uleb128 0x1b # (DW_AT_comp_dir)
-+ .uleb128 0xe # (DW_FORM_strp)
-+ .uleb128 0x11 # (DW_AT_low_pc)
-+ .uleb128 0x1 # (DW_FORM_addr)
-+ .uleb128 0x12 # (DW_AT_high_pc)
-+ .uleb128 0x7 # (DW_FORM_data8)
-+ .uleb128 0x10 # (DW_AT_stmt_list)
-+ .uleb128 0x17 # (DW_FORM_sec_offset)
-+ .byte 0
-+ .byte 0
-+ .uleb128 0x2 # (abbrev code)
-+ .uleb128 0x2e # (TAG: DW_TAG_subprogram)
-+ .byte 0x1 # DW_children_yes
-+ .uleb128 0x3f # (DW_AT_external)
-+ .uleb128 0x19 # (DW_FORM_flag_present)
-+ .uleb128 0x3 # (DW_AT_name)
-+ .uleb128 0x8 # (DW_FORM_string)
-+ .uleb128 0x3a # (DW_AT_decl_file)
-+ .uleb128 0xb # (DW_FORM_data1)
-+ .uleb128 0x3b # (DW_AT_decl_line)
-+ .uleb128 0xb # (DW_FORM_data1)
-+ .uleb128 0x27 # (DW_AT_prototyped)
-+ .uleb128 0x19 # (DW_FORM_flag_present)
-+ .uleb128 0x11 # (DW_AT_low_pc)
-+ .uleb128 0x1 # (DW_FORM_addr)
-+ .uleb128 0x12 # (DW_AT_high_pc)
-+ .uleb128 0x7 # (DW_FORM_data8)
-+ .uleb128 0x40 # (DW_AT_frame_base)
-+ .uleb128 0x18 # (DW_FORM_exprloc)
-+ .uleb128 0x2117 # (DW_AT_GNU_all_call_sites)
-+ .uleb128 0x19 # (DW_FORM_flag_present)
-+ .uleb128 0x1 # (DW_AT_sibling)
-+ .uleb128 0x13 # (DW_FORM_ref4)
-+ .byte 0
-+ .byte 0
-+ .uleb128 0x3 # (abbrev code)
-+ .uleb128 0x5 # (TAG: DW_TAG_formal_parameter)
-+ .byte 0 # DW_children_no
-+ .uleb128 0x3 # (DW_AT_name)
-+ .uleb128 0xe # (DW_FORM_strp)
-+ .uleb128 0x3a # (DW_AT_decl_file)
-+ .uleb128 0xb # (DW_FORM_data1)
-+ .uleb128 0x3b # (DW_AT_decl_line)
-+ .uleb128 0xb # (DW_FORM_data1)
-+ .uleb128 0x49 # (DW_AT_type)
-+ .uleb128 0x13 # (DW_FORM_ref4)
-+ .uleb128 0x2 # (DW_AT_location)
-+ .uleb128 0x18 # (DW_FORM_exprloc)
-+ .byte 0
-+ .byte 0
-+ .uleb128 0x4 # (abbrev code)
-+ .uleb128 0x16 # (TAG: DW_TAG_typedef)
-+ .byte 0 # DW_children_no
-+ .uleb128 0x3 # (DW_AT_name)
-+ .uleb128 0xe # (DW_FORM_strp)
-+ .uleb128 0x3a # (DW_AT_decl_file)
-+ .uleb128 0xb # (DW_FORM_data1)
-+ .uleb128 0x3b # (DW_AT_decl_line)
-+ .uleb128 0xb # (DW_FORM_data1)
-+ .uleb128 0x49 # (DW_AT_type)
-+ .uleb128 0x13 # (DW_FORM_ref4)
-+ .byte 0
-+ .byte 0
-+ .uleb128 0x5 # (abbrev code)
-+ .uleb128 0x34 # (TAG: DW_TAG_variable)
-+ .byte 0 # DW_children_no
-+ .uleb128 0x3 # (DW_AT_name)
-+ .uleb128 0xe # (DW_FORM_strp)
-+ .uleb128 0x3a # (DW_AT_decl_file)
-+ .uleb128 0xb # (DW_FORM_data1)
-+ .uleb128 0x3b # (DW_AT_decl_line)
-+ .uleb128 0xb # (DW_FORM_data1)
-+ .uleb128 0x49 # (DW_AT_type)
-+ .uleb128 0x13 # (DW_FORM_ref4)
-+ .uleb128 0x2 # (DW_AT_location)
-+ .uleb128 0x18 # (DW_FORM_exprloc)
-+ .byte 0
-+ .byte 0
-+ .uleb128 0x6 # (abbrev code)
-+ .uleb128 0x34 # (TAG: DW_TAG_variable)
-+ .byte 0 # DW_children_no
-+ .uleb128 0x3 # (DW_AT_name)
-+ .uleb128 0x8 # (DW_FORM_string)
-+ .uleb128 0x3a # (DW_AT_decl_file)
-+ .uleb128 0xb # (DW_FORM_data1)
-+ .uleb128 0x3b # (DW_AT_decl_line)
-+ .uleb128 0xb # (DW_FORM_data1)
-+ .uleb128 0x49 # (DW_AT_type)
-+ .uleb128 0x13 # (DW_FORM_ref4)
-+ .uleb128 0x2 # (DW_AT_location)
-+ .uleb128 0x18 # (DW_FORM_exprloc)
-+ .byte 0
-+ .byte 0
-+ .uleb128 0x7 # (abbrev code)
-+ .uleb128 0x24 # (TAG: DW_TAG_base_type)
-+ .byte 0 # DW_children_no
-+ .uleb128 0xb # (DW_AT_byte_size)
-+ .uleb128 0xb # (DW_FORM_data1)
-+ .uleb128 0x3e # (DW_AT_encoding)
-+ .uleb128 0xb # (DW_FORM_data1)
-+ .uleb128 0x3 # (DW_AT_name)
-+ .uleb128 0x8 # (DW_FORM_string)
-+ .byte 0
-+ .byte 0
-+ .uleb128 0x8 # (abbrev code)
-+ .uleb128 0x1 # (TAG: DW_TAG_array_type)
-+ .byte 0x1 # DW_children_yes
-+ .uleb128 0x49 # (DW_AT_type)
-+ .uleb128 0x13 # (DW_FORM_ref4)
-+ .uleb128 0x1 # (DW_AT_sibling)
-+ .uleb128 0x13 # (DW_FORM_ref4)
-+ .byte 0
-+ .byte 0
-+ .uleb128 0x9 # (abbrev code)
-+ .uleb128 0x21 # (TAG: DW_TAG_subrange_type)
-+ .byte 0 # DW_children_no
-+ .uleb128 0x49 # (DW_AT_type)
-+ .uleb128 0x13 # (DW_FORM_ref4)
-+ .uleb128 0x2f # (DW_AT_upper_bound)
-+ .uleb128 0x18 # (DW_FORM_exprloc)
-+ .byte 0
-+ .byte 0
-+ .uleb128 0xa # (abbrev code)
-+ .uleb128 0x24 # (TAG: DW_TAG_base_type)
-+ .byte 0 # DW_children_no
-+ .uleb128 0xb # (DW_AT_byte_size)
-+ .uleb128 0xb # (DW_FORM_data1)
-+ .uleb128 0x3e # (DW_AT_encoding)
-+ .uleb128 0xb # (DW_FORM_data1)
-+ .uleb128 0x3 # (DW_AT_name)
-+ .uleb128 0xe # (DW_FORM_strp)
-+ .byte 0
-+ .byte 0
-+ .byte 0
-+ .section .debug_aranges,"",@progbits
-+ .long 0x2c # Length of Address Ranges Info
-+ .value 0x2 # DWARF Version
-+ .long .Ldebug_info0 # Offset of Compilation Unit Info
-+ .byte 0x8 # Size of Address
-+ .byte 0 # Size of Segment Descriptor
-+ .value 0 # Pad to 16 byte boundary
-+ .value 0
-+ .quad .Ltext0 # Address
-+ .quad .Letext0-.Ltext0 # Length
-+ .quad 0
-+ .quad 0
-+ .section .debug_line,"",@progbits
-+.Ldebug_line0:
-+ .section .debug_str,"MS",@progbits,1
-+.LASF4:
-+ .string "gdb.arch/x86_64-vla-pointer.c"
-+.LASF7:
-+ .string "array_t"
-+.LASF3:
-+ .string "GNU C11 6.2.1 20160916 (Red Hat 6.2.1-2) -mtune=generic -march=x86-64 -g"
-+.LASF2:
-+ .string "char"
-+.LASF1:
-+ .string "sizetype"
-+.LASF5:
-+ .string "/home/jkratoch/redhat/fedora/gdb/master/gdb-7.12/gdb/testsuite"
-+.LASF6:
-+ .string "size"
-+.LASF0:
-+ .string "array"
-+ .ident "GCC: (GNU) 6.2.1 20160916 (Red Hat 6.2.1-2)"
-+ .section .note.GNU-stack,"",@progbits
-diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.c
-@@ -0,0 +1,45 @@
-+/* This testcase is part of GDB, the GNU debugger.
-+
-+ Copyright 2009 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/>. */
-+
-+#if 0
-+
-+void
-+foo (int size)
-+{
-+ typedef char array_t[size];
-+ array_t array;
-+ int i;
-+
-+ for (i = 0; i < size; i++)
-+ array[i] = i;
-+
-+ array[0] = 0; /* break-here */
-+}
-+
-+#else
-+
-+void foo (int size);
-+
-+int
-+main (void)
-+{
-+ foo (26);
-+ foo (78);
-+ return 0;
-+}
-+
-+#endif
-diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.arch/x86_64-vla-pointer.exp
-@@ -0,0 +1,65 @@
-+# Copyright 2009 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/>.
-+
-+if ![istarget "x86_64-*-*"] then {
-+ verbose "Skipping over gdb.arch/x86_64-vla-pointer.exp test made only for x86_64."
-+ return
-+}
-+
-+set testfile x86_64-vla-pointer
-+set srcasmfile ${testfile}-foo.S
-+set srcfile ${testfile}.c
-+set binfile [standard_output_file ${testfile}]
-+set binobjfile [standard_output_file ${testfile}-foo.o]
-+if { [gdb_compile "${srcdir}/${subdir}/${srcasmfile}" "${binobjfile}" object {}] != "" } {
-+ untested "Couldn't compile test program"
-+ return -1
-+}
-+if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {}] != "" } {
-+ untested "Couldn't compile test program"
-+ return -1
-+}
-+
-+gdb_exit
-+gdb_start
-+gdb_reinitialize_dir $srcdir/$subdir
-+gdb_load ${binfile}
-+
-+if ![runto_main] {
-+ untested x86_64-vla-pointer
-+ return -1
-+}
-+
-+gdb_breakpoint $srcfile:[gdb_get_line_number "break-here"]
-+
-+gdb_continue_to_breakpoint "break-here"
-+
-+gdb_test "whatis array" "type = array_t" "first: whatis array"
-+gdb_test "whatis array_t" "type = char \\\[variable length\\\]" "first: whatis array_t"
-+gdb_test "ptype array" "type = char \\\[26\\\]" "first: ptype array"
-+
-+gdb_test "whatis *array" "type = char" "first: whatis *array"
-+gdb_test "ptype *array" "type = char" "first: ptype *array"
-+
-+gdb_test "p array\[1\]" "\\$\[0-9\] = 1 '\\\\001'"
-+gdb_test "p array\[2\]" "\\$\[0-9\] = 2 '\\\\002'"
-+gdb_test "p array\[3\]" "\\$\[0-9\] = 3 '\\\\003'"
-+gdb_test "p array\[4\]" "\\$\[0-9\] = 4 '\\\\004'"
-+
-+gdb_continue_to_breakpoint "break_here"
-+
-+gdb_test "whatis array" "type = array_t" "second: whatis array"
-+gdb_test "whatis array_t" "type = char \\\[variable length\\\]" "second: whatis array_t"
-+gdb_test "ptype array" "type = char \\\[78\\\]" "second: ptype array"
-diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef-foo.S
-@@ -0,0 +1,455 @@
-+ .file "x86_64-vla-typedef.c"
-+ .section .debug_abbrev,"",@progbits
-+.Ldebug_abbrev0:
-+ .section .debug_info,"",@progbits
-+.Ldebug_info0:
-+ .section .debug_line,"",@progbits
-+.Ldebug_line0:
-+ .text
-+.Ltext0:
-+.globl foo
-+ .type foo, @function
-+foo:
-+.LFB2:
-+ .file 1 "x86_64-vla-typedef.c"
-+ .loc 1 22 0
-+ pushq %rbp
-+.LCFI0:
-+ movq %rsp, %rbp
-+.LCFI1:
-+ subq $64, %rsp
-+.LCFI2:
-+ movl %edi, -36(%rbp)
-+ .loc 1 22 0
-+ movq %rsp, %rax
-+ movq %rax, -48(%rbp)
-+ .loc 1 23 0
-+ movl -36(%rbp), %edx
-+ movslq %edx,%rax
-+ subq $1, %rax
-+ movq %rax, -24(%rbp)
-+ .loc 1 24 0
-+ movslq %edx,%rax
-+ addq $15, %rax
-+ addq $15, %rax
-+ shrq $4, %rax
-+ salq $4, %rax
-+ subq %rax, %rsp
-+ movq %rsp, -56(%rbp)
-+ movq -56(%rbp), %rax
-+ addq $15, %rax
-+ shrq $4, %rax
-+ salq $4, %rax
-+ movq %rax, -56(%rbp)
-+ movq -56(%rbp), %rax
-+ movq %rax, -16(%rbp)
-+ .loc 1 27 0
-+ movl $0, -4(%rbp)
-+ jmp .L2
-+.L3:
-+ .loc 1 28 0
-+ movl -4(%rbp), %esi
-+ movl -4(%rbp), %eax
-+ movl %eax, %ecx
-+ movq -16(%rbp), %rdx
-+ movslq %esi,%rax
-+ movb %cl, (%rdx,%rax)
-+ .loc 1 27 0
-+ addl $1, -4(%rbp)
-+.L2:
-+ movl -4(%rbp), %eax
-+ cmpl -36(%rbp), %eax
-+ jl .L3
-+ .loc 1 30 0
-+ .globl break_here
-+break_here:
-+ movq -16(%rbp), %rax
-+ movb $0, (%rax)
-+ movq -48(%rbp), %rsp
-+ .loc 1 31 0
-+ leave
-+ ret
-+.LFE2:
-+ .size foo, .-foo
-+ .section .debug_frame,"",@progbits
-+.Lframe0:
-+ .long .LECIE0-.LSCIE0
-+.LSCIE0:
-+ .long 0xffffffff
-+ .byte 0x1
-+ .string ""
-+ .uleb128 0x1
-+ .sleb128 -8
-+ .byte 0x10
-+ .byte 0xc
-+ .uleb128 0x7
-+ .uleb128 0x8
-+ .byte 0x90
-+ .uleb128 0x1
-+ .align 8
-+.LECIE0:
-+.LSFDE0:
-+ .long .LEFDE0-.LASFDE0
-+.LASFDE0:
-+ .long .Lframe0
-+ .quad .LFB2
-+ .quad .LFE2-.LFB2
-+ .byte 0x4
-+ .long .LCFI0-.LFB2
-+ .byte 0xe
-+ .uleb128 0x10
-+ .byte 0x86
-+ .uleb128 0x2
-+ .byte 0x4
-+ .long .LCFI1-.LCFI0
-+ .byte 0xd
-+ .uleb128 0x6
-+ .align 8
-+.LEFDE0:
-+ .section .eh_frame,"a",@progbits
-+.Lframe1:
-+ .long .LECIE1-.LSCIE1
-+.LSCIE1:
-+ .long 0x0
-+ .byte 0x1
-+ .string "zR"
-+ .uleb128 0x1
-+ .sleb128 -8
-+ .byte 0x10
-+ .uleb128 0x1
-+ .byte 0x3
-+ .byte 0xc
-+ .uleb128 0x7
-+ .uleb128 0x8
-+ .byte 0x90
-+ .uleb128 0x1
-+ .align 8
-+.LECIE1:
-+.LSFDE1:
-+ .long .LEFDE1-.LASFDE1
-+.LASFDE1:
-+ .long .LASFDE1-.Lframe1
-+ .long .LFB2
-+ .long .LFE2-.LFB2
-+ .uleb128 0x0
-+ .byte 0x4
-+ .long .LCFI0-.LFB2
-+ .byte 0xe
-+ .uleb128 0x10
-+ .byte 0x86
-+ .uleb128 0x2
-+ .byte 0x4
-+ .long .LCFI1-.LCFI0
-+ .byte 0xd
-+ .uleb128 0x6
-+ .align 8
-+.LEFDE1:
-+ .text
-+.Letext0:
-+ .section .debug_loc,"",@progbits
-+.Ldebug_loc0:
-+.LLST0:
-+ .quad .LFB2-.Ltext0
-+ .quad .LCFI0-.Ltext0
-+ .value 0x2
-+ .byte 0x77
-+ .sleb128 8
-+ .quad .LCFI0-.Ltext0
-+ .quad .LCFI1-.Ltext0
-+ .value 0x2
-+ .byte 0x77
-+ .sleb128 16
-+ .quad .LCFI1-.Ltext0
-+ .quad .LFE2-.Ltext0
-+ .value 0x2
-+ .byte 0x76
-+ .sleb128 16
-+ .quad 0x0
-+ .quad 0x0
-+ .section .debug_info
-+ .long .Ldebug_end - .Ldebug_start
-+.Ldebug_start:
-+ .value 0x2
-+ .long .Ldebug_abbrev0
-+ .byte 0x8
-+ .uleb128 0x1
-+ .long .LASF2
-+ .byte 0x1
-+ .long .LASF3
-+ .long .LASF4
-+ .quad .Ltext0
-+ .quad .Letext0
-+ .long .Ldebug_line0
-+ .uleb128 0x2
-+ .byte 0x1
-+ .string "foo"
-+ .byte 0x1
-+ .byte 0x16
-+ .byte 0x1
-+ .quad .LFB2
-+ .quad .LFE2
-+ .long .LLST0
-+ .long 0x83
-+ .uleb128 0x3
-+ .long .LASF5
-+ .byte 0x1
-+ .byte 0x15
-+ .long 0x83
-+ .byte 0x2
-+ .byte 0x91
-+ .sleb128 -52
-+.Ltag_typedef:
-+ .uleb128 0x4
-+ .long .LASF6
-+ .byte 0x1
-+ .byte 0x17
-+ .long .Ltag_array_type - .debug_info
-+ .uleb128 0x5 /* Abbrev Number: 5 (DW_TAG_variable) */
-+ .long .LASF0
-+ .byte 0x1
-+ .byte 0x18
-+#if 1
-+ .long .Ltag_typedef - .debug_info
-+#else
-+ /* Debugging only: Skip the typedef indirection. */
-+ .long .Ltag_array_type - .debug_info
-+#endif
-+ /* DW_AT_location: DW_FORM_block1: start */
-+ .byte 0x3
-+ .byte 0x91
-+ .sleb128 -32
-+#if 0
-+ .byte 0x6 /* DW_OP_deref */
-+#else
-+ .byte 0x96 /* DW_OP_nop */
-+#endif
-+ /* DW_AT_location: DW_FORM_block1: end */
-+ .uleb128 0x6
-+ .string "i"
-+ .byte 0x1
-+ .byte 0x19
-+ .long 0x83
-+ .byte 0x2
-+ .byte 0x91
-+ .sleb128 -20
-+ .byte 0x0
-+ .uleb128 0x7
-+ .byte 0x4
-+ .byte 0x5
-+ .string "int"
-+.Ltag_array_type:
-+ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */
-+ .long 0xa0 + (2f - 1f) /* DW_AT_type: DW_FORM_ref4 */
-+ .long 0x9d + (2f - 1f) /* DW_AT_sibling: DW_FORM_ref4 */
-+1: /* DW_AT_data_location: DW_FORM_block1: start */
-+ .byte 2f - 3f /* length */
-+3:
-+ .byte 0x97 /* DW_OP_push_object_address */
-+ .byte 0x6 /* DW_OP_deref */
-+2: /* DW_AT_data_location: DW_FORM_block1: end */
-+ .uleb128 0x9
-+ .long 0x9d + (2b - 1b) /* DW_AT_type: DW_FORM_ref4 */
-+ .byte 0x3
-+ .byte 0x91
-+ .sleb128 -40
-+ .byte 0x6
-+ .byte 0x0
-+ .uleb128 0xa
-+ .byte 0x8
-+ .byte 0x7
-+ .uleb128 0xb
-+ .byte 0x1
-+ .byte 0x6
-+ .long .LASF1
-+ .byte 0x0
-+.Ldebug_end:
-+ .section .debug_abbrev
-+ .uleb128 0x1
-+ .uleb128 0x11
-+ .byte 0x1
-+ .uleb128 0x25
-+ .uleb128 0xe
-+ .uleb128 0x13
-+ .uleb128 0xb
-+ .uleb128 0x3
-+ .uleb128 0xe
-+ .uleb128 0x1b
-+ .uleb128 0xe
-+ .uleb128 0x11
-+ .uleb128 0x1
-+ .uleb128 0x12
-+ .uleb128 0x1
-+ .uleb128 0x10
-+ .uleb128 0x6
-+ .byte 0x0
-+ .byte 0x0
-+ .uleb128 0x2
-+ .uleb128 0x2e
-+ .byte 0x1
-+ .uleb128 0x3f
-+ .uleb128 0xc
-+ .uleb128 0x3
-+ .uleb128 0x8
-+ .uleb128 0x3a
-+ .uleb128 0xb
-+ .uleb128 0x3b
-+ .uleb128 0xb
-+ .uleb128 0x27
-+ .uleb128 0xc
-+ .uleb128 0x11
-+ .uleb128 0x1
-+ .uleb128 0x12
-+ .uleb128 0x1
-+ .uleb128 0x40
-+ .uleb128 0x6
-+ .uleb128 0x1
-+ .uleb128 0x13
-+ .byte 0x0
-+ .byte 0x0
-+ .uleb128 0x3
-+ .uleb128 0x5
-+ .byte 0x0
-+ .uleb128 0x3
-+ .uleb128 0xe
-+ .uleb128 0x3a
-+ .uleb128 0xb
-+ .uleb128 0x3b
-+ .uleb128 0xb
-+ .uleb128 0x49
-+ .uleb128 0x13
-+ .uleb128 0x2
-+ .uleb128 0xa
-+ .byte 0x0
-+ .byte 0x0
-+ .uleb128 0x4
-+ .uleb128 0x16
-+ .byte 0x0
-+ .uleb128 0x3
-+ .uleb128 0xe
-+ .uleb128 0x3a
-+ .uleb128 0xb
-+ .uleb128 0x3b
-+ .uleb128 0xb
-+ .uleb128 0x49
-+ .uleb128 0x13
-+ .byte 0x0
-+ .byte 0x0
-+ .uleb128 0x5
-+ .uleb128 0x34
-+ .byte 0x0
-+ .uleb128 0x3
-+ .uleb128 0xe
-+ .uleb128 0x3a
-+ .uleb128 0xb
-+ .uleb128 0x3b
-+ .uleb128 0xb
-+ .uleb128 0x49
-+ .uleb128 0x13
-+ .uleb128 0x2
-+ .uleb128 0xa
-+ .byte 0x0
-+ .byte 0x0
-+ .uleb128 0x6
-+ .uleb128 0x34
-+ .byte 0x0
-+ .uleb128 0x3
-+ .uleb128 0x8
-+ .uleb128 0x3a
-+ .uleb128 0xb
-+ .uleb128 0x3b
-+ .uleb128 0xb
-+ .uleb128 0x49
-+ .uleb128 0x13
-+ .uleb128 0x2
-+ .uleb128 0xa
-+ .byte 0x0
-+ .byte 0x0
-+ .uleb128 0x7
-+ .uleb128 0x24
-+ .byte 0x0
-+ .uleb128 0xb
-+ .uleb128 0xb
-+ .uleb128 0x3e
-+ .uleb128 0xb
-+ .uleb128 0x3
-+ .uleb128 0x8
-+ .byte 0x0
-+ .byte 0x0
-+ .uleb128 0x8 /* Abbrev Number: 8 (DW_TAG_array_type) */
-+ .uleb128 0x1
-+ .byte 0x1
-+ .uleb128 0x49 /* DW_AT_type */
-+ .uleb128 0x13 /* DW_FORM_ref4 */
-+ .uleb128 0x1 /* DW_AT_sibling */
-+ .uleb128 0x13 /* DW_FORM_ref4 */
-+ .uleb128 0x50 /* DW_AT_data_location */
-+ .uleb128 0xa /* DW_FORM_block1 */
-+ .byte 0x0
-+ .byte 0x0
-+ .uleb128 0x9
-+ .uleb128 0x21
-+ .byte 0x0
-+ .uleb128 0x49 /* DW_AT_type */
-+ .uleb128 0x13 /* DW_FORM_ref4 */
-+ .uleb128 0x2f
-+ .uleb128 0xa
-+ .byte 0x0
-+ .byte 0x0
-+ .uleb128 0xa
-+ .uleb128 0x24
-+ .byte 0x0
-+ .uleb128 0xb
-+ .uleb128 0xb
-+ .uleb128 0x3e
-+ .uleb128 0xb
-+ .byte 0x0
-+ .byte 0x0
-+ .uleb128 0xb
-+ .uleb128 0x24
-+ .byte 0x0
-+ .uleb128 0xb
-+ .uleb128 0xb
-+ .uleb128 0x3e
-+ .uleb128 0xb
-+ .uleb128 0x3
-+ .uleb128 0xe
-+ .byte 0x0
-+ .byte 0x0
-+ .byte 0x0
-+ .section .debug_pubnames,"",@progbits
-+ .long 0x16
-+ .value 0x2
-+ .long .Ldebug_info0
-+ .long 0xa8
-+ .long 0x2d
-+ .string "foo"
-+ .long 0x0
-+ .section .debug_aranges,"",@progbits
-+ .long 0x2c
-+ .value 0x2
-+ .long .Ldebug_info0
-+ .byte 0x8
-+ .byte 0x0
-+ .value 0x0
-+ .value 0x0
-+ .quad .Ltext0
-+ .quad .Letext0-.Ltext0
-+ .quad 0x0
-+ .quad 0x0
-+ .section .debug_str,"MS",@progbits,1
-+.LASF0:
-+ .string "array"
-+.LASF5:
-+ .string "size"
-+.LASF3:
-+ .string "x86_64-vla-typedef.c"
-+.LASF6:
-+ .string "array_t"
-+.LASF1:
-+ .string "char"
-+.LASF4:
-+ .string "gdb.arch"
-+.LASF2:
-+ .string "GNU C 4.3.2 20081105 (Red Hat 4.3.2-7)"
-+ .ident "GCC: (GNU) 4.3.2 20081105 (Red Hat 4.3.2-7)"
-+ .section .note.GNU-stack,"",@progbits
-diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.c
-@@ -0,0 +1,45 @@
-+/* This testcase is part of GDB, the GNU debugger.
-+
-+ Copyright 2008 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/>. */
-+
-+#if 0
-+
-+void
-+foo (int size)
-+{
-+ typedef char array_t[size];
-+ array_t array;
-+ int i;
-+
-+ for (i = 0; i < size; i++)
-+ array[i] = i;
-+
-+ array[0] = 0; /* break-here */
-+}
-+
-+#else
-+
-+void foo (int size);
-+
-+int
-+main (void)
-+{
-+ foo (26);
-+ foo (78);
-+ return 0;
-+}
-+
-+#endif
-diff --git a/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.arch/x86_64-vla-typedef.exp
-@@ -0,0 +1,64 @@
-+# Copyright 2009 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/>.
-+
-+# Test DW_AT_data_location accessed through DW_TAG_typedef intermediate.
-+
-+if ![istarget "x86_64-*-*"] then {
-+ verbose "Skipping over gdb.arch/x86_64-vla-typedef.exp test made only for x86_64."
-+ return
-+}
-+
-+set testfile x86_64-vla-typedef
-+set srcasmfile ${testfile}-foo.S
-+set srcfile ${testfile}.c
-+set binfile [standard_output_file ${testfile}]
-+set binobjfile [standard_output_file ${testfile}-foo.o]
-+if { [gdb_compile "${srcdir}/${subdir}/${srcasmfile}" "${binobjfile}" object {}] != "" } {
-+ untested "Couldn't compile test program"
-+ return -1
-+}
-+if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${binobjfile}" "${binfile}" executable {debug}] != "" } {
-+ untested "Couldn't compile test program"
-+ return -1
-+}
-+
-+gdb_exit
-+gdb_start
-+gdb_reinitialize_dir $srcdir/$subdir
-+gdb_load ${binfile}
-+
-+if ![runto_main] {
-+ untested x86_64-vla-typedef
-+ return -1
-+}
-+
-+gdb_breakpoint "break_here"
-+
-+gdb_continue_to_breakpoint "break_here"
-+
-+gdb_test "whatis array" "type = array_t" "first: whatis array"
-+
-+gdb_test "ptype array" "type = char \\\[26\\\]" "first: ptype array"
-+
-+gdb_test "p array\[1\]" "\\$\[0-9\] = 1 '\\\\001'"
-+gdb_test "p array\[2\]" "\\$\[0-9\] = 2 '\\\\002'"
-+gdb_test "p array\[3\]" "\\$\[0-9\] = 3 '\\\\003'"
-+gdb_test "p array\[4\]" "\\$\[0-9\] = 4 '\\\\004'"
-+
-+gdb_continue_to_breakpoint "break_here"
-+
-+gdb_test "whatis array" "type = array_t" "second: whatis array"
-+
-+gdb_test "ptype array" "type = char \\\[78\\\]" "second: ptype array"
-diff --git a/gdb/testsuite/gdb.base/arrayidx.c b/gdb/testsuite/gdb.base/arrayidx.c
---- a/gdb/testsuite/gdb.base/arrayidx.c
-+++ b/gdb/testsuite/gdb.base/arrayidx.c
-@@ -17,6 +17,13 @@
-
- int array[] = {1, 2, 3, 4};
-
-+#ifdef __GNUC__
-+struct
-+ {
-+ int a[0];
-+ } unbound;
-+#endif
-+
- int
- main (void)
- {
-diff --git a/gdb/testsuite/gdb.base/arrayidx.exp b/gdb/testsuite/gdb.base/arrayidx.exp
---- a/gdb/testsuite/gdb.base/arrayidx.exp
-+++ b/gdb/testsuite/gdb.base/arrayidx.exp
-@@ -49,4 +49,12 @@ gdb_test "print array" \
- "\\{\\\[0\\\] = 1, \\\[1\\\] = 2, \\\[2\\\] = 3, \\\[3\\\] = 4\\}" \
- "print array with array-indexes on"
-
--
-+set test "p unbound.a == &unbound.a\[0\]"
-+gdb_test_multiple $test $test {
-+ -re " = 1\r\n$gdb_prompt $" {
-+ pass $test
-+ }
-+ -re "No symbol \"unbound\" in current context.\r\n$gdb_prompt $" {
-+ unsupported "$test (no GCC)"
-+ }
-+}
-diff --git a/gdb/testsuite/gdb.base/internal-var-field-address.c b/gdb/testsuite/gdb.base/internal-var-field-address.c
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.base/internal-var-field-address.c
-@@ -0,0 +1,20 @@
-+/* This testcase is part of GDB, the GNU debugger.
-+
-+ Copyright 2009 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/>. */
-+
-+struct {
-+ int field;
-+} staticstruct = { 1 };
-diff --git a/gdb/testsuite/gdb.base/internal-var-field-address.exp b/gdb/testsuite/gdb.base/internal-var-field-address.exp
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.base/internal-var-field-address.exp
-@@ -0,0 +1,26 @@
-+# Copyright 2009 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/>.
-+
-+set test internal-var-field-address
-+set binfile ${test}.x
-+if { [gdb_compile "${srcdir}/${subdir}/${test}.c" "[standard_output_file ${binfile}]" object {debug}] != "" } {
-+ untested "Couldn't compile test program"
-+ return -1
-+}
-+
-+clean_restart $binfile
-+
-+gdb_test {set $varstruct = staticstruct}
-+gdb_test {p $varstruct.field} " = 1"
-diff --git a/gdb/testsuite/gdb.base/vla-frame.c b/gdb/testsuite/gdb.base/vla-frame.c
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.base/vla-frame.c
-@@ -0,0 +1,31 @@
-+/* This testcase is part of GDB, the GNU debugger.
-+
-+ Copyright 2011 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/>. */
-+
-+#include <string.h>
-+
-+int
-+main (int argc, char **argv)
-+{
-+ char s[2 + argc];
-+ void (*f) (char *) = 0;
-+
-+ memset (s, 0, sizeof (s));
-+ s[0] = 'X';
-+
-+ f (s);
-+ return 0;
-+}
-diff --git a/gdb/testsuite/gdb.base/vla-frame.exp b/gdb/testsuite/gdb.base/vla-frame.exp
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.base/vla-frame.exp
-@@ -0,0 +1,38 @@
-+# Copyright 2011 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/>.
-+
-+set testfile vla-frame
-+set executable ${testfile}
-+
-+if { [prepare_for_testing ${testfile}.exp ${executable}] } {
-+ return -1
-+}
-+
-+if ![runto_main] {
-+ return -1
-+}
-+
-+set test "continue"
-+gdb_test_multiple $test $test {
-+ -re "Continuing\\.\r\n\r\nProgram received signal SIGSEGV, Segmentation fault\\.\r\n0x0+ in \\?\\? \\(\\)\r\n$gdb_prompt $" {
-+ pass $test
-+ }
-+ -re "\r\n$gdb_prompt $" {
-+ untested ${testfile}.exp
-+ return
-+ }
-+}
-+
-+gdb_test "bt full" "\r\n +s = \"X\\\\000\"\r\n.*"
-diff --git a/gdb/testsuite/gdb.base/vla-overflow.c b/gdb/testsuite/gdb.base/vla-overflow.c
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.base/vla-overflow.c
-@@ -0,0 +1,30 @@
-+/* This testcase is part of GDB, the GNU debugger.
-+
-+ Copyright 2008 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/>. */
-+
-+#include <stdlib.h>
-+
-+int
-+main (int argc, char **argv)
-+{
-+ int array[argc];
-+
-+ array[0] = array[0];
-+
-+ abort ();
-+
-+ return 0;
-+}
-diff --git a/gdb/testsuite/gdb.base/vla-overflow.exp b/gdb/testsuite/gdb.base/vla-overflow.exp
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.base/vla-overflow.exp
-@@ -0,0 +1,109 @@
-+# Copyright 2008 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/>.
-+
-+# We could crash in:
-+# #0 block_linkage_function (bl=0x0) at ../../gdb/block.c:69
-+# #1 in dwarf_block_get_frame_base (...) at ../../gdb/dwarf2block.c:97
-+# 97 framefunc = block_linkage_function (get_frame_block (frame, NULL));
-+# #2 in execute_stack_op (...) at ../../gdb/dwarf2expr.c:496
-+# #3 in dwarf_block_exec_core () at ../../gdb/dwarf2block.c:156
-+# #4 dwarf_block_exec (...) at ../../gdb/dwarf2block.c:206
-+# #5 in range_type_count_bound_internal (...) at ../../gdb/gdbtypes.c:1430
-+# #6 in create_array_type (...) at ../../gdb/gdbtypes.c:840
-+# ...
-+# #21 in psymtab_to_symtab (...) at ../../gdb/symfile.c:292
-+# ...
-+# #29 in backtrace_command_1 () at ../../gdb/stack.c:1273
-+
-+set testfile vla-overflow
-+set shfile [standard_output_file ${testfile}-gdb.sh]
-+set srcfile ${testfile}.c
-+set binfile [standard_output_file ${testfile}]
-+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-+ untested "Couldn't compile test program"
-+ return -1
-+}
-+
-+set f [open "|getconf PAGESIZE" "r"]
-+gets $f pagesize
-+close $f
-+
-+gdb_exit
-+gdb_start
-+gdb_reinitialize_dir $srcdir/$subdir
-+gdb_load ${binfile}
-+
-+set pid_of_gdb [exp_pid -i [board_info host fileid]]
-+
-+if { [runto_main] < 0 } {
-+ untested vla-overflow
-+ return -1
-+}
-+
-+# Get the GDB memory size when we stay at main.
-+
-+proc memory_v_pages_get {} {
-+ global pid_of_gdb pagesize
-+ set fd [open "/proc/$pid_of_gdb/statm"]
-+ gets $fd line
-+ close $fd
-+ # number of pages of virtual memory
-+ scan $line "%d" drs
-+ return $drs
-+}
-+
-+set pages_found [memory_v_pages_get]
-+
-+# s390x with glibc-debuginfo.s390x installed used approx. 16MB.
-+set mb_reserve 40
-+verbose -log "pages_found = $pages_found, mb_reserve = $mb_reserve"
-+set kb_found [expr $pages_found * $pagesize / 1024]
-+set kb_permit [expr $kb_found + 1 * 1024 + $mb_reserve * 1024]
-+verbose -log "kb_found = $kb_found, kb_permit = $kb_permit"
-+
-+# Create the ulimit wrapper.
-+set f [open $shfile "w"]
-+puts $f "#! /bin/sh"
-+puts $f "ulimit -v $kb_permit"
-+puts $f "exec $GDB \"\$@\""
-+close $f
-+remote_exec host "chmod +x $shfile"
-+
-+gdb_exit
-+set GDBold $GDB
-+set GDB "$shfile"
-+gdb_start
-+set GDB $GDBold
-+
-+gdb_reinitialize_dir $srcdir/$subdir
-+gdb_load ${binfile}
-+
-+set pid_of_gdb [exp_pid -i [board_info host fileid]]
-+
-+# Check the size again after the second run.
-+# We must not stop in main as it would cache `array' and never crash later.
-+
-+gdb_run_cmd
-+
-+verbose -log "kb_found before abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
-+
-+gdb_test "" "Program received signal SIGABRT, Aborted..*" "Enter abort()"
-+
-+verbose -log "kb_found in abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
-+
-+# `abort' can get expressed as `*__GI_abort'.
-+gdb_test "bt" "in \[^ \]*abort \\(.* in main \\(.*" "Backtrace after abort()"
-+
-+verbose -log "kb_found in bt after abort() = [expr [memory_v_pages_get] * $pagesize / 1024]"
-diff --git a/gdb/testsuite/gdb.base/vla.c b/gdb/testsuite/gdb.base/vla.c
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.base/vla.c
-@@ -0,0 +1,55 @@
-+/* This testcase is part of GDB, the GNU debugger.
-+
-+ Copyright 2008 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/>. */
-+
-+#include <string.h>
-+
-+void
-+marker (void)
-+{
-+}
-+
-+void
-+bar (char *a, char *b, char *c, int size)
-+{
-+ memset (a, '1', size);
-+ memset (b, '2', size);
-+ memset (c, '3', 48);
-+}
-+
-+void
-+foo (int size)
-+{
-+ char temp1[size];
-+ char temp3[48];
-+
-+ temp1[size - 1] = '\0';
-+ {
-+ char temp2[size];
-+
-+ bar (temp1, temp2, temp3, size);
-+
-+ marker (); /* break-here */
-+ }
-+}
-+
-+int
-+main (void)
-+{
-+ foo (26);
-+ foo (78);
-+ return 0;
-+}
-diff --git a/gdb/testsuite/gdb.base/vla.exp b/gdb/testsuite/gdb.base/vla.exp
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.base/vla.exp
-@@ -0,0 +1,62 @@
-+# Copyright 2008 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/>.
-+
-+set testfile vla
-+set srcfile ${testfile}.c
-+set binfile [standard_output_file ${testfile}]
-+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
-+ untested "Couldn't compile test program"
-+ return -1
-+}
-+
-+gdb_exit
-+gdb_start
-+gdb_reinitialize_dir $srcdir/$subdir
-+gdb_load ${binfile}
-+
-+if ![runto_main] {
-+ untested vla
-+ return -1
-+}
-+
-+gdb_breakpoint [gdb_get_line_number "break-here"]
-+
-+gdb_continue_to_breakpoint "break-here"
-+
-+gdb_test "whatis temp1" "type = char \\\[26\\\]" "first: whatis temp1"
-+gdb_test "whatis temp2" "type = char \\\[26\\\]" "first: whatis temp2"
-+gdb_test "whatis temp3" "type = char \\\[48\\\]" "first: whatis temp3"
-+
-+gdb_test "ptype temp1" "type = char \\\[26\\\]" "first: ptype temp1"
-+gdb_test "ptype temp2" "type = char \\\[26\\\]" "first: ptype temp2"
-+gdb_test "ptype temp3" "type = char \\\[48\\\]" "first: ptype temp3"
-+
-+gdb_test "p temp1" " = '1' <repeats 26 times>" "first: print temp1"
-+gdb_test "p temp2" " = '2' <repeats 26 times>" "first: print temp2"
-+gdb_test "p temp3" " = '3' <repeats 48 times>" "first: print temp3"
-+
-+gdb_continue_to_breakpoint "break-here"
-+
-+gdb_test "whatis temp1" "type = char \\\[78\\\]" "second: whatis temp1"
-+gdb_test "whatis temp2" "type = char \\\[78\\\]" "second: whatis temp2"
-+gdb_test "whatis temp3" "type = char \\\[48\\\]" "second: whatis temp3"
-+
-+gdb_test "ptype temp1" "type = char \\\[78\\\]" "second: ptype temp1"
-+gdb_test "ptype temp2" "type = char \\\[78\\\]" "second: ptype temp2"
-+gdb_test "ptype temp3" "type = char \\\[48\\\]" "second: ptype temp3"
-+
-+gdb_test "p temp1" " = '1' <repeats 78 times>" "second: print temp1"
-+gdb_test "p temp2" " = '2' <repeats 78 times>" "second: print temp2"
-+gdb_test "p temp3" " = '3' <repeats 48 times>" "second: print temp3"
-diff --git a/gdb/testsuite/gdb.cp/gdb9593.cc b/gdb/testsuite/gdb.cp/gdb9593.cc
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.cp/gdb9593.cc
-@@ -0,0 +1,179 @@
-+/* This testcase is part of GDB, the GNU debugger.
-+
-+ Copyright 2008, 2009 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/>.
-+ */
-+#include <iostream>
-+
-+using namespace std;
-+
-+class NextOverThrowDerivates
-+{
-+
-+public:
-+
-+
-+ // Single throw an exception in this function.
-+ void function1()
-+ {
-+ throw 20;
-+ }
-+
-+ // Throw an exception in another function.
-+ void function2()
-+ {
-+ function1();
-+ }
-+
-+ // Throw an exception in another function, but handle it
-+ // locally.
-+ void function3 ()
-+ {
-+ {
-+ try
-+ {
-+ function1 ();
-+ }
-+ catch (...)
-+ {
-+ cout << "Caught and handled function1 exception" << endl;
-+ }
-+ }
-+ }
-+
-+ void rethrow ()
-+ {
-+ try
-+ {
-+ function1 ();
-+ }
-+ catch (...)
-+ {
-+ throw;
-+ }
-+ }
-+
-+ void finish ()
-+ {
-+ // We use this to test that a "finish" here does not end up in
-+ // this frame, but in the one above.
-+ try
-+ {
-+ function1 ();
-+ }
-+ catch (int x)
-+ {
-+ }
-+ function1 (); // marker for until
-+ }
-+
-+ void until ()
-+ {
-+ function1 ();
-+ function1 (); // until here
-+ }
-+
-+};
-+NextOverThrowDerivates next_cases;
-+
-+
-+int main ()
-+{
-+ try
-+ {
-+ next_cases.function1 ();
-+ }
-+ catch (...)
-+ {
-+ // Discard
-+ }
-+
-+ try
-+ {
-+ next_cases.function2 ();
-+ }
-+ catch (...)
-+ {
-+ // Discard
-+ }
-+
-+ try
-+ {
-+ // This is duplicated so we can next over one but step into
-+ // another.
-+ next_cases.function2 ();
-+ }
-+ catch (...)
-+ {
-+ // Discard
-+ }
-+
-+ next_cases.function3 ();
-+
-+ try
-+ {
-+ next_cases.rethrow ();
-+ }
-+ catch (...)
-+ {
-+ // Discard
-+ }
-+
-+ try
-+ {
-+ // Another duplicate so we can test "finish".
-+ next_cases.function2 ();
-+ }
-+ catch (...)
-+ {
-+ // Discard
-+ }
-+
-+ // Another test for "finish".
-+ try
-+ {
-+ next_cases.finish ();
-+ }
-+ catch (...)
-+ {
-+ }
-+
-+ // Test of "until".
-+ try
-+ {
-+ next_cases.finish ();
-+ }
-+ catch (...)
-+ {
-+ }
-+
-+ // Test of "until" with an argument.
-+ try
-+ {
-+ next_cases.until ();
-+ }
-+ catch (...)
-+ {
-+ }
-+
-+ // Test of "advance".
-+ try
-+ {
-+ next_cases.until ();
-+ }
-+ catch (...)
-+ {
-+ }
-+}
-diff --git a/gdb/testsuite/gdb.cp/gdb9593.exp b/gdb/testsuite/gdb.cp/gdb9593.exp
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.cp/gdb9593.exp
-@@ -0,0 +1,189 @@
-+# Copyright 2008, 2009 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/>.
-+
-+
-+if $tracelevel then {
-+ strace $tracelevel
-+}
-+
-+if { [skip_cplus_tests] } { continue }
-+
-+set testfile "gdb9593"
-+set srcfile ${testfile}.cc
-+set binfile [standard_output_file $testfile]
-+
-+# Create and source the file that provides information about the compiler
-+# used to compile the test case.
-+if [get_compiler_info "c++"] {
-+ untested gdb9593.exp
-+ return -1
-+}
-+
-+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug c++}] != "" } {
-+ untested gdb9593.exp
-+ return -1
-+}
-+
-+# Some targets can't do function calls, so don't even bother with this
-+# test.
-+if [target_info exists gdb,cannot_call_functions] {
-+ setup_xfail "*-*-*" 9593
-+ fail "This target can not call functions"
-+ continue
-+}
-+
-+gdb_exit
-+gdb_start
-+gdb_reinitialize_dir $srcdir/$subdir
-+gdb_load ${binfile}
-+
-+if ![runto_main] then {
-+ perror "couldn't run to main"
-+ continue
-+}
-+
-+# See whether we have the needed unwinder hooks.
-+set ok 1
-+gdb_test_multiple "print _Unwind_DebugHook" "check for unwinder hook" {
-+ -re "= .*_Unwind_DebugHook.*\r\n$gdb_prompt $" {
-+ pass "check for unwinder hook"
-+ }
-+ -re "No symbol .* in current context.\r\n$gdb_prompt $" {
-+ # Pass the test so we don't get bogus fails in the results.
-+ pass "check for unwinder hook"
-+ set ok 0
-+ }
-+}
-+if {!$ok} {
-+ untested gdb9593.exp
-+ return -1
-+}
-+
-+# See http://sourceware.org/bugzilla/show_bug.cgi?id=9593
-+
-+gdb_test "next" \
-+ ".*catch (...).*" \
-+ "next over a throw 1"
-+
-+gdb_test "next" \
-+ ".*next_cases.function2.*" \
-+ "next past catch 1"
-+
-+gdb_test "next" \
-+ ".*catch (...).*" \
-+ "next over a throw 2"
-+
-+gdb_test "next" \
-+ ".*next_cases.function2.*" \
-+ "next past catch 2"
-+
-+gdb_test "step" \
-+ ".*function1().*" \
-+ "step into function2 1"
-+
-+gdb_test "next" \
-+ ".*catch (...).*" \
-+ "next over a throw 3"
-+
-+gdb_test "next" \
-+ ".*next_cases.function3.*" \
-+ "next past catch 3"
-+
-+gdb_test "next" \
-+ ".*next_cases.rethrow.*" \
-+ "next over a throw 4"
-+
-+gdb_test "next" \
-+ ".*catch (...).*" \
-+ "next over a rethrow"
-+
-+gdb_test "next" \
-+ ".*next_cases.function2.*" \
-+ "next after a rethrow"
-+
-+gdb_test "step" \
-+ ".*function1().*" \
-+ "step into function2 2"
-+
-+gdb_test "finish" \
-+ ".*catch (...).*" \
-+ "finish 1"
-+
-+gdb_test "next" \
-+ ".*next_cases.finish ().*" \
-+ "next past catch 4"
-+
-+gdb_test "step" \
-+ ".*function1 ().*" \
-+ "step into finish method"
-+
-+gdb_test "finish" \
-+ ".*catch (...).*" \
-+ "finish 2"
-+
-+gdb_test "next" \
-+ ".*next_cases.finish ().*" \
-+ "next past catch 5"
-+
-+gdb_test "step" \
-+ ".*function1 ().*" \
-+ "step into finish, for until"
-+
-+gdb_test_multiple "until" "until with no argument 1" {
-+ -re -wrap ".*function1 ().*" {
-+ pass $gdb_test_name
-+ }
-+ -re -wrap ".*$hex\t80\t \}" {
-+ # PR gcc/97774 - "Incorrect line info for try/catch"
-+ # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97774
-+ xfail $gdb_test_name
-+ }
-+}
-+
-+set line [gdb_get_line_number "marker for until" $testfile.cc]
-+
-+gdb_test "until $line" \
-+ ".*function1 ().*" \
-+ "next past catch 6"
-+
-+gdb_test "until" \
-+ ".*catch (...).*" \
-+ "until with no argument 2"
-+
-+set line [gdb_get_line_number "until here" $testfile.cc]
-+
-+gdb_test "next" \
-+ ".*next_cases.until ().*" \
-+ "next past catch 6"
-+
-+gdb_test "step" \
-+ ".*function1 ().*" \
-+ "step into until"
-+
-+gdb_test "until $line" \
-+ ".*catch (...).*" \
-+ "until-over-throw"
-+
-+gdb_test "next" \
-+ ".*next_cases.until ().*" \
-+ "next past catch 7"
-+
-+gdb_test "step" \
-+ ".*function1 ().*" \
-+ "step into until, for advance"
-+
-+gdb_test "advance $line" \
-+ ".*catch (...).*" \
-+ "advance-over-throw"
-diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.S
-@@ -0,0 +1,246 @@
-+/* This testcase is part of GDB, the GNU debugger.
-+
-+ Copyright 2010 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/>. */
-+
-+/* Debug information */
-+
-+/* We will `break *main' at the very first instruction. */
-+#define main_length 1
-+
-+ .section .data
-+vardata:
-+ /* See DW_OP_lit3 + 1 (0-based). */
-+ .string "seennotseen"
-+
-+ .section .debug_info
-+.Lcu1_begin:
-+ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */
-+.Lcu1_start:
-+ .2byte 2 /* DWARF version number */
-+ .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */
-+ .byte 4 /* Pointer Size (in bytes) */
-+
-+ /* CU die */
-+ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */
-+ .4byte .Lproducer /* DW_AT_producer */
-+ /* Use C++ to exploit a bug in parsing DW_AT_name "". */
-+ .byte 4 /* DW_AT_language (C++) - */
-+ .4byte main /* DW_AT_low_pc */
-+ .byte main_length /* DW_AT_high_pc */
-+
-+.Larray_type:
-+ .uleb128 2 /* Abbrev: DW_TAG_array_type */
-+ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */
-+
-+ .uleb128 3 /* Abbrev: DW_TAG_subrange_type */
-+ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
-+ .byte 0 /* DW_AT_lower_bound */
-+ .4byte .Llen_var-.Lcu1_begin /* DW_AT_upper_bound */
-+ .byte 0 /* End of children of die */
-+
-+ /* DW_AT_upper_bound is referencing an optimized-out variable. */
-+.Larrayb_type:
-+ .uleb128 2 /* Abbrev: DW_TAG_array_type */
-+ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */
-+
-+ .uleb128 3 /* Abbrev: DW_TAG_subrange_type */
-+ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
-+ .byte 0 /* DW_AT_lower_bound */
-+ .4byte .Llenb_var-.Lcu1_begin /* DW_AT_upper_bound */
-+ .byte 0 /* End of children of die */
-+
-+ /* DW_AT_upper_bound is referencing register. */
-+.Larrayreg_type:
-+ .uleb128 2 /* Abbrev: DW_TAG_array_type */
-+ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */
-+
-+ .uleb128 8 /* Abbrev: DW_TAG_subrange_type with block */
-+ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
-+ .byte 0 /* DW_AT_lower_bound */
-+ .byte 2f - 1f /* DW_AT_upper_bound */
-+1: .byte 0x50 /* DW_OP_reg0 */
-+2:
-+ .byte 0 /* End of children of die */
-+
-+.Luint_type:
-+ .uleb128 4 /* Abbrev: DW_TAG_base_type */
-+ .4byte .Luint_str /* DW_AT_name */
-+ .byte 4 /* DW_AT_byte_size */
-+ .byte 7 /* DW_AT_encoding */
-+
-+.Lchar_type:
-+ .uleb128 4 /* Abbrev: DW_TAG_base_type */
-+ .4byte .Lchar_str /* DW_AT_name */
-+ .byte 1 /* DW_AT_byte_size */
-+ .byte 6 /* DW_AT_encoding */
-+
-+.Llen_var:
-+ .uleb128 5 /* Abbrev: DW_TAG_variable artificial */
-+ .byte 1 /* DW_AT_artificial */
-+ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
-+ .4byte .Llen_loclist-.Lloclist /* DW_AT_location */
-+
-+ /* optimized-out variable for b_string. */
-+.Llenb_var:
-+ .uleb128 7 /* Abbrev: DW_TAG_variable artificial no DW_AT_location */
-+ .byte 1 /* DW_AT_artificial */
-+ .4byte .Luint_type-.Lcu1_begin /* DW_AT_type */
-+
-+ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */
-+ .string "a_string" /* DW_AT_name */
-+ .4byte .Larray_type-.Lcu1_begin /* DW_AT_type */
-+ .byte 2f - 1f /* DW_AT_location */
-+1: .byte 3 /* DW_OP_addr */
-+ .4byte vardata /* <addr> */
-+2:
-+
-+ /* DW_AT_upper_bound is referencing an optimized-out variable. */
-+ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */
-+ .string "b_string" /* DW_AT_name */
-+ .4byte .Larrayb_type-.Lcu1_begin /* DW_AT_type */
-+ .byte 2f - 1f /* DW_AT_location */
-+1: .byte 3 /* DW_OP_addr */
-+ .4byte vardata /* <addr> */
-+2:
-+
-+ /* DW_AT_upper_bound is referencing register. */
-+ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */
-+ .string "reg_string" /* DW_AT_name */
-+ .4byte .Larrayreg_type-.Lcu1_begin /* DW_AT_type */
-+ .byte 2f - 1f /* DW_AT_location */
-+1: .byte 3 /* DW_OP_addr */
-+ .4byte vardata /* <addr> */
-+2:
-+
-+ .byte 0 /* End of children of CU */
-+.Lcu1_end:
-+
-+ .section .debug_loc
-+.Lloclist:
-+.Llen_loclist:
-+ .4byte 0 # Location list begin address
-+ .4byte main_length # Location list end address
-+ .value 2f-1f # Location expression size
-+1: .byte 0x33 # DW_OP_lit3
-+ .byte 0x9f # DW_OP_stack_value
-+2:
-+ .quad 0x0 # Location list terminator begin (*.LLST2)
-+ .quad 0x0 # Location list terminator end (*.LLST2)
-+
-+ .section .debug_abbrev
-+.Ldebug_abbrev0:
-+ .uleb128 1 /* Abbrev code */
-+ .uleb128 0x11 /* DW_TAG_compile_unit */
-+ .byte 0x1 /* has_children */
-+ .uleb128 0x25 /* DW_AT_producer */
-+ .uleb128 0xe /* DW_FORM_strp */
-+ .uleb128 0x13 /* DW_AT_language */
-+ .uleb128 0xb /* DW_FORM_data1 */
-+ .uleb128 0x11 /* DW_AT_low_pc */
-+ .uleb128 0x1 /* DW_FORM_addr */
-+ .uleb128 0x12 /* DW_AT_high_pc */
-+ .uleb128 0xb /* DW_FORM_data1 */
-+ .byte 0x0 /* Terminator */
-+ .byte 0x0 /* Terminator */
-+
-+ .uleb128 2 /* Abbrev code */
-+ .uleb128 0x1 /* TAG: DW_TAG_array_type */
-+ .byte 0x1 /* DW_children_yes */
-+ .uleb128 0x49 /* DW_AT_type */
-+ .uleb128 0x13 /* DW_FORM_ref4 */
-+ .byte 0x0 /* Terminator */
-+ .byte 0x0 /* Terminator */
-+
-+ .uleb128 3 /* Abbrev code */
-+ .uleb128 0x21 /* DW_TAG_subrange_type */
-+ .byte 0x0 /* no children */
-+ .uleb128 0x49 /* DW_AT_type */
-+ .uleb128 0x13 /* DW_FORM_ref4 */
-+ .uleb128 0x22 /* DW_AT_lower_bound */
-+ .uleb128 0xb /* DW_FORM_data1 */
-+ .uleb128 0x2f /* DW_AT_upper_bound */
-+ .uleb128 0x13 /* DW_FORM_ref4 */
-+ .byte 0x0 /* Terminator */
-+ .byte 0x0 /* Terminator */
-+
-+ .uleb128 4 /* Abbrev code */
-+ .uleb128 0x24 /* DW_TAG_base_type */
-+ .byte 0x0 /* no_children */
-+ .uleb128 0x3 /* DW_AT_name */
-+ .uleb128 0xe /* DW_FORM_strp */
-+ .uleb128 0xb /* DW_AT_byte_size */
-+ .uleb128 0xb /* DW_FORM_data1 */
-+ .uleb128 0x3e /* DW_AT_encoding */
-+ .uleb128 0xb /* DW_FORM_data1 */
-+ .byte 0x0 /* Terminator */
-+ .byte 0x0 /* Terminator */
-+
-+ .uleb128 5 /* Abbrev code */
-+ .uleb128 0x34 /* DW_TAG_variable */
-+ .byte 0x0 /* no_children */
-+ .uleb128 0x34 /* DW_AT_artificial */
-+ .uleb128 0x0c /* DW_FORM_flag */
-+ .uleb128 0x49 /* DW_AT_type */
-+ .uleb128 0x13 /* DW_FORM_ref4 */
-+ .uleb128 0x02 /* DW_AT_location */
-+ .uleb128 0x06 /* DW_FORM_data4 */
-+ .byte 0x0 /* Terminator */
-+ .byte 0x0 /* Terminator */
-+
-+ .uleb128 6 /* Abbrev code */
-+ .uleb128 0x34 /* DW_TAG_variable */
-+ .byte 0x0 /* no_children */
-+ .uleb128 0x3 /* DW_AT_name */
-+ .uleb128 0x8 /* DW_FORM_string */
-+ .uleb128 0x49 /* DW_AT_type */
-+ .uleb128 0x13 /* DW_FORM_ref4 */
-+ .uleb128 0x2 /* DW_AT_location */
-+ .uleb128 0xa /* DW_FORM_block1 */
-+ .byte 0x0 /* Terminator */
-+ .byte 0x0 /* Terminator */
-+
-+ .uleb128 7 /* Abbrev code */
-+ .uleb128 0x34 /* DW_TAG_variable */
-+ .byte 0x0 /* no_children */
-+ .uleb128 0x34 /* DW_AT_artificial */
-+ .uleb128 0x0c /* DW_FORM_flag */
-+ .uleb128 0x49 /* DW_AT_type */
-+ .uleb128 0x13 /* DW_FORM_ref4 */
-+ .byte 0x0 /* Terminator */
-+ .byte 0x0 /* Terminator */
-+
-+ .uleb128 8 /* Abbrev code */
-+ .uleb128 0x21 /* DW_TAG_subrange_type with block */
-+ .byte 0x0 /* no children */
-+ .uleb128 0x49 /* DW_AT_type */
-+ .uleb128 0x13 /* DW_FORM_ref4 */
-+ .uleb128 0x22 /* DW_AT_lower_bound */
-+ .uleb128 0xb /* DW_FORM_data1 */
-+ .uleb128 0x2f /* DW_AT_upper_bound */
-+ .uleb128 0xa /* DW_FORM_block1 */
-+ .byte 0x0 /* Terminator */
-+ .byte 0x0 /* Terminator */
-+
-+ .byte 0x0 /* Terminator */
-+
-+/* String table */
-+ .section .debug_str
-+.Lproducer:
-+ .string "GNU C 3.3.3"
-+.Lchar_str:
-+ .string "char"
-+.Luint_str:
-+ .string "unsigned int"
-diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.dwarf2/dw2-bound-loclist.exp
-@@ -0,0 +1,66 @@
-+# Copyright 2010 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/>.
-+
-+# Test printing variable with dynamic bounds which reference a different
-+# (artificial in the GCC case) variable containing loclist as its location.
-+# This testcase uses value (not address) of the referenced variable:
-+# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762
-+
-+# This test can only be run on targets which support DWARF-2 and use gas.
-+# For now pick a sampling of likely targets.
-+if {![istarget *-*-linux*]
-+ && ![istarget *-*-gnu*]
-+ && ![istarget *-*-elf*]
-+ && ![istarget *-*-openbsd*]
-+ && ![istarget arm-*-eabi*]
-+ && ![istarget powerpc-*-eabi*]} {
-+ return 0
-+}
-+
-+set testfile dw2-bound-loclist
-+if { [prepare_for_testing ${testfile}.exp ${testfile} [list ${testfile}.S main.c] {}] } {
-+ return -1
-+}
-+
-+# Verify it behaves at least as an unbound array without inferior.
-+
-+# FIXME: FSF GDB crashes due to !has_stack_frames ().
-+# But in practice that should not happen.
-+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43762
-+#set test "p a_string"
-+#gdb_test_multiple $test $test {
-+# -re " = 0x\[0-9a-f\]+ \"seennotseen\"\r\n$gdb_prompt $" {
-+# pass $test
-+# }
-+# -re "No registers\\.\r\n$gdb_prompt $" {
-+# kfail "vlaregression" $test
-+# }
-+#}
-+#
-+#gdb_test "ptype a_string" {type = char \[variable length\]}
-+
-+# Not runto_main as dw2-bound-loclist.S handles only the first byte of main.
-+if ![runto "*main"] {
-+ return -1
-+}
-+
-+gdb_test "p a_string" { = "seen"}
-+gdb_test "ptype a_string" {type = char \[4\]}
-+
-+gdb_test "p b_string" { = (0x[0-9a-f]+ )?"seennotseen"}
-+gdb_test "ptype b_string" {type = char \[\]}
-+
-+# The register contains unpredictable value - the array size.
-+gdb_test "ptype reg_string" {type = char \[-?[0-9]+\]}
-diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.c b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.c
-@@ -0,0 +1,42 @@
-+/* This testcase is part of GDB, the GNU debugger.
-+
-+ Copyright 2004 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 2 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, write to the Free Software
-+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
-+ USA. */
-+
-+
-+/* The function `func1' traced into must have debug info on offset > 0;
-+ (DW_UNSND (attr)). This is the reason of `func0' existence. */
-+
-+void
-+func0(int a, int b)
-+{
-+}
-+
-+/* `func1' being traced into must have some arguments to dump. */
-+
-+void
-+func1(int a, int b)
-+{
-+ func0 (a,b);
-+}
-+
-+int
-+main(void)
-+{
-+ func1 (1, 2);
-+ return 0;
-+}
-diff --git a/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.dwarf2/dw2-stripped.exp
-@@ -0,0 +1,84 @@
-+# Copyright 2006 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 2 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, write to the Free Software
-+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-+
-+# Minimal DWARF-2 unit test
-+
-+# This test can only be run on targets which support DWARF-2.
-+# For now pick a sampling of likely targets.
-+if {![istarget *-*-linux*]
-+ && ![istarget *-*-gnu*]
-+ && ![istarget *-*-elf*]
-+ && ![istarget *-*-openbsd*]
-+ && ![istarget arm-*-eabi*]
-+ && ![istarget powerpc-*-eabi*]} {
-+ return 0
-+}
-+
-+if {[use_gdb_stub]} {
-+ untested "skipping test because of use_gdb_stub"
-+ return -1
-+}
-+
-+set testfile "dw2-stripped"
-+set srcfile ${testfile}.c
-+set binfile [standard_output_file ${testfile}.x]
-+
-+remote_exec build "rm -f ${binfile}"
-+
-+# get the value of gcc_compiled
-+if [get_compiler_info ${binfile}] {
-+ return -1
-+}
-+
-+# This test can only be run on gcc as we use additional_flags=FIXME
-+if {$gcc_compiled == 0} {
-+ return 0
-+}
-+
-+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-ggdb3}] != "" } {
-+ return -1
-+}
-+
-+remote_exec build "objcopy -R .debug_loc ${binfile}"
-+set strip_output [remote_exec build "objdump -h ${binfile}"]
-+
-+set test "stripping test file preservation"
-+if [ regexp ".debug_info " $strip_output] {
-+ pass "$test (.debug_info preserved)"
-+} else {
-+ fail "$test (.debug_info got also stripped)"
-+}
-+
-+set test "stripping test file functionality"
-+if [ regexp ".debug_loc " $strip_output] {
-+ fail "$test (.debug_loc still present)"
-+} else {
-+ pass "$test (.debug_loc stripped)"
-+}
-+
-+gdb_exit
-+gdb_start
-+gdb_reinitialize_dir $srcdir/$subdir
-+gdb_load ${binfile}
-+
-+# For C programs, "start" should stop in main().
-+
-+gdb_test "start" \
-+ ".*main \\(\\) at .*" \
-+ "start"
-+gdb_test "step" \
-+ "func.* \\(.*\\) at .*" \
-+ "step"
-diff --git a/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.S
-@@ -0,0 +1,83 @@
-+/* This testcase is part of GDB, the GNU debugger.
-+
-+ Copyright 2009 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/>. */
-+
-+/* Debug information */
-+
-+ .section .debug_info
-+.Lcu1_begin:
-+ /* CU header */
-+ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */
-+.Lcu1_start:
-+ .2byte 2 /* DWARF Version */
-+ .4byte .Labbrev1_begin /* Offset into abbrev section */
-+ .byte 4 /* Pointer size */
-+
-+ /* CU die */
-+ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */
-+ .ascii "dw2-struct-member-data-location.c\0" /* DW_AT_name */
-+ .ascii "GNU C 4.3.2\0" /* DW_AT_producer */
-+ .byte 1 /* DW_AT_language (C) */
-+
-+.Ltype_uchar:
-+ .uleb128 2 /* Abbrev: DW_TAG_structure_type */
-+ .ascii "some_struct\0" /* DW_AT_name */
-+
-+ .uleb128 3 /* Abbrev: DW_TAG_member */
-+ .ascii "field\0" /* DW_AT_name */
-+ .byte 0 /* DW_AT_data_member_location */
-+
-+ .byte 0 /* End of children of some_struct */
-+
-+ .byte 0 /* End of children of CU */
-+
-+.Lcu1_end:
-+
-+/* Abbrev table */
-+ .section .debug_abbrev
-+.Labbrev1_begin:
-+ .uleb128 1 /* Abbrev code */
-+ .uleb128 0x11 /* DW_TAG_compile_unit */
-+ .byte 1 /* has_children */
-+ .uleb128 0x3 /* DW_AT_name */
-+ .uleb128 0x8 /* DW_FORM_string */
-+ .uleb128 0x25 /* DW_AT_producer */
-+ .uleb128 0x8 /* DW_FORM_string */
-+ .uleb128 0x13 /* DW_AT_language */
-+ .uleb128 0xb /* DW_FORM_data1 */
-+ .byte 0x0 /* Terminator */
-+ .byte 0x0 /* Terminator */
-+
-+ .uleb128 2 /* Abbrev code */
-+ .uleb128 0x13 /* DW_TAG_structure_type */
-+ .byte 1 /* has_children */
-+ .uleb128 0x3 /* DW_AT_name */
-+ .uleb128 0x8 /* DW_FORM_string */
-+ .byte 0x0 /* Terminator */
-+ .byte 0x0 /* Terminator */
-+
-+ .uleb128 3 /* Abbrev code */
-+ .uleb128 0x0d /* DW_TAG_member */
-+ .byte 0 /* has_children */
-+ .uleb128 0x3 /* DW_AT_name */
-+ .uleb128 0x8 /* DW_FORM_string */
-+ .uleb128 0x38 /* DW_AT_data_member_location */
-+ .uleb128 0x0b /* DW_FORM_data1 */
-+ .byte 0x0 /* Terminator */
-+ .byte 0x0 /* Terminator */
-+
-+ .byte 0x0 /* Terminator */
-+ .byte 0x0 /* Terminator */
-diff --git a/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.dwarf2/dw2-struct-member-data-location.exp
-@@ -0,0 +1,37 @@
-+# Copyright 2009 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 test can only be run on targets which support DWARF-2 and use gas.
-+# For now pick a sampling of likely targets.
-+if {![istarget *-*-linux*]
-+ && ![istarget *-*-gnu*]
-+ && ![istarget *-*-elf*]
-+ && ![istarget *-*-openbsd*]
-+ && ![istarget arm-*-eabi*]
-+ && ![istarget powerpc-*-eabi*]} {
-+ return 0
-+}
-+
-+set testfile "dw2-struct-member-data-location"
-+set srcfile ${testfile}.S
-+set binfile ${testfile}.x
-+
-+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "[standard_output_file ${binfile}]" object {nodebug}] != "" } {
-+ return -1
-+}
-+
-+clean_restart $binfile
-+
-+gdb_test "ptype struct some_struct" "type = struct some_struct {\[\r\n \t\]*void field;\[\r\n \t\]*}"
-diff --git a/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.S
-@@ -0,0 +1,121 @@
-+/* This testcase is part of GDB, the GNU debugger.
-+
-+ Copyright 2012 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/>. */
-+
-+/* Debug information */
-+
-+ .section .data
-+vardata:
-+ .rept 129
-+ .ascii "x"
-+ .endr
-+ .ascii "UNSEEN\0"
-+
-+ .section .debug_info
-+.Lcu1_begin:
-+ .4byte .Lcu1_end - .Lcu1_start /* Length of Compilation Unit */
-+.Lcu1_start:
-+ .2byte 2 /* DWARF version number */
-+ .4byte .Ldebug_abbrev0 /* Offset Into Abbrev. Section */
-+ .byte 4 /* Pointer Size (in bytes) */
-+
-+ /* CU die */
-+ .uleb128 1 /* Abbrev: DW_TAG_compile_unit */
-+ .ascii "GNU C 3.3.3\0" /* DW_AT_producer */
-+ .byte 2 /* DW_AT_language (C) - */
-+
-+.Larray_type:
-+ .uleb128 2 /* Abbrev: DW_TAG_array_type */
-+ .4byte .Lchar_type-.Lcu1_begin /* DW_AT_type */
-+
-+ .uleb128 8 /* Abbrev: DW_TAG_subrange_type without DW_AT_type */
-+ .byte 0 /* DW_AT_lower_bound */
-+ .byte 128 /* DW_AT_upper_bound */
-+
-+ .byte 0 /* End of children of die */
-+
-+.Lchar_type:
-+ .uleb128 4 /* Abbrev: DW_TAG_base_type */
-+ .ascii "char\0" /* DW_AT_name */
-+ .byte 1 /* DW_AT_byte_size */
-+ .byte 6 /* DW_AT_encoding */
-+
-+ .uleb128 6 /* Abbrev: DW_TAG_variable DW_FORM_string */
-+ .ascii "notype_string\0" /* DW_AT_name */
-+ .4byte .Larray_type-.Lcu1_begin /* DW_AT_type */
-+ .byte 2f - 1f /* DW_AT_location */
-+1: .byte 3 /* DW_OP_addr */
-+ .4byte vardata /* <addr> */
-+2:
-+
-+ .byte 0 /* End of children of CU */
-+.Lcu1_end:
-+
-+ .section .debug_abbrev
-+.Ldebug_abbrev0:
-+ .uleb128 1 /* Abbrev code */
-+ .uleb128 0x11 /* DW_TAG_compile_unit */
-+ .byte 0x1 /* has_children */
-+ .uleb128 0x25 /* DW_AT_producer */
-+ .uleb128 0x8 /* DW_FORM_string */
-+ .uleb128 0x13 /* DW_AT_language */
-+ .uleb128 0xb /* DW_FORM_data1 */
-+ .byte 0x0 /* Terminator */
-+ .byte 0x0 /* Terminator */
-+
-+ .uleb128 2 /* Abbrev code */
-+ .uleb128 0x1 /* TAG: DW_TAG_array_type */
-+ .byte 0x1 /* DW_children_yes */
-+ .uleb128 0x49 /* DW_AT_type */
-+ .uleb128 0x13 /* DW_FORM_ref4 */
-+ .byte 0x0 /* Terminator */
-+ .byte 0x0 /* Terminator */
-+
-+ .uleb128 4 /* Abbrev code */
-+ .uleb128 0x24 /* DW_TAG_base_type */
-+ .byte 0x0 /* no_children */
-+ .uleb128 0x3 /* DW_AT_name */
-+ .uleb128 0x8 /* DW_FORM_string */
-+ .uleb128 0xb /* DW_AT_byte_size */
-+ .uleb128 0xb /* DW_FORM_data1 */
-+ .uleb128 0x3e /* DW_AT_encoding */
-+ .uleb128 0xb /* DW_FORM_data1 */
-+ .byte 0x0 /* Terminator */
-+ .byte 0x0 /* Terminator */
-+
-+ .uleb128 6 /* Abbrev code */
-+ .uleb128 0x34 /* DW_TAG_variable */
-+ .byte 0x0 /* no_children */
-+ .uleb128 0x3 /* DW_AT_name */
-+ .uleb128 0x8 /* DW_FORM_string */
-+ .uleb128 0x49 /* DW_AT_type */
-+ .uleb128 0x13 /* DW_FORM_ref4 */
-+ .uleb128 0x2 /* DW_AT_location */
-+ .uleb128 0xa /* DW_FORM_block1 */
-+ .byte 0x0 /* Terminator */
-+ .byte 0x0 /* Terminator */
-+
-+ .uleb128 8 /* Abbrev code */
-+ .uleb128 0x21 /* DW_TAG_subrange_type without DW_AT_type */
-+ .byte 0x0 /* no children */
-+ .uleb128 0x22 /* DW_AT_lower_bound */
-+ .uleb128 0xb /* DW_FORM_data1 */
-+ .uleb128 0x2f /* DW_AT_upper_bound */
-+ .uleb128 0xb /* DW_FORM_data1 */
-+ .byte 0x0 /* Terminator */
-+ .byte 0x0 /* Terminator */
-+
-+ .byte 0x0 /* Terminator */
-diff --git a/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.dwarf2/dw2-subrange-no-type.exp
-@@ -0,0 +1,39 @@
-+# Copyright 2012 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/>.
-+load_lib dwarf.exp
-+
-+# https://bugzilla.redhat.com/show_bug.cgi?id=806920
-+# read_subrange_type <TYPE_CODE (base_type) == TYPE_CODE_VOID> reinitialization
-+# of BASE_TYPE was done too late, it affects DW_TAG_subrange_type without
-+# specified DW_AT_type, present only in XLF produced code.
-+
-+# This test can only be run on targets which support DWARF-2 and use gas.
-+if {![dwarf2_support]} {
-+ return 0
-+}
-+
-+set testfile dw2-subrange-no-type
-+set srcfile ${testfile}.S
-+set executable ${testfile}.x
-+set binfile [standard_output_file ${executable}]
-+
-+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" object {}] != "" } {
-+ return -1
-+}
-+
-+clean_restart $executable
-+
-+gdb_test "ptype notype_string" {type = char \[129\]}
-+gdb_test "p notype_string" " = 'x' <repeats 129 times>"
-diff --git a/gdb/testsuite/gdb.fortran/dwarf-stride.exp b/gdb/testsuite/gdb.fortran/dwarf-stride.exp
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.fortran/dwarf-stride.exp
-@@ -0,0 +1,42 @@
-+# Copyright 2009 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 2 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, write to the Free Software
-+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-+
-+# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
-+
-+# This file is part of the gdb testsuite. Array element stride must not be
-+# specified in the number of elements but in a number of bytes instead.
-+# Original problem:
-+# (gdb) p c40pt(1)
-+# $1 = '0-hello', ' ' <repeats 33 times>
-+# (gdb) p c40pt(2)
-+# warning: Fortran array stride not divisible by the element size
-+
-+set testfile dwarf-stride
-+set srcfile ${testfile}.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 "break-here"]
-+gdb_continue_to_breakpoint "break-here" ".*break-here.*"
-+gdb_test "p c40pt(1)" " = '0-hello.*"
-+gdb_test "p c40pt(2)" " = '1-hello.*"
-diff --git a/gdb/testsuite/gdb.fortran/dwarf-stride.f90 b/gdb/testsuite/gdb.fortran/dwarf-stride.f90
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.fortran/dwarf-stride.f90
-@@ -0,0 +1,40 @@
-+! Copyright 2009 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 2 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, write to the Free Software
-+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-+!
-+! File written by Alan Matsuoka.
-+
-+program repro
-+
-+ type small_stride
-+ character*40 long_string
-+ integer small_pad
-+ end type small_stride
-+
-+ type(small_stride), dimension (20), target :: unpleasant
-+ character*40, pointer, dimension(:):: c40pt
-+
-+ integer i
-+
-+ do i = 0,19
-+ unpleasant(i+1)%small_pad = i+1
-+ unpleasant(i+1)%long_string = char (ichar('0') + i) // '-hello'
-+ end do
-+
-+ c40pt => unpleasant%long_string
-+
-+ print *, c40pt ! break-here
-+
-+end program repro
-diff --git a/gdb/testsuite/gdb.fortran/dynamic.exp b/gdb/testsuite/gdb.fortran/dynamic.exp
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.fortran/dynamic.exp
-@@ -0,0 +1,154 @@
-+# Copyright 2007 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 2 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, write to the Free Software
-+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-+
-+# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
-+
-+# This file is part of the gdb testsuite. It contains tests for dynamically
-+# allocated Fortran arrays.
-+# It depends on the GCC dynamic Fortran arrays DWARF support:
-+# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22244
-+
-+set testfile "dynamic"
-+set srcfile ${testfile}.f90
-+set binfile [standard_output_file ${testfile}]
-+
-+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f90 quiet}] != "" } {
-+ untested "Couldn't compile ${srcfile}"
-+ return -1
-+}
-+
-+gdb_exit
-+gdb_start
-+gdb_reinitialize_dir $srcdir/$subdir
-+gdb_load ${binfile}
-+
-+if ![runto MAIN__] then {
-+ perror "couldn't run to breakpoint MAIN__"
-+ continue
-+}
-+
-+gdb_breakpoint [gdb_get_line_number "varx-init"]
-+gdb_continue_to_breakpoint "varx-init"
-+
-+# http://www.cs.rpi.edu/~szymansk/OOF90/bugs.html#5
-+# Do not: gdb_test "p varx" "\\$\[0-9\]* = <not allocated>" "p varx unallocated"
-+# Do not: gdb_test "ptype varx" {type = real\(kind=4\) \(:,:,:\)} "ptype varx unallocated"
-+# Do not: gdb_test "p varx(1,5,17)" {no such vector element \(vector not allocated\)} "p varx(1,5,17) unallocated"
-+# Do not: gdb_test "p varx(1,5,17)=1" {no such vector element \(vector not allocated\)} "p varx(1,5,17)=1 unallocated"
-+# Do not: gdb_test "ptype varx(1,5,17)" {no such vector element \(vector not allocated\)} "ptype varx(1,5,17) unallocated"
-+
-+gdb_breakpoint [gdb_get_line_number "varx-allocated"]
-+gdb_continue_to_breakpoint "varx-allocated"
-+# $1 = (( ( 0, 0, 0, 0, 0, 0) ( 0, 0, 0, 0, 0, 0) --- , 0) ) ( ( 0, 0, ...) ...) ...)
-+gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4), allocatable \\(6,5:15,17:28\\)" "ptype varx allocated"
-+# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1.
-+gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varx allocated"
-+
-+gdb_breakpoint [gdb_get_line_number "varx-filled"]
-+gdb_continue_to_breakpoint "varx-filled"
-+gdb_test "p varx(2, 5, 17)" "\\$\[0-9\]* = 6"
-+gdb_test "p varx(1, 5, 17)" "\\$\[0-9\]* = 7"
-+gdb_test "p varx(2, 6, 18)" "\\$\[0-9\]* = 8"
-+gdb_test "p varx(6, 15, 28)" "\\$\[0-9\]* = 9"
-+# http://www.cs.rpi.edu/~szymansk/OOF90/bugs.html#5
-+# Do not: gdb_test "p varv" "\\$\[0-9\]* = <not associated>" "p varv unassociated"
-+# Do not: gdb_test "ptype varv" {type = real\(kind=4\) \(:,:,:\)} "ptype varv unassociated"
-+
-+set test "output varx"
-+gdb_test_multiple $test $test {
-+ -re "^output varx\r\n\[() ,6789.\]*$gdb_prompt $" {
-+ pass $test
-+ }
-+}
-+
-+gdb_breakpoint [gdb_get_line_number "varv-associated"]
-+gdb_continue_to_breakpoint "varv-associated"
-+gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 6" "p varx(3, 7, 19) with varv associated"
-+gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 6" "p varv(3, 7, 19) associated"
-+# Intel Fortran Compiler 10.1.008 uses -1 there, GCC uses 1.
-+gdb_test "p l" "\\$\[0-9\]* = (\\.TRUE\\.|4294967295)" "p l if varv associated"
-+gdb_test "ptype varx" "type = real(\\(kind=4\\)|\\*4), allocatable \\(6,5:15,17:28\\)" "ptype varx with varv associated"
-+# Intel Fortran Compiler 10.1.008 uses the pointer type.
-+gdb_test "ptype varv" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(6,5:15,17:28\\)\\)?" "ptype varv associated"
-+
-+gdb_breakpoint [gdb_get_line_number "varv-filled"]
-+gdb_continue_to_breakpoint "varv-filled"
-+gdb_test "p varx(3, 7, 19)" "\\$\[0-9\]* = 10" "p varx(3, 7, 19) with varv filled"
-+gdb_test "p varv(3, 7, 19)" "\\$\[0-9\]* = 10" "p varv(3, 7, 19) filled"
-+
-+gdb_breakpoint [gdb_get_line_number "varv-deassociated"]
-+gdb_continue_to_breakpoint "varv-deassociated"
-+# The latter one is for the Intel Fortran Compiler 10.1.008 pointer type.
-+gdb_test "p varv" "\\$\[0-9\]* = (<not associated>|.*(Cannot access it|Unable to access the object) because the object is not associated.)" "p varv deassociated"
-+gdb_test "ptype varv" {type = real\(kind=4\) \(:,:,:\)} "ptype varv deassociated"
-+gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varv deassociated"
-+gdb_test "p varv(1,5,17)" {no such vector element \(vector not associated\)}
-+gdb_test "ptype varv(1,5,17)" {no such vector element \(vector not associated\)}
-+
-+gdb_breakpoint [gdb_get_line_number "varx-deallocated"]
-+gdb_continue_to_breakpoint "varx-deallocated"
-+gdb_test "p varx" "\\$\[0-9\]* = <not allocated>" "p varx deallocated"
-+gdb_test "ptype varx" {type = real\(kind=4\), allocatable \(:,:,:\)} "ptype varx deallocated"
-+gdb_test "p l" "\\$\[0-9\]* = \\.FALSE\\." "p l if varx deallocated"
-+gdb_test "p varx(1,5,17)" {no such vector element \(vector not allocated\)} "p varx(1,5,17) deallocated"
-+gdb_test "ptype varx(1,5,17)" {no such vector element \(vector not allocated\)} "ptype varx(1,5,17) deallocated"
-+
-+gdb_breakpoint [gdb_get_line_number "vary-passed"]
-+gdb_continue_to_breakpoint "vary-passed"
-+# $1 = (( ( 1, 1, 1, 1, 1, 1) ( 1, 1, 1, 1, 1, 1) --- , 1) ) ( ( 1, 1, ...) ...) ...)
-+gdb_test "p vary" "\\$\[0-9\]* = \\(\[()1, .\]*\\)"
-+
-+gdb_breakpoint [gdb_get_line_number "vary-filled"]
-+gdb_continue_to_breakpoint "vary-filled"
-+gdb_test "ptype vary" "type = real(\\(kind=4\\)|\\*4) \\(10,10\\)"
-+gdb_test "p vary(1, 1)" "\\$\[0-9\]* = 8"
-+gdb_test "p vary(2, 2)" "\\$\[0-9\]* = 9"
-+gdb_test "p vary(1, 3)" "\\$\[0-9\]* = 10"
-+# $1 = (( ( 3, 3, 3, 3, 3, 3) ( 3, 3, 3, 3, 3, 3) --- , 3) ) ( ( 3, 3, ...) ...) ...)
-+gdb_test "p varw" "\\$\[0-9\]* = \\(\[()3, .\]*\\)"
-+
-+gdb_breakpoint [gdb_get_line_number "varw-almostfilled"]
-+gdb_continue_to_breakpoint "varw-almostfilled"
-+gdb_test "ptype varw" "type = real(\\(kind=4\\)|\\*4) \\(5,4,3\\)"
-+gdb_test "p varw(3,1,1)=1" "\\$\[0-9\]* = 1"
-+# $1 = (( ( 6, 5, 1, 5, 5, 5) ( 5, 5, 5, 5, 5, 5) --- , 5) ) ( ( 5, 5, ...) ...) ...)
-+gdb_test "p varw" "\\$\[0-9\]* = \\( *\\( *\\( *6, *5, *1,\[()5, .\]*\\)" "p varw filled"
-+# "up" works with GCC but other Fortran compilers may copy the values into the
-+# outer function only on the exit of the inner function.
-+# We need both variants as depending on the arch we optionally may still be
-+# executing the caller line or not after `finish'.
-+gdb_test "finish" ".*(call bar \\(y, x\\)|call foo \\(x, z\\(2:6, 4:7, 6:8\\)\\))"
-+gdb_test "p z(2,4,5)" "\\$\[0-9\]* = 3"
-+gdb_test "p z(2,4,6)" "\\$\[0-9\]* = 6"
-+gdb_test "p z(2,4,7)" "\\$\[0-9\]* = 5"
-+gdb_test "p z(4,4,6)" "\\$\[0-9\]* = 1"
-+
-+gdb_breakpoint [gdb_get_line_number "varz-almostfilled"]
-+gdb_continue_to_breakpoint "varz-almostfilled"
-+# GCC uses the pointer type here, Intel Fortran Compiler 10.1.008 does not.
-+gdb_test "ptype varz" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(\\*\\)\\)?"
-+# Intel Fortran Compiler 10.1.008 has a bug here - (2:11,7:7)
-+# as it produces DW_AT_lower_bound == DW_AT_upper_bound == 7.
-+gdb_test "ptype vart" "type = (PTR TO -> \\( )?real(\\(kind=4\\)|\\*4) \\(2:11,7:\\*\\)\\)?"
-+gdb_test "p varz" "\\$\[0-9\]* = \\(\\)"
-+gdb_test "p vart" "\\$\[0-9\]* = \\(\\)"
-+gdb_test "p varz(3)" "\\$\[0-9\]* = 4"
-+# maps to foo::vary(1,1)
-+gdb_test "p vart(2,7)" "\\$\[0-9\]* = 8"
-+# maps to foo::vary(2,2)
-+gdb_test "p vart(3,8)" "\\$\[0-9\]* = 9"
-+# maps to foo::vary(1,3)
-+gdb_test "p vart(2,9)" "\\$\[0-9\]* = 10"
-diff --git a/gdb/testsuite/gdb.fortran/dynamic.f90 b/gdb/testsuite/gdb.fortran/dynamic.f90
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.fortran/dynamic.f90
-@@ -0,0 +1,98 @@
-+! Copyright 2007 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 2 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, write to the Free Software
-+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-+!
-+! Ihis file is the Fortran source file for dynamic.exp.
-+! Original file written by Jakub Jelinek <jakub@redhat.com>.
-+! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
-+
-+subroutine baz
-+ real, target, allocatable :: varx (:, :, :)
-+ real, pointer :: varv (:, :, :)
-+ real, target :: varu (1, 2, 3)
-+ logical :: l
-+ allocate (varx (1:6, 5:15, 17:28)) ! varx-init
-+ l = allocated (varx)
-+ varx(:, :, :) = 6 ! varx-allocated
-+ varx(1, 5, 17) = 7
-+ varx(2, 6, 18) = 8
-+ varx(6, 15, 28) = 9
-+ varv => varx ! varx-filled
-+ l = associated (varv)
-+ varv(3, 7, 19) = 10 ! varv-associated
-+ varv => null () ! varv-filled
-+ l = associated (varv)
-+ deallocate (varx) ! varv-deassociated
-+ l = allocated (varx)
-+ varu(:, :, :) = 10 ! varx-deallocated
-+ allocate (varv (1:6, 5:15, 17:28))
-+ l = associated (varv)
-+ varv(:, :, :) = 6
-+ varv(1, 5, 17) = 7
-+ varv(2, 6, 18) = 8
-+ varv(6, 15, 28) = 9
-+ deallocate (varv)
-+ l = associated (varv)
-+ varv => varu
-+ varv(1, 1, 1) = 6
-+ varv(1, 2, 3) = 7
-+ l = associated (varv)
-+end subroutine baz
-+subroutine foo (vary, varw)
-+ real :: vary (:, :)
-+ real :: varw (:, :, :)
-+ vary(:, :) = 4 ! vary-passed
-+ vary(1, 1) = 8
-+ vary(2, 2) = 9
-+ vary(1, 3) = 10
-+ varw(:, :, :) = 5 ! vary-filled
-+ varw(1, 1, 1) = 6
-+ varw(2, 2, 2) = 7 ! varw-almostfilled
-+end subroutine foo
-+subroutine bar (varz, vart)
-+ real :: varz (*)
-+ real :: vart (2:11, 7:*)
-+ varz(1:3) = 4
-+ varz(2) = 5 ! varz-almostfilled
-+ vart(2,7) = vart(2,7)
-+end subroutine bar
-+program test
-+ interface
-+ subroutine foo (vary, varw)
-+ real :: vary (:, :)
-+ real :: varw (:, :, :)
-+ end subroutine
-+ end interface
-+ interface
-+ subroutine bar (varz, vart)
-+ real :: varz (*)
-+ real :: vart (2:11, 7:*)
-+ end subroutine
-+ end interface
-+ real :: x (10, 10), y (5), z(8, 8, 8)
-+ x(:,:) = 1
-+ y(:) = 2
-+ z(:,:,:) = 3
-+ call baz
-+ call foo (x, z(2:6, 4:7, 6:8))
-+ call bar (y, x)
-+ if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort
-+ if (x (1, 3) .ne. 10) call abort
-+ if (z (2, 4, 6) .ne. 6 .or. z (3, 5, 7) .ne. 7 .or. z (2, 4, 7) .ne. 5) call abort
-+ if (any (y .ne. (/4, 5, 4, 2, 2/))) call abort
-+ call foo (transpose (x), z)
-+ if (x (1, 1) .ne. 8 .or. x (2, 2) .ne. 9 .or. x (1, 2) .ne. 4) call abort
-+ if (x (3, 1) .ne. 10) call abort
-+end
-diff --git a/gdb/testsuite/gdb.fortran/string.exp b/gdb/testsuite/gdb.fortran/string.exp
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.fortran/string.exp
-@@ -0,0 +1,71 @@
-+# Copyright 2008 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 2 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, write to the Free Software
-+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-+
-+# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
-+
-+# This file is part of the gdb testsuite. It contains tests for Fortran
-+# strings with dynamic length.
-+
-+set testfile "string"
-+set srcfile ${testfile}.f90
-+set binfile [standard_output_file ${testfile}]
-+
-+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug f90 quiet}] != "" } {
-+ untested "Couldn't compile ${srcfile}"
-+ return -1
-+}
-+
-+gdb_exit
-+gdb_start
-+gdb_reinitialize_dir $srcdir/$subdir
-+gdb_load ${binfile}
-+
-+if ![runto MAIN__] then {
-+ perror "couldn't run to breakpoint MAIN__"
-+ continue
-+}
-+
-+gdb_breakpoint [gdb_get_line_number "var-init"]
-+gdb_continue_to_breakpoint "var-init"
-+gdb_test "ptype c" "type = character(\\(kind=1\\)|\\*1)"
-+gdb_test "ptype d" "type = character(\\(kind=8\\)|\\*8)"
-+# Fortran: Support pointers to dynamic types.
-+setup_kfail gdb/nnnnn "*-*-*"
-+gdb_test "ptype e" "type = character(\\(kind=4\\)|\\*4)"
-+# Fortran: Support pointers to dynamic types.
-+setup_kfail gdb/nnnnn "*-*-*"
-+gdb_test "ptype f" "type = character(\\(kind=4\\)|\\*4) \\(7,8:10\\)"
-+# Fortran: Support pointers to dynamic types.
-+setup_kfail gdb/nnnnn "*-*-*"
-+gdb_test "ptype *e" "Attempt to take contents of a non-pointer value."
-+# Fortran: Support pointers to dynamic types.
-+setup_kfail gdb/nnnnn "*-*-*"
-+gdb_test "ptype *f" "type = character(\\(kind=4\\)|\\*4) \\(7\\)"
-+gdb_test "p c" "\\$\[0-9\]* = 'c'"
-+gdb_test "p d" "\\$\[0-9\]* = 'd '"
-+gdb_test "p e" "\\$\[0-9\]* = 'g '"
-+# Fortran: Support pointers to dynamic types.
-+setup_kfail gdb/nnnnn "*-*-*"
-+gdb_test "p f" "\\$\[0-9\]* = \\(\\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\( 'h ', 'h ', 'h ', 'h ', 'h ', 'h ', 'h '\\) \\)"
-+gdb_test "p *e" "Attempt to take contents of a non-pointer value."
-+gdb_test "p *f" "Attempt to take contents of a non-pointer value."
-+
-+gdb_breakpoint [gdb_get_line_number "var-finish"]
-+gdb_continue_to_breakpoint "var-finish"
-+gdb_test "p e" "\\$\[0-9\]* = 'e '" "p e re-set"
-+# Fortran: Support pointers to dynamic types.
-+setup_kfail gdb/nnnnn "*-*-*"
-+gdb_test "p f" "\\$\[0-9\]* = \\(\\( 'f ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\( 'f2 ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\( 'f ', 'f ', 'f ', 'f ', 'f ', 'f ', 'f '\\) \\)" "p *f re-set"
-diff --git a/gdb/testsuite/gdb.fortran/string.f90 b/gdb/testsuite/gdb.fortran/string.f90
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.fortran/string.f90
-@@ -0,0 +1,37 @@
-+! Copyright 2008 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 2 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, write to the Free Software
-+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-+!
-+! Ihis file is the Fortran source file for dynamic.exp.
-+! Original file written by Jakub Jelinek <jakub@redhat.com>.
-+! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
-+
-+subroutine foo (e, f)
-+ character (len=1) :: c
-+ character (len=8) :: d
-+ character (len=*) :: e
-+ character (len=*) :: f (1:7, 8:10)
-+ c = 'c'
-+ d = 'd'
-+ e = 'e' ! var-init
-+ f = 'f'
-+ f(1,9) = 'f2'
-+ c = 'c' ! var-finish
-+end subroutine foo
-+ character (len=4) :: g, h (1:7, 8:10)
-+ g = 'g'
-+ h = 'h'
-+ call foo (g, h)
-+end
-diff --git a/gdb/testsuite/gdb.fortran/subrange.exp b/gdb/testsuite/gdb.fortran/subrange.exp
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.fortran/subrange.exp
-@@ -0,0 +1,72 @@
-+# Copyright 2011 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/>.
-+
-+if { [skip_fortran_tests] } { return -1 }
-+
-+set testfile "subrange"
-+set srcfile ${testfile}.f90
-+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug f90}] } {
-+ return -1
-+}
-+
-+if ![runto MAIN__] {
-+ perror "Couldn't run to MAIN__"
-+ continue
-+}
-+
-+# Depending on the compiler version being used, the name of the 4-byte integer
-+# and real types can be printed differently. For instance, gfortran-4.1 uses
-+# "int4" whereas gfortran-4.3 uses "int(kind=4)".
-+set int4 "(int4|integer\\(kind=4\\))"
-+
-+gdb_breakpoint [gdb_get_line_number "break-static"]
-+gdb_continue_to_breakpoint "break-static" ".*break-static.*"
-+
-+foreach var {a alloc ptr} {
-+ global pf_prefix
-+ set old_prefix $pf_prefix
-+ lappend pf_prefix "$var:"
-+
-+ setup_kfail "*-*-*" "vlaregression/9999"
-+ gdb_test "p $var (2, 2:3)" { = \(22, 32\)}
-+ setup_kfail "*-*-*" "vlaregression/9999"
-+ gdb_test "p $var (2:3, 3)" { = \(32, 33\)}
-+ setup_kfail "*-*-*" "vlaregression/9999"
-+ gdb_test "p $var (1, 2:)" { = \(21, 31\)}
-+ setup_kfail "*-*-*" "vlaregression/9999"
-+ gdb_test "p $var (2, :2)" { = \(12, 22\)}
-+ setup_kfail "*-*-*" "vlaregression/9999"
-+ gdb_test "p $var (3, 2:2)" { = \(23\)}
-+ setup_kfail "*-*-*" "vlaregression/9999"
-+ gdb_test "ptype $var (3, 2:2)" " = $int4 \\(2:2\\)"
-+ setup_kfail "*-*-*" "vlaregression/9999"
-+ gdb_test "p $var (4, :)" { = \(14, 24, 34\)}
-+ setup_kfail "*-*-*" "vlaregression/9999"
-+ gdb_test "p $var (:, :)" { = \(\( *11, 12, 13, 14\) \( *21, 22, 23, 24\) \( *31, 32, 33, 34\) *\)}
-+ setup_kfail "*-*-*" "vlaregression/9999"
-+ gdb_test "ptype $var (:, :)" " = $int4 \\(4,3\\)"
-+ setup_kfail "*-*-*" "vlaregression/9999"
-+ gdb_test "p $var (:)" "Wrong number of subscripts"
-+ setup_kfail "*-*-*" "vlaregression/9999"
-+ gdb_test "p $var (:, :, :)" "Wrong number of subscripts"
-+
-+ set pf_prefix $old_prefix
-+}
-+
-+gdb_test_no_output {set $a=a}
-+delete_breakpoints
-+gdb_unload
-+setup_kfail "*-*-*" "vlaregression/9999"
-+gdb_test {p $a (3, 2:2)} { = \(23\)}
-diff --git a/gdb/testsuite/gdb.fortran/subrange.f90 b/gdb/testsuite/gdb.fortran/subrange.f90
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.fortran/subrange.f90
-@@ -0,0 +1,28 @@
-+! Copyright 2011 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/>.
-+
-+program test
-+ integer, target :: a (4, 3)
-+ integer, allocatable :: alloc (:, :)
-+ integer, pointer :: ptr (:, :)
-+ do 1 i = 1, 4
-+ do 1 j = 1, 3
-+ a (i, j) = j * 10 + i
-+1 continue
-+ allocate (alloc (4, 3))
-+ alloc = a
-+ ptr => a
-+ write (*,*) a ! break-static
-+end
-diff --git a/gdb/testsuite/gdb.mi/mi2-var-stale-type.c b/gdb/testsuite/gdb.mi/mi2-var-stale-type.c
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.mi/mi2-var-stale-type.c
-@@ -0,0 +1,26 @@
-+/* Copyright 2011 Free Software Foundation, Inc.
-+
-+ This file is part of GDB.
-+
-+ 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/>. */
-+
-+int
-+main (int argc, char **argv)
-+{
-+ char vla[argc];
-+
-+ vla[0] = 0; /* break-here */
-+
-+ return 0;
-+}
-diff --git a/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp b/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.mi/mi2-var-stale-type.exp
-@@ -0,0 +1,57 @@
-+# Copyright 2011 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/>.
-+
-+load_lib mi-support.exp
-+set MIFLAGS "-i=mi2"
-+
-+gdb_exit
-+if [mi_gdb_start] {
-+ continue
-+}
-+
-+set testfile "mi2-var-stale-type"
-+set srcfile ${testfile}.c
-+set binfile [standard_output_file ${testfile}]
-+if {[build_executable ${testfile}.exp $testfile $srcfile] == -1} {
-+ return -1
-+}
-+
-+mi_delete_breakpoints
-+mi_gdb_reinitialize_dir $srcdir/$subdir
-+mi_gdb_load ${binfile}
-+
-+mi_gdb_test {-interpreter-exec console "maintenance set internal-error quit yes"} \
-+ {\^done} \
-+ "maintenance set internal-error quit yes"
-+
-+mi_gdb_test {-interpreter-exec console "maintenance set internal-error corefile yes"} \
-+ {\^done} \
-+ "maintenance set internal-error corefile yes"
-+
-+set line [gdb_get_line_number "break-here"]
-+set func "main"
-+
-+mi_gdb_test "-break-insert -t $srcfile:$line" \
-+ "\\^done,bkpt=\{number=\"\[0-9\]+\",type=\"breakpoint\",disp=\"del\",enabled=\"y\",addr=\"$hex\",func=\"$func\(\\\(.*\\\)\)?\",file=\".*\",fullname=\".*\",line=\"$line\",\[^\r\n\]*,original-location=\".*\"\}" \
-+ "breakpoint at $func"
-+
-+if { [mi_run_cmd] < 0 } {
-+ return -1
-+}
-+mi_expect_stop "breakpoint-hit" $func ".*" ".*" "\[0-9\]+" { "" "disp=\"del\"" } "stop after initializing vla"
-+
-+mi_create_varobj "vla" "vla" "create local variable vla"
-+
-+mi_gdb_test "-var-update *" "\\^done,changelist=.*" "-var-update *"
-diff --git a/gdb/testsuite/gdb.opt/array-from-register-func.c b/gdb/testsuite/gdb.opt/array-from-register-func.c
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.opt/array-from-register-func.c
-@@ -0,0 +1,22 @@
-+/* This file is part of GDB, the GNU debugger.
-+
-+ Copyright 2009 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/>. */
-+
-+int
-+func (int *arr)
-+{
-+ return arr[0];
-+}
-diff --git a/gdb/testsuite/gdb.opt/array-from-register.c b/gdb/testsuite/gdb.opt/array-from-register.c
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.opt/array-from-register.c
-@@ -0,0 +1,28 @@
-+/* This file is part of GDB, the GNU debugger.
-+
-+ Copyright 2009 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/>. */
-+
-+extern int func (int *arr);
-+
-+int
-+main (void)
-+{
-+ int arr[] = { 42 };
-+
-+ func (arr);
-+
-+ return 0;
-+}
-diff --git a/gdb/testsuite/gdb.opt/array-from-register.exp b/gdb/testsuite/gdb.opt/array-from-register.exp
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.opt/array-from-register.exp
-@@ -0,0 +1,33 @@
-+# Copyright 2009 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 2 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, write to the Free Software
-+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-+#
-+# This file is part of the gdb testsuite.
-+
-+if { [prepare_for_testing array-from-register.exp "array-from-register" \
-+ {array-from-register.c array-from-register-func.c} \
-+ {debug optimize=-O2}] } {
-+ return -1
-+}
-+
-+if ![runto func] then {
-+ return -1
-+}
-+
-+gdb_test "p arr" "\\$\[0-9\]+ = \\(int \\*\\) *0x\[0-9a-f\]+"
-+
-+# Seen regression:
-+# Address requested for identifier "arr" which is in register $rdi
-+gdb_test "p arr\[0\]" "\\$\[0-9\]+ = 42"
-diff --git a/gdb/testsuite/gdb.opt/fortran-string.exp b/gdb/testsuite/gdb.opt/fortran-string.exp
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.opt/fortran-string.exp
-@@ -0,0 +1,46 @@
-+# Copyright 2009 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 2 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, write to the Free Software
-+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-+
-+# This file was written by Jan Kratochvil <jan.kratochvil@redhat.com>.
-+
-+# Test GDB can cope with Fortran strings having their length present in a CPU
-+# register. With -O0 the string length is passed on the stack. To make this
-+# test meaningful the follow assertion should pass. It is not being checked
-+# here as the "_s" symbol is compiler dependent:
-+# (gdb) info address _s
-+# Symbol "_s" is a variable in register XX.
-+
-+set test fortran-string
-+set srcfile ${test}.f90
-+if { [prepare_for_testing ${test}.exp ${test} ${srcfile} {debug f90 additional_flags=-O2}] } {
-+ return -1
-+}
-+
-+if ![runto $srcfile:[gdb_get_line_number "s = s"]] then {
-+ perror "couldn't run to breakpoint MAIN__"
-+ continue
-+}
-+
-+gdb_test "info args" ".*s = 'foo'.*"
-+gdb_test_multiple "ptype s" "" {
-+ -re -wrap "type = character \\(3\\)" {
-+ pass $gdb_test_name
-+ }
-+ -re -wrap "type = character\\*3" {
-+ pass $gdb_test_name
-+ }
-+}
-+gdb_test "p s" "\\$\[0-9\]* = 'foo'"
-diff --git a/gdb/testsuite/gdb.opt/fortran-string.f90 b/gdb/testsuite/gdb.opt/fortran-string.f90
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.opt/fortran-string.f90
-@@ -0,0 +1,29 @@
-+! Copyright 2009 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 2 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, write to the Free Software
-+! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-+!
-+! Ihis file is the Fortran source file for dynamic.exp.
-+! Original file written by Jakub Jelinek <jakub@redhat.com>.
-+! Modified for the GDB testcase by Jan Kratochvil <jan.kratochvil@redhat.com>.
-+
-+ subroutine f(s)
-+ character*(*) s
-+ s = s
-+ print *, s
-+ end
-+
-+ program main
-+ call f ('foo')
-+ end
-diff --git a/gdb/testsuite/gdb.pascal/arrays.exp b/gdb/testsuite/gdb.pascal/arrays.exp
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.pascal/arrays.exp
-@@ -0,0 +1,107 @@
-+# Copyright 2008, 2009 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/>.
-+
-+if $tracelevel then {
-+ strace $tracelevel
-+}
-+
-+load_lib "pascal.exp"
-+
-+set testfile "arrays"
-+set srcfile ${testfile}.pas
-+set binfile [standard_output_file ${testfile}$EXEEXT]
-+
-+# These tests only work with fpc, using the -gw3 compile-option
-+pascal_init
-+if { $pascal_compiler_is_fpc != 1 } {
-+ return -1
-+}
-+
-+# Detect if the fpc version is below 2.3.0
-+set fpc_generates_dwarf_for_dynamic_arrays 1
-+if { ($fpcversion_major < 2) || ( ($fpcversion_major == 2) && ($fpcversion_minor < 3))} {
-+ set fpc_generates_dwarf_for_dynamic_arrays 0
-+}
-+
-+
-+if {[gdb_compile_pascal "-gw3 ${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug ]] != "" } {
-+ return -1
-+}
-+
-+gdb_exit
-+gdb_start
-+gdb_reinitialize_dir $srcdir/$subdir
-+gdb_load ${binfile}
-+set bp_location1 [gdb_get_line_number "set breakpoint 1 here"]
-+set bp_location2 [gdb_get_line_number "set breakpoint 2 here"]
-+
-+
-+if { [gdb_breakpoint ${srcfile}:${bp_location1}] } {
-+ pass "setting breakpoint 1"
-+}
-+if { [gdb_breakpoint ${srcfile}:${bp_location2}] } {
-+ pass "setting breakpoint 2"
-+}
-+
-+# Verify that "start" lands inside the right procedure.
-+if { [gdb_start_cmd] < 0 } {
-+ untested start
-+ return -1
-+}
-+
-+gdb_test "" ".* at .*${srcfile}.*" "start"
-+
-+gdb_test "cont" "Breakpoint .*:${bp_location1}.*" "Going to first breakpoint"
-+
-+gdb_test "print StatArrInt" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61\\}" "Print static array of integer type"
-+gdb_test "print StatArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61\\}" "Print static array of integer"
-+
-+gdb_test "cont" "Breakpoint .*:${bp_location2}.*" "Going to second breakpoint"
-+
-+gdb_test "print StatArrChar" ".* = 'abcdefghijkl'" "Print static array of char"
-+gdb_test "print Stat2dArrInt" ".* = \\{\\{0, 1, 2, 3, 4\\}, \\{1, 2, 3, 4, 5\\}, \\{2, 3, 4, 5, 6\\}, \\{3, 4, 5, 6, 7\\}, \\{4, 5, 6, 7, 8\\}, \\{5, 6, 7, 8, 9\\}, \\{6, 7, 8, 9, 10\\}, \\{7, 8, 9, 10, 11\\}, \\{8, 9, 10, 11, 12\\}, \\{9, 10, 11, 12, 13\\}, \\{10, 11, 12, 13, 14\\}, \\{11, 12, 13, 14, 15\\}\\}" "Print static 2-dimensional array of integer"
-+
-+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
-+ setup_xfail "*-*-*"
-+}
-+gdb_test "print DynArrInt" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer type"
-+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
-+ setup_xfail "*-*-*"
-+}
-+gdb_test "print DynArrInt_" ".* = \\{50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62\\}" "Print dynamic array of integer"
-+
-+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
-+ setup_xfail "*-*-*"
-+}
-+gdb_test "print s" ".* = 'test'#0'string'" "Print string containing null-char"
-+
-+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
-+ setup_xfail "*-*-*"
-+} else {
-+ setup_kfail "*-*-*" pascal/26106
-+}
-+gdb_test "print DynArrStr" ".* = \\{'dstr0', 'dstr1', 'dstr2', 'dstr3', 'dstr4', 'dstr5', 'dstr6', 'dstr7', 'dstr8', 'dstr9', 'dstr10', 'dstr11', 'dstr12'\\}" "Print dynamic array of string"
-+
-+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
-+ setup_xfail "*-*-*"
-+} else {
-+ setup_kfail "*-*-*" pascal/26855
-+}
-+gdb_test "print StatArrStr" ".* = \\{'str0', 'str1', 'str2', 'str3', 'str4', 'str5', 'str6', 'str7', 'str8', 'str9', 'str10', 'str11', 'str12'\\}" "Print static array of string"
-+
-+if { $fpc_generates_dwarf_for_dynamic_arrays == 0} {
-+ setup_xfail "*-*-*"
-+}
-+gdb_test "print DynArrChar" ".* = 'abcdefghijklm'" "Print dynamic array of char"
-diff --git a/gdb/testsuite/gdb.pascal/arrays.pas b/gdb/testsuite/gdb.pascal/arrays.pas
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.pascal/arrays.pas
-@@ -0,0 +1,82 @@
-+{
-+ Copyright 2008, 2009 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/>.
-+}
-+
-+program arrays;
-+
-+{$mode objfpc}{$h+}
-+
-+uses sysutils;
-+
-+type TStatArrInt= array[0..11] of integer;
-+ TDynArrInt= array of integer;
-+ TStatArrStr= array[0..12] of string;
-+ TDynArrStr= array of string;
-+ TDynArrChar = array of char;
-+ TStatArrChar = array [0..11] of char;
-+
-+ TStat2dArrInt = array[0..11,0..4] of integer;
-+
-+var StatArrInt: TStatArrInt;
-+ StatArrInt_: Array[0..11] of integer;
-+ DynArrInt: TDynArrInt;
-+ DynArrInt_: Array of integer;
-+ StatArrStr: TStatArrStr;
-+ DynArrStr: TDynArrStr;
-+ StatArrChar: TStatArrChar;
-+ DynArrChar: TDynArrChar;
-+
-+ Stat2dArrInt: TStat2dArrInt;
-+
-+ s: string;
-+
-+ i,j : integer;
-+
-+begin
-+ for i := 0 to 11 do
-+ begin
-+ StatArrInt[i]:= i+50;
-+ StatArrInt_[i]:= i+50;
-+ StatArrChar[i]:= chr(ord('a')+i);
-+ for j := 0 to 4 do
-+ Stat2dArrInt[i,j]:=i+j;
-+ end;
-+ writeln(StatArrInt_[0]);
-+ writeln(StatArrInt[0]); { set breakpoint 1 here }
-+ writeln(StatArrChar[0]);
-+ writeln(Stat2dArrInt[0,0]);
-+
-+ setlength(DynArrInt,13);
-+ setlength(DynArrInt_,13);
-+ setlength(DynArrStr,13);
-+ setlength(DynArrChar,13);
-+ for i := 0 to 12 do
-+ begin
-+ DynArrInt[i]:= i+50;
-+ DynArrInt_[i]:= i+50;
-+ DynArrChar[i]:= chr(ord('a')+i);
-+ StatArrStr[i]:='str'+inttostr(i);
-+ DynArrStr[i]:='dstr'+inttostr(i);
-+ end;
-+ writeln(DynArrInt_[1]);
-+ writeln(DynArrInt[1]);
-+ writeln(DynArrStr[1]);
-+ writeln(StatArrStr[1]);
-+ writeln(DynArrChar[1]);
-+
-+ s := 'test'#0'string';
-+ writeln(s); { set breakpoint 2 here }
-+end.
-diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
---- a/gdb/testsuite/lib/gdb.exp
-+++ b/gdb/testsuite/lib/gdb.exp
-@@ -224,6 +224,11 @@ proc gdb_unload {} {
- send_gdb "y\n" answer
- exp_continue
- }
-+ -re "A program is being debugged already..*Are you sure you want to change the file.*y or n. $"\
-+ { send_gdb "y\n"
-+ verbose "\t\tUnloading symbols for program being debugged"
-+ exp_continue
-+ }
- -re "Discard symbol table from .*y or n.*$" {
- send_gdb "y\n" answer
- exp_continue
-diff --git a/gdb/testsuite/lib/pascal.exp b/gdb/testsuite/lib/pascal.exp
---- a/gdb/testsuite/lib/pascal.exp
-+++ b/gdb/testsuite/lib/pascal.exp
-@@ -37,6 +37,9 @@ proc pascal_init {} {
- gdb_persistent_global pascal_compiler_is_fpc
- gdb_persistent_global gpc_compiler
- gdb_persistent_global fpc_compiler
-+ gdb_persistent_global fpcversion_major
-+ gdb_persistent_global fpcversion_minor
-+ gdb_persistent_global fpcversion_release
- global env
-
- if { $pascal_init_done == 1 } {
-@@ -64,6 +67,20 @@ proc pascal_init {} {
- set pascal_compiler_is_fpc 1
- verbose -log "Free Pascal compiler found"
- }
-+
-+ # Detect the fpc-version
-+ if { $pascal_compiler_is_fpc == 1 } {
-+ set fpcversion_major 1
-+ set fpcversion_minor 0
-+ set fpcversion_release 0
-+ set fpcversion [ remote_exec host $fpc_compiler "-iV" ]
-+ if [regexp {.*([0-9]+)\.([0-9]+)\.([0-9]+).?} $fpcversion] {
-+ regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\1} fpcversion_major
-+ regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\2} fpcversion_minor
-+ regsub {.*([0-9]+)\.([0-9]+)\.([0-9]+).?\n?.?} $fpcversion {\3} fpcversion_release
-+ }
-+ verbose -log "Freepascal version: $fpcversion_major.$fpcversion_minor.$fpcversion_release"
-+ }
- }
- set pascal_init_done 1
- }
+++ /dev/null
-From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
-From: Fedora GDB patches <invalid@email.com>
-Date: Fri, 27 Oct 2017 21:07:50 +0200
-Subject: gdb-vla-intel-fortran-strides.patch
-
-;; VLA (Fortran dynamic arrays) from Intel + archer-jankratochvil-vla tests.
-;;=push
-
-git diff --stat -p gdb/master...gdb/users/bheckel/fortran-strides
-dbfd7140bf4c0500d1f5d192be781f83f78f7922
-
- gdb/dwarf2loc.c | 46 ++-
- gdb/dwarf2loc.h | 6 +
- gdb/dwarf2read.c | 13 +-
- gdb/eval.c | 391 +++++++++++++++++++++-----
- gdb/expprint.c | 20 +-
- gdb/expression.h | 18 +-
- gdb/f-exp.y | 42 ++-
- gdb/f-valprint.c | 8 +-
- gdb/gdbtypes.c | 34 ++-
- gdb/gdbtypes.h | 18 +-
- gdb/parse.c | 24 +-
- gdb/rust-exp.y | 12 +-
- gdb/rust-lang.c | 17 +-
- gdb/testsuite/gdb.fortran/static-arrays.exp | 421 ++++++++++++++++++++++++++++
- gdb/testsuite/gdb.fortran/static-arrays.f90 | 55 ++++
- gdb/testsuite/gdb.fortran/vla-ptype.exp | 4 +
- gdb/testsuite/gdb.fortran/vla-sizeof.exp | 4 +
- gdb/testsuite/gdb.fortran/vla-stride.exp | 44 +++
- gdb/testsuite/gdb.fortran/vla-stride.f90 | 29 ++
- gdb/testsuite/gdb.fortran/vla.f90 | 10 +
- gdb/valarith.c | 10 +-
- gdb/valops.c | 197 +++++++++++--
- gdb/value.h | 2 +
- 23 files changed, 1242 insertions(+), 183 deletions(-)
-
-diff --git a/gdb/eval.c b/gdb/eval.c
---- a/gdb/eval.c
-+++ b/gdb/eval.c
-@@ -371,29 +371,323 @@ init_array_element (struct value *array, struct value *element,
- return index;
- }
-
-+/* Evaluates any operation on Fortran arrays or strings with at least
-+ one user provided parameter. Expects the input ARRAY to be either
-+ an array, or a string. Evaluates EXP by incrementing POS, and
-+ writes the content from the elt stack into a local struct. NARGS
-+ specifies number of literal or range arguments the user provided.
-+ NARGS must be the same number as ARRAY has dimensions. */
-+
- static struct value *
--value_f90_subarray (struct value *array,
-- struct expression *exp, int *pos, enum noside noside)
-+value_f90_subarray (struct value *array, struct expression *exp,
-+ int *pos, int nargs, enum noside noside)
- {
-- int pc = (*pos) + 1;
-- LONGEST low_bound, high_bound;
-- struct type *range = check_typedef (value_type (array)->index_type ());
-- enum range_type range_type
-- = (enum range_type) longest_to_int (exp->elts[pc].longconst);
--
-- *pos += 3;
--
-- if (range_type == LOW_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT)
-- low_bound = range->bounds ()->low.const_val ();
-- else
-- low_bound = value_as_long (evaluate_subexp (nullptr, exp, pos, noside));
-+ int i, dim_count = 0;
-+ struct value *new_array = array;
-+ struct type *array_type = check_typedef (value_type (new_array));
-+ struct type *elt_type;
-+
-+ typedef struct
-+ {
-+ enum range_type f90_range_type;
-+ LONGEST low, high, stride;
-+ } subscript_range;
-+
-+ typedef enum subscript_kind
-+ {
-+ SUBSCRIPT_RANGE, /* e.g. "(lowbound:highbound)" */
-+ SUBSCRIPT_INDEX /* e.g. "(literal)" */
-+ } kind;
-+
-+ /* Local struct to hold user data for Fortran subarray dimensions. */
-+ struct subscript_store
-+ {
-+ /* For every dimension, we are either working on a range or an index
-+ expression, so we store this info separately for later. */
-+ enum subscript_kind kind;
-+
-+ /* We also store either the lower and upper bound info, or the index
-+ number. Before evaluation of the input values, we do not know if we are
-+ actually working on a range of ranges, or an index in a range. So as a
-+ first step we store all input in a union. The array calculation itself
-+ deals with this later on. */
-+ union element_range
-+ {
-+ subscript_range range;
-+ LONGEST number;
-+ } U;
-+ } *subscript_array;
-+
-+ /* Check if the number of arguments provided by the user matches
-+ the number of dimension of the array. A string has only one
-+ dimension. */
-+ if (nargs != calc_f77_array_dims (value_type (new_array)))
-+ error (_("Wrong number of subscripts"));
-+
-+ subscript_array = (struct subscript_store*) alloca (sizeof (*subscript_array) * nargs);
-+
-+ /* Parse the user input into the SUBSCRIPT_ARRAY to store it. We need
-+ to evaluate it first, as the input is from left-to-right. The
-+ array is stored from right-to-left. So we have to use the user
-+ input in reverse order. Later on, we need the input information to
-+ re-calculate the output array. For multi-dimensional arrays, we
-+ can be dealing with any possible combination of ranges and indices
-+ for every dimension. */
-+ for (i = 0; i < nargs; i++)
-+ {
-+ struct subscript_store *index = &subscript_array[i];
-+
-+ /* The user input is a range, with or without lower and upper bound.
-+ E.g.: "p arry(2:5)", "p arry( :5)", "p arry( : )", etc. */
-+ if (exp->elts[*pos].opcode == OP_RANGE)
-+ {
-+ int pc = (*pos) + 1;
-+ subscript_range *range;
-+
-+ index->kind = SUBSCRIPT_RANGE;
-+ range = &index->U.range;
-+
-+ *pos += 3;
-+ range->f90_range_type = (enum range_type) exp->elts[pc].longconst;
-+
-+ /* If a lower bound was provided by the user, the bit has been
-+ set and we can assign the value from the elt stack. Same for
-+ upper bound. */
-+ if ((range->f90_range_type & SUBARRAY_LOW_BOUND)
-+ == SUBARRAY_LOW_BOUND)
-+ range->low = value_as_long (evaluate_subexp (nullptr, exp,
-+ pos, noside));
-+ if ((range->f90_range_type & SUBARRAY_HIGH_BOUND)
-+ == SUBARRAY_HIGH_BOUND)
-+ range->high = value_as_long (evaluate_subexp (nullptr, exp,
-+ pos, noside));
-+
-+ /* Assign the user's stride value if provided. */
-+ if ((range->f90_range_type & SUBARRAY_STRIDE) == SUBARRAY_STRIDE)
-+ range->stride = value_as_long (evaluate_subexp (nullptr, exp,
-+ pos, noside));
-+
-+ /* Assign the default stride value '1'. */
-+ else
-+ range->stride = 1;
-
-- if (range_type == HIGH_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT)
-- high_bound = range->bounds ()->high.const_val ();
-- else
-- high_bound = value_as_long (evaluate_subexp (nullptr, exp, pos, noside));
-+ /* Check the provided stride value is illegal, aka '0'. */
-+ if (range->stride == 0)
-+ error (_("Stride must not be 0"));
-+ }
-+ /* User input is an index. E.g.: "p arry(5)". */
-+ else
-+ {
-+ struct value *val;
-+
-+ index->kind = SUBSCRIPT_INDEX;
-+
-+ /* Evaluate each subscript; it must be a legal integer in F77. This
-+ ensures the validity of the provided index. */
-+ val = evaluate_subexp_with_coercion (exp, pos, noside);
-+ index->U.number = value_as_long (val);
-+ }
-+
-+ }
-+
-+ /* Traverse the array from right to left and set the high and low bounds
-+ for later use. */
-+ for (i = nargs - 1; i >= 0; i--)
-+ {
-+ struct subscript_store *index = &subscript_array[i];
-+ struct type *index_type = array_type->index_type ();
-+
-+ switch (index->kind)
-+ {
-+ case SUBSCRIPT_RANGE:
-+ {
-+
-+ /* When we hit the first range specified by the user, we must
-+ treat any subsequent user entry as a range. We simply
-+ increment DIM_COUNT which tells us how many times we are
-+ calling VALUE_SLICE_1. */
-+ subscript_range *range = &index->U.range;
-+
-+ /* If no lower bound was provided by the user, we take the
-+ default boundary. Same for the high bound. */
-+ if ((range->f90_range_type & SUBARRAY_LOW_BOUND) == 0)
-+ range->low = index_type->bounds ()->low.const_val ();
-+
-+ if ((range->f90_range_type & SUBARRAY_HIGH_BOUND) == 0)
-+ range->high = index_type->bounds ()->high.const_val ();
-+
-+ /* Both user provided low and high bound have to be inside the
-+ array bounds. Throw an error if not. */
-+ if (range->low < index_type->bounds ()->low.const_val ()
-+ || range->low > index_type->bounds ()->high.const_val ()
-+ || range->high < index_type->bounds ()->low.const_val ()
-+ || range->high > index_type->bounds ()->high.const_val ())
-+ error (_("provided bound(s) outside array bound(s)"));
-+
-+ /* For a negative stride the lower boundary must be larger than the
-+ upper boundary.
-+ For a positive stride the lower boundary must be smaller than the
-+ upper boundary. */
-+ if ((range->stride < 0 && range->low < range->high)
-+ || (range->stride > 0 && range->low > range->high))
-+ error (_("Wrong value provided for stride and boundaries"));
-+
-+ }
-+ break;
-+
-+ case SUBSCRIPT_INDEX:
-+ break;
-+
-+ }
-+
-+ array_type = TYPE_TARGET_TYPE (array_type);
-+ }
-+
-+ /* Reset ARRAY_TYPE before slicing.*/
-+ array_type = check_typedef (value_type (new_array));
-+
-+ /* Traverse the array from right to left and evaluate each corresponding
-+ user input. VALUE_SUBSCRIPT is called for every index, until a range
-+ expression is evaluated. After a range expression has been evaluated,
-+ every subsequent expression is also treated as a range. */
-+ for (i = nargs - 1; i >= 0; i--)
-+ {
-+ struct subscript_store *index = &subscript_array[i];
-+ struct type *index_type = array_type->index_type ();
-+
-+ switch (index->kind)
-+ {
-+ case SUBSCRIPT_RANGE:
-+ {
-+
-+ /* When we hit the first range specified by the user, we must
-+ treat any subsequent user entry as a range. We simply
-+ increment DIM_COUNT which tells us how many times we are
-+ calling VALUE_SLICE_1. */
-+ subscript_range *range = &index->U.range;
-+
-+ /* DIM_COUNT counts every user argument that is treated as a range.
-+ This is necessary for expressions like 'print array(7, 8:9).
-+ Here the first argument is a literal, but must be treated as a
-+ range argument to allow the correct output representation. */
-+ dim_count++;
-+
-+ new_array
-+ = value_slice_1 (new_array, range->low,
-+ range->high - range->low + 1,
-+ range->stride, dim_count);
-+ }
-+ break;
-+
-+ case SUBSCRIPT_INDEX:
-+ {
-+ /* DIM_COUNT only stays '0' when no range argument was processed
-+ before, starting from the last dimension. This way we can
-+ reduce the number of dimensions from the result array.
-+ However, if a range has been processed before an index, we
-+ treat the index like a range with equal low- and high bounds
-+ to get the value offset right. */
-+ if (dim_count == 0)
-+ new_array
-+ = value_subscripted_rvalue (new_array, index->U.number,
-+ f77_get_lowerbound (value_type
-+ (new_array)));
-+ else
-+ {
-+ dim_count++;
-+
-+ /* We might end up here, because we have to treat the provided
-+ index like a range. But now VALUE_SUBSCRIPTED_RVALUE
-+ cannot do the range checks for us. So we have to make sure
-+ ourselves that the user provided index is inside the
-+ array bounds. Throw an error if not. */
-+ if (index->U.number < index_type->bounds ()->low.const_val ()
-+ && index->U.number > index_type->bounds ()->high.const_val ())
-+ error (_("provided bound(s) outside array bound(s)"));
-+
-+ if (index->U.number > index_type->bounds ()->low.const_val ()
-+ && index->U.number > index_type->bounds ()->high.const_val ())
-+ error (_("provided bound(s) outside array bound(s)"));
-+
-+ new_array = value_slice_1 (new_array,
-+ index->U.number,
-+ 1, /* COUNT is '1' element */
-+ 1, /* STRIDE set to '1' */
-+ dim_count);
-+ }
-+
-+ }
-+ break;
-+ }
-+ array_type = TYPE_TARGET_TYPE (array_type);
-+ }
-+
-+ /* With DIM_COUNT > 1 we currently have a one dimensional array, but expect
-+ an array of arrays, depending on how many ranges have been provided by
-+ the user. So we need to rebuild the array dimensions for printing it
-+ correctly.
-+ Starting from right to left in the user input, after we hit the first
-+ range argument every subsequent argument is also treated as a range.
-+ E.g.:
-+ "p ary(3, 7, 2:15)" in Fortran has only 1 dimension, but we calculated 3
-+ ranges.
-+ "p ary(3, 7:12, 4)" in Fortran has only 1 dimension, but we calculated 2
-+ ranges.
-+ "p ary(2:4, 5, 7)" in Fortran has only 1 dimension, and we calculated 1
-+ range. */
-+ if (dim_count > 1)
-+ {
-+ struct value *v = NULL;
-+
-+ elt_type = TYPE_TARGET_TYPE (value_type (new_array));
-
-- return value_slice (array, low_bound, high_bound - low_bound + 1);
-+ /* Every SUBSCRIPT_RANGE in the user input signifies an actual range in
-+ the output array. So we traverse the SUBSCRIPT_ARRAY again, looking
-+ for a range entry. When we find one, we use the range info to create
-+ an additional range_type to set the correct bounds and dimensions for
-+ the output array. In addition, we may have a stride value that is not
-+ '1', forcing us to adjust the number of elements in a range, according
-+ to the stride value. */
-+ for (i = 0; i < nargs; i++)
-+ {
-+ struct subscript_store *index = &subscript_array[i];
-+
-+ if (index->kind == SUBSCRIPT_RANGE)
-+ {
-+ struct type *range_type, *interim_array_type;
-+
-+ int new_length;
-+
-+ /* The length of a sub-dimension with all elements between the
-+ bounds plus the start element itself. It may be modified by
-+ a user provided stride value. */
-+ new_length = index->U.range.high - index->U.range.low;
-+
-+ new_length /= index->U.range.stride;
-+
-+ range_type
-+ = create_static_range_type (NULL,
-+ elt_type,
-+ index->U.range.low,
-+ index->U.range.low + new_length);
-+
-+ interim_array_type = create_array_type (NULL,
-+ elt_type,
-+ range_type);
-+
-+ interim_array_type->set_code ( value_type (new_array)->code ());
-+
-+ v = allocate_value (interim_array_type);
-+
-+ elt_type = value_type (v);
-+ }
-+
-+ }
-+ value_contents_copy (v, 0, new_array, 0, TYPE_LENGTH (elt_type));
-+ return v;
-+ }
-+
-+ return new_array;
- }
-
-
-@@ -1233,19 +1527,6 @@ evaluate_funcall (type *expect_type, expression *exp, int *pos,
- return eval_call (exp, noside, nargs, argvec, var_func_name, expect_type);
- }
-
--/* Helper for skipping all the arguments in an undetermined argument list.
-- This function was designed for use in the OP_F77_UNDETERMINED_ARGLIST
-- case of evaluate_subexp_standard as multiple, but not all, code paths
-- require a generic skip. */
--
--static void
--skip_undetermined_arglist (int nargs, struct expression *exp, int *pos,
-- enum noside noside)
--{
-- for (int i = 0; i < nargs; ++i)
-- evaluate_subexp (nullptr, exp, pos, noside);
--}
--
- /* Return true if type is integral or reference to integral */
-
- static bool
-@@ -1953,33 +2234,8 @@ evaluate_subexp_standard (struct type *expect_type,
- switch (code)
- {
- case TYPE_CODE_ARRAY:
-- if (exp->elts[*pos].opcode == OP_RANGE)
-- return value_f90_subarray (arg1, exp, pos, noside);
-- else
-- {
-- if (noside == EVAL_SKIP)
-- {
-- skip_undetermined_arglist (nargs, exp, pos, noside);
-- /* Return the dummy value with the correct type. */
-- return arg1;
-- }
-- goto multi_f77_subscript;
-- }
--
- case TYPE_CODE_STRING:
-- if (exp->elts[*pos].opcode == OP_RANGE)
-- return value_f90_subarray (arg1, exp, pos, noside);
-- else
-- {
-- if (noside == EVAL_SKIP)
-- {
-- skip_undetermined_arglist (nargs, exp, pos, noside);
-- /* Return the dummy value with the correct type. */
-- return arg1;
-- }
-- arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
-- return value_subscript (arg1, value_as_long (arg2));
-- }
-+ return value_f90_subarray (arg1, exp, pos, nargs, noside);
-
- case TYPE_CODE_PTR:
- case TYPE_CODE_FUNC:
-@@ -2400,49 +2656,6 @@ evaluate_subexp_standard (struct type *expect_type,
- }
- return (arg1);
-
-- multi_f77_subscript:
-- {
-- LONGEST subscript_array[MAX_FORTRAN_DIMS];
-- int ndimensions = 1, i;
-- struct value *array = arg1;
--
-- if (nargs > MAX_FORTRAN_DIMS)
-- error (_("Too many subscripts for F77 (%d Max)"), MAX_FORTRAN_DIMS);
--
-- ndimensions = calc_f77_array_dims (type);
--
-- if (nargs != ndimensions)
-- error (_("Wrong number of subscripts"));
--
-- gdb_assert (nargs > 0);
--
-- /* Now that we know we have a legal array subscript expression
-- let us actually find out where this element exists in the array. */
--
-- /* Take array indices left to right. */
-- for (i = 0; i < nargs; i++)
-- {
-- /* Evaluate each subscript; it must be a legal integer in F77. */
-- arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
--
-- /* Fill in the subscript array. */
--
-- subscript_array[i] = value_as_long (arg2);
-- }
--
-- /* Internal type of array is arranged right to left. */
-- for (i = nargs; i > 0; i--)
-- {
-- struct type *array_type = check_typedef (value_type (array));
-- LONGEST index = subscript_array[i - 1];
--
-- array = value_subscripted_rvalue (array, index,
-- f77_get_lowerbound (array_type));
-- }
--
-- return array;
-- }
--
- case BINOP_LOGICAL_AND:
- arg1 = evaluate_subexp (nullptr, exp, pos, noside);
- if (noside == EVAL_SKIP)
-@@ -3360,6 +3573,9 @@ calc_f77_array_dims (struct type *array_type)
- int ndimen = 1;
- struct type *tmp_type;
-
-+ if (array_type->code () == TYPE_CODE_STRING)
-+ return 1;
-+
- if ((array_type->code () != TYPE_CODE_ARRAY))
- error (_("Can't get dimensions for a non-array type"));
-
-diff --git a/gdb/expprint.c b/gdb/expprint.c
---- a/gdb/expprint.c
-+++ b/gdb/expprint.c
-@@ -576,17 +576,14 @@ print_subexp_standard (struct expression *exp, int *pos,
- longest_to_int (exp->elts[pc + 1].longconst);
- *pos += 2;
-
-- if (range_type == NONE_BOUND_DEFAULT_EXCLUSIVE
-- || range_type == LOW_BOUND_DEFAULT_EXCLUSIVE)
-+ if ((range_type & SUBARRAY_HIGH_BOUND_EXCLUSIVE)
-+ == SUBARRAY_HIGH_BOUND_EXCLUSIVE)
- fputs_filtered ("EXCLUSIVE_", stream);
- fputs_filtered ("RANGE(", stream);
-- if (range_type == HIGH_BOUND_DEFAULT
-- || range_type == NONE_BOUND_DEFAULT
-- || range_type == NONE_BOUND_DEFAULT_EXCLUSIVE)
-+ if ((range_type & SUBARRAY_LOW_BOUND) == SUBARRAY_LOW_BOUND)
- print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
- fputs_filtered ("..", stream);
-- if (range_type == LOW_BOUND_DEFAULT
-- || range_type == NONE_BOUND_DEFAULT)
-+ if ((range_type & SUBARRAY_HIGH_BOUND) == SUBARRAY_HIGH_BOUND)
- print_subexp (exp, pos, stream, PREC_ABOVE_COMMA);
- fputs_filtered (")", stream);
- return;
-@@ -1103,22 +1100,24 @@ dump_subexp_body_standard (struct expression *exp,
-
- switch (range_type)
- {
-- case BOTH_BOUND_DEFAULT:
-+ case SUBARRAY_NONE_BOUND:
- fputs_filtered ("Range '..'", stream);
- break;
-- case LOW_BOUND_DEFAULT:
-+ case SUBARRAY_HIGH_BOUND:
- fputs_filtered ("Range '..EXP'", stream);
- break;
-- case LOW_BOUND_DEFAULT_EXCLUSIVE:
-- fputs_filtered ("ExclusiveRange '..EXP'", stream);
-- break;
-- case HIGH_BOUND_DEFAULT:
-+ case SUBARRAY_LOW_BOUND:
- fputs_filtered ("Range 'EXP..'", stream);
- break;
-- case NONE_BOUND_DEFAULT:
-+ case (SUBARRAY_LOW_BOUND
-+ | SUBARRAY_HIGH_BOUND
-+ | SUBARRAY_HIGH_BOUND_EXCLUSIVE):
-+ fputs_filtered ("ExclusiveRange '..EXP'", stream);
-+ break;
-+ case (SUBARRAY_LOW_BOUND | SUBARRAY_HIGH_BOUND):
- fputs_filtered ("Range 'EXP..EXP'", stream);
- break;
-- case NONE_BOUND_DEFAULT_EXCLUSIVE:
-+ case (SUBARRAY_HIGH_BOUND | SUBARRAY_HIGH_BOUND_EXCLUSIVE):
- fputs_filtered ("ExclusiveRange 'EXP..EXP'", stream);
- break;
- default:
-@@ -1126,11 +1125,9 @@ dump_subexp_body_standard (struct expression *exp,
- break;
- }
-
-- if (range_type == HIGH_BOUND_DEFAULT
-- || range_type == NONE_BOUND_DEFAULT)
-+ if ((range_type & SUBARRAY_LOW_BOUND) == SUBARRAY_LOW_BOUND)
- elt = dump_subexp (exp, stream, elt);
-- if (range_type == LOW_BOUND_DEFAULT
-- || range_type == NONE_BOUND_DEFAULT)
-+ if ((range_type & SUBARRAY_HIGH_BOUND) == SUBARRAY_HIGH_BOUND)
- elt = dump_subexp (exp, stream, elt);
- }
- break;
-diff --git a/gdb/expression.h b/gdb/expression.h
---- a/gdb/expression.h
-+++ b/gdb/expression.h
-@@ -167,28 +167,27 @@ extern void dump_raw_expression (struct expression *,
- struct ui_file *, const char *);
- extern void dump_prefix_expression (struct expression *, struct ui_file *);
-
--/* In an OP_RANGE expression, either bound could be empty, indicating
-- that its value is by default that of the corresponding bound of the
-- array or string. Also, the upper end of the range can be exclusive
-- or inclusive. So we have six sorts of subrange. This enumeration
-- type is to identify this. */
-+/* In an OP_RANGE expression, either bound can be provided by the
-+ user, or not. In addition to this, the user can also specify a
-+ stride value to indicated only certain elements of the array.
-+ Also, the upper end of the range can be exclusive or inclusive.
-+ This enumeration type is to identify this. */
-
- enum range_type
--{
-- /* Neither the low nor the high bound was given -- so this refers to
-- the entire available range. */
-- BOTH_BOUND_DEFAULT,
-- /* The low bound was not given and the high bound is inclusive. */
-- LOW_BOUND_DEFAULT,
-- /* The high bound was not given and the low bound in inclusive. */
-- HIGH_BOUND_DEFAULT,
-- /* Both bounds were given and both are inclusive. */
-- NONE_BOUND_DEFAULT,
-- /* The low bound was not given and the high bound is exclusive. */
-- NONE_BOUND_DEFAULT_EXCLUSIVE,
-- /* Both bounds were given. The low bound is inclusive and the high
-- bound is exclusive. */
-- LOW_BOUND_DEFAULT_EXCLUSIVE,
--};
-+ {
-+ SUBARRAY_NONE_BOUND = 0x0, /* "( : )" */
-+ SUBARRAY_LOW_BOUND = 0x1, /* "(low:)" */
-+ SUBARRAY_HIGH_BOUND = 0x2, /* "(:high)" */
-+ SUBARRAY_STRIDE = 0x4, /* "(::stride)" */
-+ /* The low bound was not given and the high bound is exclusive.
-+ In this case we always use (SUBARRAY_HIGH_BOUND |
-+ SUBARRAY_HIGH_BOUND_EXCLUSIVE). */
-+ SUBARRAY_HIGH_BOUND_EXCLUSIVE = 0x8,
-+ /* Both bounds were given. The low bound is inclusive and the high
-+ bound is exclusive. In this case, we use (SUBARRAY_LOW_BOUND |
-+ SUBARRAY_HIGH_BOUND | SUBARRAY_HIGH_BOUND_EXCLUSIVE). */
-+ // SUBARRAY_LOW_BOUND_EXCLUSIVE = (SUBARRAY_LOW_BOUND
-+ // | SUBARRAY_HIGH_BOUND_EXCLUSIVE),
-+ };
-
- #endif /* !defined (EXPRESSION_H) */
-diff --git a/gdb/f-exp.y b/gdb/f-exp.y
---- a/gdb/f-exp.y
-+++ b/gdb/f-exp.y
-@@ -282,31 +282,63 @@ arglist : subrange
-
- arglist : arglist ',' exp %prec ABOVE_COMMA
- { pstate->arglist_len++; }
-+ | arglist ',' subrange %prec ABOVE_COMMA
-+ { pstate->arglist_len++; }
- ;
-
- /* There are four sorts of subrange types in F90. */
-
- subrange: exp ':' exp %prec ABOVE_COMMA
-- { write_exp_elt_opcode (pstate, OP_RANGE);
-- write_exp_elt_longcst (pstate, NONE_BOUND_DEFAULT);
-+ { write_exp_elt_opcode (pstate, OP_RANGE);
-+ write_exp_elt_longcst (pstate,
-+ SUBARRAY_LOW_BOUND | SUBARRAY_HIGH_BOUND);
- write_exp_elt_opcode (pstate, OP_RANGE); }
- ;
-
- subrange: exp ':' %prec ABOVE_COMMA
- { write_exp_elt_opcode (pstate, OP_RANGE);
-- write_exp_elt_longcst (pstate, HIGH_BOUND_DEFAULT);
-+ write_exp_elt_longcst (pstate, SUBARRAY_LOW_BOUND);
- write_exp_elt_opcode (pstate, OP_RANGE); }
- ;
-
- subrange: ':' exp %prec ABOVE_COMMA
- { write_exp_elt_opcode (pstate, OP_RANGE);
-- write_exp_elt_longcst (pstate, LOW_BOUND_DEFAULT);
-+ write_exp_elt_longcst (pstate, SUBARRAY_HIGH_BOUND);
- write_exp_elt_opcode (pstate, OP_RANGE); }
- ;
-
- subrange: ':' %prec ABOVE_COMMA
- { write_exp_elt_opcode (pstate, OP_RANGE);
-- write_exp_elt_longcst (pstate, BOTH_BOUND_DEFAULT);
-+ write_exp_elt_longcst (pstate, SUBARRAY_NONE_BOUND);
-+ write_exp_elt_opcode (pstate, OP_RANGE); }
-+ ;
-+
-+/* Each subrange type can have a stride argument. */
-+subrange: exp ':' exp ':' exp %prec ABOVE_COMMA
-+ { write_exp_elt_opcode (pstate, OP_RANGE);
-+ write_exp_elt_longcst (pstate, SUBARRAY_LOW_BOUND
-+ | SUBARRAY_HIGH_BOUND
-+ | SUBARRAY_STRIDE);
-+ write_exp_elt_opcode (pstate, OP_RANGE); }
-+ ;
-+
-+subrange: exp ':' ':' exp %prec ABOVE_COMMA
-+ { write_exp_elt_opcode (pstate, OP_RANGE);
-+ write_exp_elt_longcst (pstate, SUBARRAY_LOW_BOUND
-+ | SUBARRAY_STRIDE);
-+ write_exp_elt_opcode (pstate, OP_RANGE); }
-+ ;
-+
-+subrange: ':' exp ':' exp %prec ABOVE_COMMA
-+ { write_exp_elt_opcode (pstate, OP_RANGE);
-+ write_exp_elt_longcst (pstate, SUBARRAY_HIGH_BOUND
-+ | SUBARRAY_STRIDE);
-+ write_exp_elt_opcode (pstate, OP_RANGE); }
-+ ;
-+
-+subrange: ':' ':' exp %prec ABOVE_COMMA
-+ { write_exp_elt_opcode (pstate, OP_RANGE);
-+ write_exp_elt_longcst (pstate, SUBARRAY_STRIDE);
- write_exp_elt_opcode (pstate, OP_RANGE); }
- ;
-
-diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
---- a/gdb/f-valprint.c
-+++ b/gdb/f-valprint.c
-@@ -129,6 +129,11 @@ f77_print_array_1 (int nss, int ndimensions, struct type *type,
- byte_stride = dim_size;
- size_t offs = 0;
-
-+ if (byte_stride)
-+ dim_size = byte_stride;
-+ else
-+ dim_size = TYPE_LENGTH (TYPE_TARGET_TYPE (type));
-+
- for (i = lowerbound;
- (i < upperbound + 1 && (*elts) < options->print_max);
- i++)
-diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
---- a/gdb/gdbtypes.c
-+++ b/gdb/gdbtypes.c
-@@ -1006,7 +1006,8 @@ create_static_range_type (struct type *result_type, struct type *index_type,
- low.set_const_val (low_bound);
- high.set_const_val (high_bound);
-
-- result_type = create_range_type (result_type, index_type, &low, &high, 0);
-+ result_type = create_range_type (result_type, index_type,
-+ &low, &high, 0);
-
- return result_type;
- }
-diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
---- a/gdb/gdbtypes.h
-+++ b/gdb/gdbtypes.h
-@@ -1615,6 +1615,15 @@ extern unsigned type_align (struct type *);
- space in struct type. */
- extern bool set_type_align (struct type *, ULONGEST);
-
-+#define TYPE_BYTE_STRIDE(range_type) \
-+ TYPE_RANGE_DATA(range_type)->stride.data.const_val
-+#define TYPE_BYTE_STRIDE_BLOCK(range_type) \
-+ TYPE_RANGE_DATA(range_type)->stride.data.locexpr
-+#define TYPE_BYTE_STRIDE_LOCLIST(range_type) \
-+ TYPE_RANGE_DATA(range_type)->stride.data.loclist
-+#define TYPE_BYTE_STRIDE_KIND(range_type) \
-+ TYPE_RANGE_DATA(range_type)->stride.kind
-+
- /* Property accessors for the type data location. */
- #define TYPE_DATA_LOCATION(thistype) \
- ((thistype)->dyn_prop (DYN_PROP_DATA_LOCATION))
-@@ -1633,6 +1642,26 @@ extern bool set_type_align (struct type *, ULONGEST);
- #define TYPE_ASSOCIATED_PROP(thistype) \
- ((thistype)->dyn_prop (DYN_PROP_ASSOCIATED))
-
-+/* Accessors for struct range_bounds data attached to an array type's
-+ index type. */
-+
-+#define TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED(arraytype) \
-+ ((arraytype)->index_type ()->bounds ()->high.kind () == PROP_UNDEFINED)
-+#define TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED(arraytype) \
-+ (arraytype->index_type ()->bounds ().low.kind () == PROP_UNDEFINED)
-+#define TYPE_ARRAY_STRIDE_IS_UNDEFINED(arraytype) \
-+ (TYPE_BYTE_STRIDE(arraytype->index_type ()) == 0)
-+
-+
-+#define TYPE_ARRAY_UPPER_BOUND_VALUE(arraytype) \
-+ (TYPE_HIGH_BOUND((arraytype)->index_type ()))
-+
-+#define TYPE_ARRAY_LOWER_BOUND_VALUE(arraytype) \
-+ (TYPE_LOW_BOUND((arraytype)->index_type ()))
-+
-+#define TYPE_ARRAY_BIT_STRIDE(arraytype) \
-+ (TYPE_BIT_STRIDE((arraytype)->index_type ()))
-+
- /* C++ */
-
- #define TYPE_SELF_TYPE(thistype) internal_type_self_type (thistype)
-diff --git a/gdb/parse.c b/gdb/parse.c
---- a/gdb/parse.c
-+++ b/gdb/parse.c
-@@ -919,24 +919,20 @@ operator_length_standard (const struct expression *expr, int endpos,
-
- case OP_RANGE:
- oplen = 3;
-+ args = 0;
- range_type = (enum range_type)
- longest_to_int (expr->elts[endpos - 2].longconst);
-
-- switch (range_type)
-- {
-- case LOW_BOUND_DEFAULT:
-- case LOW_BOUND_DEFAULT_EXCLUSIVE:
-- case HIGH_BOUND_DEFAULT:
-- args = 1;
-- break;
-- case BOTH_BOUND_DEFAULT:
-- args = 0;
-- break;
-- case NONE_BOUND_DEFAULT:
-- case NONE_BOUND_DEFAULT_EXCLUSIVE:
-- args = 2;
-- break;
-- }
-+ /* Increment the argument counter for each argument
-+ provided by the user. */
-+ if ((range_type & SUBARRAY_LOW_BOUND) == SUBARRAY_LOW_BOUND)
-+ args++;
-+
-+ if ((range_type & SUBARRAY_HIGH_BOUND) == SUBARRAY_HIGH_BOUND)
-+ args++;
-+
-+ if ((range_type & SUBARRAY_STRIDE) == SUBARRAY_STRIDE)
-+ args++;
-
- break;
-
-diff --git a/gdb/rust-exp.y b/gdb/rust-exp.y
---- a/gdb/rust-exp.y
-+++ b/gdb/rust-exp.y
-@@ -2492,24 +2492,28 @@ rust_parser::convert_ast_to_expression (const struct rust_op *operation,
-
- case OP_RANGE:
- {
-- enum range_type kind = BOTH_BOUND_DEFAULT;
-+ enum range_type kind = SUBARRAY_NONE_BOUND;
-
- if (operation->left.op != NULL)
- {
- convert_ast_to_expression (operation->left.op, top);
-- kind = HIGH_BOUND_DEFAULT;
-+ kind = SUBARRAY_LOW_BOUND;
- }
- if (operation->right.op != NULL)
- {
- convert_ast_to_expression (operation->right.op, top);
-- if (kind == BOTH_BOUND_DEFAULT)
-- kind = (operation->inclusive
-- ? LOW_BOUND_DEFAULT : LOW_BOUND_DEFAULT_EXCLUSIVE);
-+ if (kind == SUBARRAY_NONE_BOUND)
-+ {
-+ kind = (range_type) SUBARRAY_HIGH_BOUND;
-+ if (!operation->inclusive)
-+ kind = (range_type) (kind | SUBARRAY_HIGH_BOUND_EXCLUSIVE);
-+ }
- else
- {
-- gdb_assert (kind == HIGH_BOUND_DEFAULT);
-- kind = (operation->inclusive
-- ? NONE_BOUND_DEFAULT : NONE_BOUND_DEFAULT_EXCLUSIVE);
-+ gdb_assert (kind == SUBARRAY_LOW_BOUND);
-+ kind = (range_type) (kind | SUBARRAY_HIGH_BOUND);
-+ if (!operation->inclusive)
-+ kind = (range_type) (kind | SUBARRAY_HIGH_BOUND_EXCLUSIVE);
- }
- }
- else
-diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
---- a/gdb/rust-lang.c
-+++ b/gdb/rust-lang.c
-@@ -1082,13 +1082,11 @@ rust_range (struct expression *exp, int *pos, enum noside noside)
- kind = (enum range_type) longest_to_int (exp->elts[*pos + 1].longconst);
- *pos += 3;
-
-- if (kind == HIGH_BOUND_DEFAULT || kind == NONE_BOUND_DEFAULT
-- || kind == NONE_BOUND_DEFAULT_EXCLUSIVE)
-+ if ((kind & SUBARRAY_LOW_BOUND) == SUBARRAY_LOW_BOUND)
- low = evaluate_subexp (nullptr, exp, pos, noside);
-- if (kind == LOW_BOUND_DEFAULT || kind == LOW_BOUND_DEFAULT_EXCLUSIVE
-- || kind == NONE_BOUND_DEFAULT || kind == NONE_BOUND_DEFAULT_EXCLUSIVE)
-+ if ((kind & SUBARRAY_HIGH_BOUND) == SUBARRAY_HIGH_BOUND)
- high = evaluate_subexp (nullptr, exp, pos, noside);
-- bool inclusive = (kind == NONE_BOUND_DEFAULT || kind == LOW_BOUND_DEFAULT);
-+ bool inclusive = (!((kind & SUBARRAY_HIGH_BOUND_EXCLUSIVE) == SUBARRAY_HIGH_BOUND_EXCLUSIVE));
-
- if (noside == EVAL_SKIP)
- return value_from_longest (builtin_type (exp->gdbarch)->builtin_int, 1);
-@@ -1177,7 +1175,7 @@ rust_compute_range (struct type *type, struct value *range,
-
- *low = 0;
- *high = 0;
-- *kind = BOTH_BOUND_DEFAULT;
-+ *kind = SUBARRAY_NONE_BOUND;
-
- if (type->num_fields () == 0)
- return;
-@@ -1185,15 +1183,14 @@ rust_compute_range (struct type *type, struct value *range,
- i = 0;
- if (strcmp (TYPE_FIELD_NAME (type, 0), "start") == 0)
- {
-- *kind = HIGH_BOUND_DEFAULT;
-+ *kind = SUBARRAY_LOW_BOUND;
- *low = value_as_long (value_field (range, 0));
- ++i;
- }
- if (type->num_fields () > i
- && strcmp (TYPE_FIELD_NAME (type, i), "end") == 0)
- {
-- *kind = (*kind == BOTH_BOUND_DEFAULT
-- ? LOW_BOUND_DEFAULT : NONE_BOUND_DEFAULT);
-+ *kind = (range_type) (*kind | SUBARRAY_HIGH_BOUND);
- *high = value_as_long (value_field (range, i));
-
- if (rust_inclusive_range_type_p (type))
-@@ -1211,7 +1208,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
- struct type *rhstype;
- LONGEST low, high_bound;
- /* Initialized to appease the compiler. */
-- enum range_type kind = BOTH_BOUND_DEFAULT;
-+ enum range_type kind = SUBARRAY_NONE_BOUND;
- LONGEST high = 0;
- int want_slice = 0;
-
-@@ -1309,7 +1306,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
- error (_("Cannot subscript non-array type"));
-
- if (want_slice
-- && (kind == BOTH_BOUND_DEFAULT || kind == LOW_BOUND_DEFAULT))
-+ && ((kind & SUBARRAY_LOW_BOUND) != SUBARRAY_LOW_BOUND))
- low = low_bound;
- if (low < 0)
- error (_("Index less than zero"));
-@@ -1327,7 +1324,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
- CORE_ADDR addr;
- struct value *addrval, *tem;
-
-- if (kind == BOTH_BOUND_DEFAULT || kind == HIGH_BOUND_DEFAULT)
-+ if ((kind & SUBARRAY_HIGH_BOUND) != SUBARRAY_HIGH_BOUND)
- high = high_bound;
- if (high < 0)
- error (_("High index less than zero"));
-diff --git a/gdb/testsuite/gdb.fortran/static-arrays.exp b/gdb/testsuite/gdb.fortran/static-arrays.exp
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.fortran/static-arrays.exp
-@@ -0,0 +1,421 @@
-+# Copyright 2015 Free Software Foundation, Inc.
-+#
-+# Contributed by Intel Corp. <christoph.t.weinmann@intel.com>
-+#
-+# 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/>.
-+
-+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
---- /dev/null
-+++ b/gdb/testsuite/gdb.fortran/static-arrays.f90
-@@ -0,0 +1,55 @@
-+! Copyright 2015 Free Software Foundation, Inc.
-+!
-+! Contributed by Intel Corp. <christoph.t.weinmann@intel.com>
-+!
-+! 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/>.
-+
-+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
-diff --git a/gdb/testsuite/gdb.fortran/vla-sizeof.exp b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
---- a/gdb/testsuite/gdb.fortran/vla-sizeof.exp
-+++ b/gdb/testsuite/gdb.fortran/vla-sizeof.exp
-@@ -35,7 +35,8 @@ gdb_test "print sizeof(vla1)" " = 0" "print sizeof non-allocated vla1"
- gdb_test "print sizeof(vla1(3,2,1))" \
- "no such vector element \\(vector not allocated\\)" \
- "print sizeof non-allocated indexed vla1"
--gdb_test "print sizeof(vla1(3:4,2,1))" "array not allocated" \
-+gdb_test "print sizeof(vla1(3:4,2,1))" \
-+ "provided bound\\(s\\) outside array bound\\(s\\)" \
- "print sizeof non-allocated sliced vla1"
-
- # Try to access value in allocated VLA
-@@ -44,7 +45,7 @@ gdb_continue_to_breakpoint "vla1-allocated"
- gdb_test "print sizeof(vla1)" " = 4000" "print sizeof allocated vla1"
- gdb_test "print sizeof(vla1(3,2,1))" "4" \
- "print sizeof element from allocated vla1"
--gdb_test "print sizeof(vla1(3:4,2,1))" "800" \
-+gdb_test "print sizeof(vla1(3:4,2,1))" "8" \
- "print sizeof sliced vla1"
-
- # Try to access values in undefined pointer to VLA (dangling)
-@@ -52,7 +53,8 @@ gdb_test "print sizeof(pvla)" " = 0" "print sizeof non-associated pvla"
- gdb_test "print sizeof(pvla(3,2,1))" \
- "no such vector element \\(vector not associated\\)" \
- "print sizeof non-associated indexed pvla"
--gdb_test "print sizeof(pvla(3:4,2,1))" "array not associated" \
-+gdb_test "print sizeof(pvla(3:4,2,1))" \
-+ "provided bound\\(s\\) outside array bound\\(s\\)" \
- "print sizeof non-associated sliced pvla"
-
- # Try to access values in pointer to VLA and compare them
-@@ -61,7 +63,8 @@ gdb_continue_to_breakpoint "pvla-associated"
- gdb_test "print sizeof(pvla)" " = 4000" "print sizeof associated pvla"
- gdb_test "print sizeof(pvla(3,2,1))" "4" \
- "print sizeof element from associated pvla"
--gdb_test "print sizeof(pvla(3:4,2,1))" "800" "print sizeof sliced pvla"
-+
-+gdb_test "print sizeof(pvla(3:4,2,1))" "8" "print sizeof sliced pvla"
-
- gdb_breakpoint [gdb_get_line_number "vla1-neg-bounds-v1"]
- gdb_continue_to_breakpoint "vla1-neg-bounds-v1"
-diff --git a/gdb/testsuite/gdb.fortran/vla-stride.exp b/gdb/testsuite/gdb.fortran/vla-stride.exp
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.fortran/vla-stride.exp
-@@ -0,0 +1,47 @@
-+# Copyright 2016 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/>.
-+
-+standard_testfile ".f90"
-+
-+if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} \
-+ {debug f90 quiet}] } {
-+ return -1
-+}
-+
-+if ![runto MAIN__] then {
-+ perror "couldn't run to breakpoint MAIN__"
-+ continue
-+}
-+
-+gdb_test_no_output "set max-value-size unlimited" \
-+ "set max-value-size to unlimited"
-+
-+gdb_breakpoint [gdb_get_line_number "re-reverse-elements"]
-+gdb_continue_to_breakpoint "re-reverse-elements"
-+gdb_test "print pvla" " = \\\(1, 2, 3, 4, 5, 6, 7, 8, 9, 10\\\)" \
-+ "print re-reverse-elements"
-+gdb_test "print pvla(1)" " = 1" "print first re-reverse-element"
-+gdb_test "print pvla(10)" " = 10" "print last re-reverse-element"
-+
-+gdb_breakpoint [gdb_get_line_number "odd-elements"]
-+gdb_continue_to_breakpoint "odd-elements"
-+gdb_test "print pvla" " = \\\(1, 3, 5, 7, 9\\\)" "print odd-elements"
-+gdb_test "print pvla(1)" " = 1" "print first odd-element"
-+gdb_test "print pvla(5)" " = 9" "print last odd-element"
-+
-+gdb_breakpoint [gdb_get_line_number "single-element"]
-+gdb_continue_to_breakpoint "single-element"
-+gdb_test "print pvla" " = \\\(5\\\)" "print single-element"
-+gdb_test "print pvla(1)" " = 5" "print one single-element"
-diff --git a/gdb/testsuite/gdb.fortran/vla-stride.f90 b/gdb/testsuite/gdb.fortran/vla-stride.f90
-new file mode 100644
---- /dev/null
-+++ b/gdb/testsuite/gdb.fortran/vla-stride.f90
-@@ -0,0 +1,29 @@
-+! Copyright 2016 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/>.
-+
-+program vla_stride
-+ integer, target, allocatable :: vla (:)
-+ integer, pointer :: pvla (:)
-+
-+ allocate(vla(10))
-+ vla = (/ (I, I = 1,10) /)
-+
-+ pvla => vla(10:1:-1)
-+ pvla => pvla(10:1:-1)
-+ pvla => vla(1:10:2) ! re-reverse-elements
-+ pvla => vla(5:4:-2) ! odd-elements
-+
-+ pvla => null() ! single-element
-+end program vla_stride
-diff --git a/gdb/valops.c b/gdb/valops.c
---- a/gdb/valops.c
-+++ b/gdb/valops.c
-@@ -3756,13 +3756,42 @@ value_of_this_silent (const struct language_defn *lang)
-
- struct value *
- value_slice (struct value *array, int lowbound, int length)
-+{
-+ /* Pass unaltered arguments to VALUE_SLICE_1, plus a default stride
-+ value of '1', which returns every element between LOWBOUND and
-+ (LOWBOUND + LENGTH). We also provide a default CALL_COUNT of '1'
-+ as we are only considering the highest dimension, or we are
-+ working on a one dimensional array. So we call VALUE_SLICE_1
-+ exactly once. */
-+ return value_slice_1 (array, lowbound, length, 1, 1);
-+}
-+
-+/* VALUE_SLICE_1 is called for each array dimension to calculate the number
-+ of elements as defined by the subscript expression.
-+ CALL_COUNT is used to determine if we are calling the function once, e.g.
-+ we are working on the current dimension of ARRAY, or if we are calling
-+ the function repeatedly. In the later case we need to take elements
-+ from the TARGET_TYPE of ARRAY.
-+ With a CALL_COUNT greater than 1 we calculate the offsets for every element
-+ that should be in the result array. Then we fetch the contents and then
-+ copy them into the result array. The result array will have one dimension
-+ less than the input array, so later on we need to recreate the indices and
-+ ranges in the calling function. */
-+
-+struct value *
-+value_slice_1 (struct value *array, int lowbound, int length,
-+ int stride_length, int call_count)
- {
- struct type *slice_range_type, *slice_type, *range_type;
-- LONGEST lowerbound, upperbound;
-- struct value *slice;
-- struct type *array_type;
-+ struct type *array_type = check_typedef (value_type (array));
-+ struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (array_type));
-+ unsigned int elt_size, elt_offs;
-+ LONGEST ary_high_bound, ary_low_bound;
-+ struct value *v;
-+ int slice_range_size, i = 0, row_count = 1, elem_count = 1;
-
-- array_type = check_typedef (value_type (array));
-+ /* Check for legacy code if we are actually dealing with an array or
-+ string. */
- if (array_type->code () != TYPE_CODE_ARRAY
- && array_type->code () != TYPE_CODE_STRING)
- error (_("cannot take slice of non-array"));
-@@ -3772,45 +3801,155 @@ value_slice (struct value *array, int lowbound, int length)
- if (type_not_associated (array_type))
- error (_("array not associated"));
-
-- range_type = array_type->index_type ();
-- if (!get_discrete_bounds (range_type, &lowerbound, &upperbound))
-- error (_("slice from bad array or bitstring"));
-+ ary_low_bound = array_type->index_type ()->bounds ()->low.const_val ();
-+ ary_high_bound = array_type->index_type ()->bounds ()->high.const_val ();
-+
-+ /* When we are working on a multi-dimensional array, we need to get the
-+ attributes of the underlying type. */
-+ if (call_count > 1)
-+ {
-+ ary_low_bound = elt_type->index_type ()->bounds ()->low.const_val ();
-+ ary_high_bound = elt_type->index_type ()->bounds ()->high.const_val ();
-+ elt_type = check_typedef (TYPE_TARGET_TYPE (elt_type));
-+ row_count = TYPE_LENGTH (array_type)
-+ / TYPE_LENGTH (TYPE_TARGET_TYPE (array_type));
-+ }
-+
-+ /* With a stride of '1', the number of elements per result row is equal to
-+ the LENGTH of the subarray. With non-default stride values, we skip
-+ elements, but have to add the start element to the total number of
-+ elements per row. */
-+ if (stride_length == 1)
-+ elem_count = length;
-+ else
-+ elem_count = ((length - 1) / stride_length) + 1;
-+
-+ elt_size = TYPE_LENGTH (elt_type);
-+ elt_offs = lowbound - ary_low_bound;
-+
-+ elt_offs *= elt_size;
-
-- if (lowbound < lowerbound || length < 0
-- || lowbound + length - 1 > upperbound)
-- error (_("slice out of range"));
-+ /* Check for valid user input. In case of Fortran this was already done
-+ in the calling function. */
-+ if (call_count == 1
-+ && (!TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (array_type)
-+ && elt_offs >= TYPE_LENGTH (array_type)))
-+ error (_("no such vector element"));
-+
-+ /* CALL_COUNT is 1 when we are dealing either with the highest dimension
-+ of the array, or a one dimensional array. Set RANGE_TYPE accordingly.
-+ In both cases we calculate how many rows/elements will be in the output
-+ array by setting slice_range_size. */
-+ if (call_count == 1)
-+ {
-+ range_type = array_type->index_type ();
-+ slice_range_size = ary_low_bound + elem_count - 1;
-+
-+ /* Check if the array bounds are valid. */
-+ if (get_discrete_bounds (range_type, &ary_low_bound, &ary_high_bound) < 0)
-+ error (_("slice from bad array or bitstring"));
-+ }
-+ /* When CALL_COUNT is greater than 1, we are dealing with an array of arrays.
-+ So we need to get the type below the current one and set the RANGE_TYPE
-+ accordingly. */
-+ else
-+ {
-+ range_type = TYPE_TARGET_TYPE (array_type)->index_type ();
-+ slice_range_size = ary_low_bound + (row_count * elem_count) - 1;
-+ ary_low_bound = range_type->bounds ()->low.const_val ();
-+ }
-
- /* FIXME-type-allocation: need a way to free this type when we are
-- done with it. */
-- slice_range_type = create_static_range_type (NULL,
-- TYPE_TARGET_TYPE (range_type),
-- lowbound,
-- lowbound + length - 1);
-+ done with it. */
-
-+ slice_range_type = create_static_range_type (NULL, TYPE_TARGET_TYPE (range_type),
-+ ary_low_bound, slice_range_size);
- {
-- struct type *element_type = TYPE_TARGET_TYPE (array_type);
-- LONGEST offset
-- = (lowbound - lowerbound) * TYPE_LENGTH (check_typedef (element_type));
-+ struct type *element_type;
-
-- slice_type = create_array_type (NULL,
-- element_type,
-- slice_range_type);
-- slice_type->set_code (array_type->code ());
-+ /* When both CALL_COUNT and STRIDE_LENGTH equal 1, we can use the legacy
-+ code for subarrays. */
-+ if (call_count == 1 && stride_length == 1)
-+ {
-+ element_type = TYPE_TARGET_TYPE (array_type);
-+
-+ slice_type = create_array_type (NULL, element_type, slice_range_type);
-+
-+ slice_type->set_code (array_type->code ());
-
-- if (VALUE_LVAL (array) == lval_memory && value_lazy (array))
-- slice = allocate_value_lazy (slice_type);
-+ if (VALUE_LVAL (array) == lval_memory && value_lazy (array))
-+ v = allocate_value_lazy (slice_type);
-+ else
-+ {
-+ v = allocate_value (slice_type);
-+ value_contents_copy (v,
-+ value_embedded_offset (v),
-+ array,
-+ value_embedded_offset (array) + elt_offs,
-+ elt_size * longest_to_int (length));
-+ }
-+
-+ }
-+ /* With a CALL_COUNT or STRIDE_LENGTH are greater than 1 we are working
-+ on a range of ranges. So we copy the relevant elements into the
-+ new array we return. */
- else
- {
-- slice = allocate_value (slice_type);
-- value_contents_copy (slice, 0, array, offset,
-- type_length_units (slice_type));
-+ int j, offs_store = elt_offs;
-+ LONGEST dst_offset = 0;
-+ LONGEST src_row_length = TYPE_LENGTH (TYPE_TARGET_TYPE (array_type));
-+
-+ if (call_count == 1)
-+ {
-+ /* When CALL_COUNT is equal to 1 we are working on the current range
-+ and use these elements directly. */
-+ element_type = TYPE_TARGET_TYPE (array_type);
-+ }
-+ else
-+ {
-+ /* Working on an array of arrays, the type of the elements is the type
-+ of the subarrays' type. */
-+ element_type = TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (array_type));
-+ }
-+
-+ slice_type = create_array_type (NULL, element_type, slice_range_type);
-+
-+ /* If we have a one dimensional array, we copy its type code. For a
-+ multi dimensional array we copy the embedded type's type code. */
-+ if (call_count == 1)
-+ slice_type->set_code (array_type->code ());
-+ else
-+ slice_type->set_code ((TYPE_TARGET_TYPE (array_type)->code ()));
-+
-+ v = allocate_value (slice_type);
-+
-+ /* Iterate through the rows of the outer array and set the new offset
-+ for each row. */
-+ for (i = 0; i < row_count; i++)
-+ {
-+ elt_offs = offs_store + i * src_row_length;
-+
-+ /* Iterate through the elements in each row to copy only those. */
-+ for (j = 1; j <= elem_count; j++)
-+ {
-+ /* Fetches the contents of ARRAY and copies them into V. */
-+ value_contents_copy (v, dst_offset, array, elt_offs, elt_size);
-+ elt_offs += elt_size * stride_length;
-+ dst_offset += elt_size;
-+ }
-+ }
- }
-
-- set_value_component_location (slice, array);
-- set_value_offset (slice, value_offset (array) + offset);
-+ set_value_component_location (v, array);
-+ if (VALUE_LVAL (v) == lval_register)
-+ {
-+ VALUE_REGNUM (v) = VALUE_REGNUM (array);
-+ VALUE_NEXT_FRAME_ID (v) = VALUE_NEXT_FRAME_ID (array);
-+ }
-+ set_value_offset (v, value_offset (array) + elt_offs);
- }
-
-- return slice;
-+ return v;
- }
-
- /* See value.h. */
-diff --git a/gdb/value.h b/gdb/value.h
---- a/gdb/value.h
-+++ b/gdb/value.h
-@@ -1144,6 +1144,8 @@ extern struct value *varying_to_slice (struct value *);
-
- extern struct value *value_slice (struct value *, int, int);
-
-+extern struct value *value_slice_1 (struct value *, int, int, int, int);
-+
- /* Create a complex number. The type is the complex type; the values
- are cast to the underlying scalar type before the complex number is
- created. */