public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Bruno Larsen <blarsen@redhat.com>
To: gdb-patches@sourceware.org
Cc: Bruno Larsen <blarsen@redhat.com>
Subject: [PATCH] gdb/testsuite: Fix FAILs in gdb.linespec/cpcompletion.exp when using clang
Date: Thu,  5 Jan 2023 08:57:05 +0100	[thread overview]
Message-ID: <20230105075705.2271636-1-blarsen@redhat.com> (raw)

When using clang 16.0.0 to test gdb.linespec/cpcompletion.exp, I get 99
unexpected failures.  They all fail to produce a complete list of
completion options for a function, either overload2_function,
overload3_function or anon_ns_function.  This happens because clang is
optimizing them away, since they are never used.

Fix this by adding __attribute__((used)) to all declarations to the
aforementioned functions.
---
 gdb/testsuite/gdb.linespec/cpls.cc | 33 ++++++++++++++++--------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/gdb/testsuite/gdb.linespec/cpls.cc b/gdb/testsuite/gdb.linespec/cpls.cc
index 037b5c28325..d63ed892564 100644
--- a/gdb/testsuite/gdb.linespec/cpls.cc
+++ b/gdb/testsuite/gdb.linespec/cpls.cc
@@ -56,16 +56,17 @@ struct overload2_arg9 {};
 struct overload2_arga {};
 
 #define GEN_OVERLOAD2_FUNCTIONS(ARG1, ARG2)		\
-  void							\
+  void __attribute__ ((used))				\
   overload2_function (ARG1)				\
   {}							\
 							\
   struct struct_overload2_test				\
   {							\
-    void overload2_function (ARG2);			\
+    void __attribute__ ((used))				\
+      overload2_function (ARG2);			\
   };							\
 							\
-  void							\
+  void __attribute__ ((used))				\
   struct_overload2_test::overload2_function (ARG2)	\
   {}
 
@@ -99,23 +100,25 @@ namespace ns_overload2_test
 /* Code for the overload-3 test.  */
 
 #define GEN_OVERLOAD3_FUNCTIONS(ARG1, ARG2)		\
-  void							\
+  void __attribute__ ((used))				\
   overload3_function (ARG1)				\
   {}							\
-  void							\
+  void __attribute__ ((used))				\
   overload3_function (ARG2)				\
   {}							\
 							\
   struct struct_overload3_test				\
   {							\
-    void overload3_function (ARG1);			\
-    void overload3_function (ARG2);			\
+    void __attribute__ ((used))				\
+      overload3_function (ARG1);			\
+    void __attribute__ ((used))				\
+      overload3_function (ARG2);			\
   };							\
 							\
-  void							\
+  void __attribute__ ((used))				\
   struct_overload3_test::overload3_function (ARG1)	\
   {}							\
-  void							\
+  void __attribute__ ((used))				\
   struct_overload3_test::overload3_function (ARG2)	\
   {}
 
@@ -343,15 +346,15 @@ namespace ns2_incomplete_scope_colon_test
 
 namespace
 {
-  void anon_ns_function ()
+  void __attribute__ ((used)) anon_ns_function ()
   {}
 
   struct anon_ns_struct
   {
-    void anon_ns_function ();
+    void __attribute__ ((used)) anon_ns_function ();
   };
 
-  void
+  void __attribute__ ((used))
   anon_ns_struct::anon_ns_function ()
   {}
 }
@@ -361,15 +364,15 @@ namespace the_anon_ns_wrapper_ns
 
 namespace
 {
-  void anon_ns_function ()
+  void __attribute__ ((used)) anon_ns_function ()
   {}
 
   struct anon_ns_struct
   {
-    void anon_ns_function ();
+    void __attribute__ ((used)) anon_ns_function ();
   };
 
-  void
+  void __attribute__ ((used))
   anon_ns_struct::anon_ns_function ()
   {}
 }
-- 
2.39.0


             reply	other threads:[~2023-01-05  7:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-05  7:57 Bruno Larsen [this message]
2023-01-05 20:06 ` Tom Tromey
2023-01-06  9:51   ` Bruno Larsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230105075705.2271636-1-blarsen@redhat.com \
    --to=blarsen@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).