From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id E8E7B3858D35 for ; Thu, 5 Jan 2023 07:57:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E8E7B3858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672905434; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=MRGFj16c1kJ59m/KXFi2edtPH4D1+DugKvVNycOBHrc=; b=AYSCHEj93p0UqOvi0JzvOY7262vcHi3sxroelVPselHAPbuV/5FDDh0YdWOmLSFkkmBtJZ rw/CGgE2gFlQoi8389op9TvCOvj6ddkCU6V5pxXyxkT1K8mqhP8bSOn14lxd9gEtWu8uAy SUuOzZGxz2DyEzYAqtnB2QZDUiXdkqY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-288-vKnc1GTwOgmBNLZGnTJXow-1; Thu, 05 Jan 2023 02:57:13 -0500 X-MC-Unique: vKnc1GTwOgmBNLZGnTJXow-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3AD6480234E for ; Thu, 5 Jan 2023 07:57:13 +0000 (UTC) Received: from fedora.redhat.com (ovpn-192-134.brq.redhat.com [10.40.192.134]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ADE1F492B07; Thu, 5 Jan 2023 07:57:12 +0000 (UTC) From: Bruno Larsen To: gdb-patches@sourceware.org Cc: Bruno Larsen Subject: [PATCH] gdb/testsuite: Fix FAILs in gdb.linespec/cpcompletion.exp when using clang Date: Thu, 5 Jan 2023 08:57:05 +0100 Message-Id: <20230105075705.2271636-1-blarsen@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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