[PATCH] KFAIL variable-length array tests which fail with Clang

Gary Benson via Gdb-patches
2020-11-16T17:17:47Z

Hi all,

Clang describes the upper bounds of variable length arrays using
a DW_AT_count attribute which references the DIE of a synthetic
variable whose value is specified using a DW_AT_location. In
some cases GDB correctly handles these, but in other cases GDB
adds an extra dereference causing the test to fail. This commit
marks these failing tests as caused by PR gdb/26905 when the
test executable was built using Clang.

Checked on Fedora 32 x86_64, with GCC and Clang. Ok to commit?

Thanks,
Gary

---
gdb/testsuite/ChangeLog:

PR gdb/26905
* gdb.base/vla-optimized-out.exp: Add KFAILs for PR gdb/26905.
* gdb.base/vla-ptr.exp: Likewise.
---
gdb/testsuite/ChangeLog | 6 ++++++
gdb/testsuite/gdb.base/vla-optimized-out.exp | 8 +++++++-
gdb/testsuite/gdb.base/vla-ptr.exp | 2 ++
3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.base/vla-optimized-out.exp b/gdb/testsuite/gdb.base/vla-optimized-out.exp
index 203a82d..aaa6cd5 100644
--- a/gdb/testsuite/gdb.base/vla-optimized-out.exp
+++ b/gdb/testsuite/gdb.base/vla-optimized-out.exp
@@ -16,6 +16,7 @@
# Check whether we can determine the size of an optimized-out vla.

standard_testfile
+set using_clang [test_compiler_info clang*]

# The EXE_SUFFIX is a string appended to the name of the test binary
# to make it unique per variation.
@@ -23,7 +24,7 @@ standard_testfile
# flags used for building the test binary, and the second item is a
# pattern which matches some expected output within this proc.
proc vla_optimized_out {exe_suffix options} {
- global testfile srcfile
+ global testfile srcfile using_clang

lassign $options compile_flags sizeof_result

@@ -37,10 +38,12 @@ proc vla_optimized_out {exe_suffix options} {
return
}

+ if {$using_clang} { setup_kfail "gdb/26905" *-*-* }
gdb_test "p a" \
" = <optimized out>" \
"printed optimized out vla"

+ if {$using_clang} { setup_kfail "gdb/26905" *-*-* }
gdb_test "p sizeof (a)" \
" = ($sizeof_result)" \
"printed size of optimized out vla"
@@ -55,14 +58,17 @@ proc vla_optimized_out {exe_suffix options} {
# been removed. As such GDB can't be expected to know if the
# array contains _any_ elements at all. It seems reasonable in
# that case to reply with 'no such vector element'.
+ if {$using_clang} { setup_kfail "gdb/26905" *-*-* }
gdb_test "p a\[0\]" \
"(= <optimized out>|no such vector element)" \
"print out of range element of vla (0)"

+ if {$using_clang} { setup_kfail "gdb/26905" *-*-* }
gdb_test "p a\[6\]" \
"no such vector element" \
"print out of range element of vla (6)"

+ if {$using_clang} { setup_kfail "gdb/26905" *-*-* }
gdb_test "p a\[0xffffffff\]" \
"no such vector element" \
"print out of range element of vla (0xffffffff)"
diff --git a/gdb/testsuite/gdb.base/vla-ptr.exp b/gdb/testsuite/gdb.base/vla-ptr.exp
index 346ff00..adf1779 100644
--- a/gdb/testsuite/gdb.base/vla-ptr.exp
+++ b/gdb/testsuite/gdb.base/vla-ptr.exp
@@ -14,6 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

standard_testfile
+set using_clang [test_compiler_info clang*]

if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
return -1
@@ -38,4 +39,5 @@ gdb_test "print *vla_ptr" " = 2" "print *vla_ptr (bar)"

gdb_breakpoint [gdb_get_line_number "vla_func_bp"]
gdb_continue_to_breakpoint "vla_func_bp"
+if {$using_clang} { setup_kfail "gdb/26905" *-*-* }
gdb_test "print td_vla" " = \\\{4, 5, 6, 7, 8\\\}"
--
1.8.3.1