diff --git a/gdb/f-lang.h b/gdb/f-lang.h
index d20a46f..46ea267 100644
--- a/gdb/f-lang.h
+++ b/gdb/f-lang.h
@@ -96,9 +96,9 @@ extern SAVED_F77_COMMON_PTR find_common_for_function (const char *,
extern char *real_main_name; /* Name of main function. */
extern int real_main_c_value; /* C_value field of main function. */
-extern int f77_get_upperbound (struct type *);
+extern LONGEST f77_get_upperbound (struct type *);
-extern int f77_get_lowerbound (struct type *);
+extern LONGEST f77_get_lowerbound (struct type *);
extern void f77_get_dynamic_array_length (struct type *);
diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
index c59e639..f6877fa 100644
--- a/gdb/f-typeprint.c
+++ b/gdb/f-typeprint.c
@@ -150,7 +150,7 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
int show, int passed_a_ptr, int demangled_args,
int arrayprint_recurse_level)
{
- int upper_bound, lower_bound;
+ LONGEST upper_bound, lower_bound;
/* No static variables are permitted as an error call may occur during
execution of this function. */
@@ -177,7 +177,7 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
lower_bound = f77_get_lowerbound (type);
if (lower_bound != 1) /* Not the default. */
- fprintf_filtered (stream, "%d:", lower_bound);
+ fprintf_filtered (stream, "%s:", plongest (lower_bound));
/* Make sure that, if we have an assumed size array, we
print out a warning and print the upperbound as '*'. */
@@ -187,7 +187,7 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
else
{
upper_bound = f77_get_upperbound (type);
- fprintf_filtered (stream, "%d", upper_bound);
+ fprintf_filtered (stream, "%s", plongest (upper_bound));
}
if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_ARRAY)
@@ -255,7 +255,7 @@ void
f_type_print_base (struct type *type, struct ui_file *stream, int show,
int level)
{
- int upper_bound;
+ LONGEST upper_bound;
int index;
QUIT;
@@ -337,7 +337,7 @@ f_type_print_base (struct type *type, struct ui_file *stream, int show,
else
{
upper_bound = f77_get_upperbound (type);
- fprintf_filtered (stream, "character*%d", upper_bound);
+ fprintf_filtered (stream, "character*%s", plongest (upper_bound));
}
break;
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index a422ac2..b4ce356 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -60,7 +60,7 @@ LONGEST f77_array_offset_tbl[MAX_FORTRAN_DIMS + 1][2];
#define F77_DIM_OFFSET(n) (f77_array_offset_tbl[n][0])
-int
+LONGEST
f77_get_lowerbound (struct type *type)
{
if (TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED (type))
@@ -69,7 +69,7 @@ f77_get_lowerbound (struct type *type)
return TYPE_ARRAY_LOWER_BOUND_VALUE (type);
}
-int
+LONGEST
f77_get_upperbound (struct type *type)
{
if (TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
@@ -90,8 +90,8 @@ f77_get_upperbound (struct type *type)
static void
f77_get_dynamic_length_of_aggregate (struct type *type)
{
- int upper_bound = -1;
- int lower_bound = 1;
+ LONGEST upper_bound = -1;
+ LONGEST lower_bound = 1;
/* Recursively go all the way down into a possibly multi-dimensional
F77 array and get the bounds. For simple arrays, this is pretty
@@ -126,7 +126,7 @@ f77_create_arrayprint_offset_tbl (struct type *type, struct ui_file *stream)
struct type *tmp_type;
LONGEST eltlen;
int ndimen = 1;
- int upper, lower;
+ LONGEST upper, lower;
tmp_type = type;
diff --git a/gdb/testsuite/gdb.fortran/array-bounds.exp b/gdb/testsuite/gdb.fortran/array-bounds.exp
new file mode 100644
index 0000000..68873fe
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/array-bounds.exp
@@ -0,0 +1,35 @@
+# 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 .
+
+# This file is part of the gdb testsuite. It contains test to ensure that
+# array bounds accept LONGEST.
+
+if { [skip_fortran_tests] } { return -1 }
+
+standard_testfile .f
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug additional_flags=-fno-range-check f90}]} {
+ print "compile failed"
+ return -1
+}
+
+if { ![runto MAIN__] } {
+ perror "Could not run to breakpoint `MAIN__'."
+ continue
+}
+
+gdb_test "print &foo" {.*\(4294967296:4294967297\).*}
+gdb_test "print &bar" {.*\(-4294967297:-4294967296\).*}
+
diff --git a/gdb/testsuite/gdb.fortran/array-bounds.f b/gdb/testsuite/gdb.fortran/array-bounds.f
new file mode 100644
index 0000000..a43184c
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/array-bounds.f
@@ -0,0 +1,21 @@
+c Copyright 2012 Free Software Foundation, Inc.
+
+c This program is free software; you can redistribute it and/or modify
+c it under the terms of the GNU General Public License as published by
+c the Free Software Foundation; either version 3 of the License, or
+c (at your option) any later version.
+c
+c This program is distributed in the hope that it will be useful,
+c but WITHOUT ANY WARRANTY; without even the implied warranty of
+c MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+c GNU General Public License for more details.
+c
+c You should have received a copy of the GNU General Public License
+c along with this program. If not, see .
+
+ dimension foo(4294967296:4294967297)
+ dimension bar(-4294967297:-4294967296)
+ foo=bar
+ stop
+ end
+