Fix crash in Fortran code
authorTom Tromey <tom@tromey.com>
Thu, 24 Feb 2022 16:01:42 +0000 (09:01 -0700)
committerTom Tromey <tom@tromey.com>
Thu, 24 Feb 2022 21:38:08 +0000 (14:38 -0700)
commit4c937052c13b13053559a5aa2b1345545a185ca5
treeda1c7680fef3345636fffc45b22592a59150f0f4
parent7124770976d3f051532faf864013b76ab36249bf
Fix crash in Fortran code

PR fortran/28801 points out a gdb crash that can be provoked by
certain Fortran code.  The bug is that f77_get_upperbound assumes the
property is either a constant or undefined, but in this case it is
PROP_LOCEXPR.

This patch fixes the crash by making this function (and the
lower-bound one as well) do the correct check before calling
'const_val'.

Thanks to Andrew for writing the test case.

Co-authored-by: Andrew Burgess <aburgess@redhat.com>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28801
gdb/f-valprint.c
gdb/testsuite/gdb.dwarf2/fortran-var-string.c [new file with mode: 0644]
gdb/testsuite/gdb.dwarf2/fortran-var-string.exp [new file with mode: 0644]