From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7862) id 46DF43858D28; Fri, 6 Jan 2023 09:51:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 46DF43858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1672998673; bh=ZAKqPIRYQyMLQu9mntsjE7ROI+7rzkHzfSsODKl4MiA=; h=From:To:Subject:Date:From; b=ZCUfsvdmSIuxzgZTRxwg0Of/Ieqi9tP+vfSvX2A8HDmvRyGJih4vRgAaWEfjtkskz lvH/SH7xBU68xtaQBLANozDrfIp6TnlGAWdopGFqW2b1LZeQjvEsMcAX97J01gSWbF ain8gw/vrb/ci6AqmXi86FmQF4dPTXd4KK99NrzU= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Bruno Larsen To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/testsuite: Fix FAILs in gdb.linespec/cpcompletion.exp when using clang X-Act-Checkin: binutils-gdb X-Git-Author: Bruno Larsen X-Git-Refname: refs/heads/master X-Git-Oldrev: 5fb0e308577143ceb313fde5538dc9ecb038f29f X-Git-Newrev: 695e9773786d79f191e9487a88d3b39a57d9c7e7 Message-Id: <20230106095113.46DF43858D28@sourceware.org> Date: Fri, 6 Jan 2023 09:51:13 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D695e9773786d= 79f191e9487a88d3b39a57d9c7e7 commit 695e9773786d79f191e9487a88d3b39a57d9c7e7 Author: Bruno Larsen Date: Tue Jan 3 15:07:47 2023 +0100 gdb/testsuite: Fix FAILs in gdb.linespec/cpcompletion.exp when using cl= ang =20 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. =20 Fix this by adding __attribute__((used)) to all declarations to the aforementioned functions. Diff: --- 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.linespe= c/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 {}; =20 #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) \ {} =20 @@ -99,23 +100,25 @@ namespace ns_overload2_test /* Code for the overload-3 test. */ =20 #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) \ {} =20 @@ -343,15 +346,15 @@ namespace ns2_incomplete_scope_colon_test =20 namespace { - void anon_ns_function () + void __attribute__ ((used)) anon_ns_function () {} =20 struct anon_ns_struct { - void anon_ns_function (); + void __attribute__ ((used)) anon_ns_function (); }; =20 - void + void __attribute__ ((used)) anon_ns_struct::anon_ns_function () {} } @@ -361,15 +364,15 @@ namespace the_anon_ns_wrapper_ns =20 namespace { - void anon_ns_function () + void __attribute__ ((used)) anon_ns_function () {} =20 struct anon_ns_struct { - void anon_ns_function (); + void __attribute__ ((used)) anon_ns_function (); }; =20 - void + void __attribute__ ((used)) anon_ns_struct::anon_ns_function () {} }