[PATCH] Fix gdb.base/list.exp with Clang

Gary Benson gbenson@redhat.com
Mon Oct 5 13:44:20 GMT 2020


Hi all,

Two subtests of gdb.base/list.exp failed when built with Clang
because the unused function "unused" was optimized out.  This
commit adds __attribute__ ((used)) to both definitions.

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

Cheers,
Gary

---
gdb/testsuite/ChangeLog:

	* gdb.base/list0.c (unused): Add __attribute__ ((used)).
	* gdb.base/list1.c (unused): Likewise.
---
 gdb/testsuite/ChangeLog        | 5 +++++
 gdb/testsuite/gdb.base/list0.c | 2 +-
 gdb/testsuite/gdb.base/list1.c | 2 +-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/gdb.base/list0.c b/gdb/testsuite/gdb.base/list0.c
index 0255cf3..1e5b7c1 100644
--- a/gdb/testsuite/gdb.base/list0.c
+++ b/gdb/testsuite/gdb.base/list0.c
@@ -36,7 +36,7 @@ int main ()
     return 0;
 }
 
-static void
+static void __attribute__ ((used))
 unused ()
 {
     /* Not used for anything */
diff --git a/gdb/testsuite/gdb.base/list1.c b/gdb/testsuite/gdb.base/list1.c
index a9f614f..d694495 100644
--- a/gdb/testsuite/gdb.base/list1.c
+++ b/gdb/testsuite/gdb.base/list1.c
@@ -12,7 +12,7 @@ void bar (int x)
     long_line ();
 }
 
-static void
+static void __attribute__ ((used))
 unused ()
 {
     /* Not used for anything */
-- 
1.8.3.1



More information about the Gdb-patches mailing list