From 8caf140db24116e8874099291a7a48644c368ab6 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Sat, 2 May 2020 09:50:50 +0200 Subject: [PATCH] [gdb/testsuite] Update psym-external-decl.exp for gcc-10/clang When running test-case gdb.base/psym-external-decl.exp with gcc-10, we have: ... (gdb) print aaa^M 'aaa' has unknown type; cast it to its declared type^M (gdb) FAIL: gdb.base/psym-external-decl.exp: print aaa ... With an an earlier version, gcc still emits the debug info for the declaration of aaa: ... <0>: Abbrev Number: 1 (DW_TAG_compile_unit) DW_AT_name : psym-external-decl.c <1>: Abbrev Number: 2 (DW_TAG_variable) DW_AT_name : aaa DW_AT_external : 1 DW_AT_declaration : 1 ... but with gcc-10 that's no longer the case. Fix the test-case by adding a use of aaa in psym-external-decl.c. That still doesn't work for clang, so skip test in that case. Tested with x86_64-linux, with gcc 7.5.0, gcc 10.0.0 and clang 5.0.2. Also tested by reverting corresponding fix and ensuring test-case still fails. gdb/testsuite/ChangeLog: 2020-05-02 Tom de Vries * gdb.base/psym-external-decl.c (main): Add use of variable aaa. --- gdb/testsuite/ChangeLog | 4 ++++ gdb/testsuite/gdb.base/psym-external-decl.c | 2 +- gdb/testsuite/gdb.base/psym-external-decl.exp | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 737caffa0ea..e741fd6a7d8 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2020-05-02 Tom de Vries + + * gdb.base/psym-external-decl.c (main): Add use of variable aaa. + 2020-05-01 Tom de Vries * gdb.ada/operator_bp.exp: Allow more than required amount of diff --git a/gdb/testsuite/gdb.base/psym-external-decl.c b/gdb/testsuite/gdb.base/psym-external-decl.c index 7a4b1077741..e2374327bde 100644 --- a/gdb/testsuite/gdb.base/psym-external-decl.c +++ b/gdb/testsuite/gdb.base/psym-external-decl.c @@ -20,6 +20,6 @@ extern int aaa; int main (void) { - return 0; + return aaa; } diff --git a/gdb/testsuite/gdb.base/psym-external-decl.exp b/gdb/testsuite/gdb.base/psym-external-decl.exp index bbcc2745755..d0388d5655e 100644 --- a/gdb/testsuite/gdb.base/psym-external-decl.exp +++ b/gdb/testsuite/gdb.base/psym-external-decl.exp @@ -15,6 +15,11 @@ standard_testfile .c psym-external-decl-2.c +get_compiler_info +if { [test_compiler_info "clang-*"] } { + return -1 +} + set srcfiles [list $srcfile $srcfile2] if { [build_executable_from_specs \ -- 2.30.2