From patchwork Tue Jan 23 20:36:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans-Peter Nilsson X-Patchwork-Id: 1889893 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=axis.com header.i=@axis.com header.a=rsa-sha256 header.s=selector1 header.b=F5wKa0pi; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TKJmL0vt6z23dy for ; Wed, 24 Jan 2024 07:37:04 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9428E3858C35 for ; Tue, 23 Jan 2024 20:37:01 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2061.outbound.protection.outlook.com [40.107.247.61]) by sourceware.org (Postfix) with ESMTPS id 758FB3858D3C for ; Tue, 23 Jan 2024 20:36:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 758FB3858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=axis.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=axis.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 758FB3858D3C Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.247.61 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1706042199; cv=pass; b=tnIn/G+Y7pFAeN0N77MEG5yel6DJHA4ZIKgZOND5fdPxnphMYonB3n7gSeBt9gf7fLVPN9j54rmOHQ8v3oV2EI61PSsUcB9gnIy3jVEf/W24ddFYZO1U4svXULOdSpPf8VSm10u4um/cdwBtqDSo85cVbBNMHqRB69mj+FjZYUE= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1706042199; c=relaxed/simple; bh=ACuP1tWj09A8joNJWdJ3FlTYYqFckH/1RC/A3/gGO48=; h=DKIM-Signature:From:To:Subject:MIME-Version:Message-ID:Date; b=VfGnFyrG5gwrx+q97d1ALSfzcWQLyrCyaVgBs8LAXKG2C6oJAFU59TGLTEWsnOZuiOkCaGGhCKyag2B0oaQzTarkAnUKPtw/TH7XfFYlMKkW2WaL0R2labjGa+RCAymgNl3UA0KU7Mtu19PTAwn5czUwAZUI1iNae2nldw/Zv3E= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ORp/h112gRrNJF84osZF77Y1pclPX16TNhCgFbgusTOARv0YTETQwceBL6m7W81nFNDNw7ToYqK2+odswEuf4MKNWtS9Bun775lz1m0CAETKadIrfpx5dcLmZnXohNMZKY59uW14oklnH8m/eIo5utqY8TUZ+pYjrbHpYrNRzwtqbue5WRHw25EkvxwlzlsVJFTQdvTmWTU6Xupmh++gvJwBlzCCg4yBfUua8l56RImquGzvq0RucsUEgAkr2RjzTUHFiluf7ocMU4bOVtiSmHAZFsG2CBhqk2b3yJQgBg9N8tYxyIuTFgW1vHfnoO7uO3JD4Csla90FoZ1FithXxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Qk8DBoB2I3RPP4jjxUaQBe1LkakLHyv5F9aaqcRZekk=; b=gYFKuXHlaDESuEOkP5gD/sIjy5Jie0HDtUFGTa2VEVQh8BHRS5Uy1/czmi6902dTEHjNj+jl6sudw07kxU8MD5n2kcx7k9WUyPFcUNn8DgXvtvWb3BUnsVbOhBRWYhUPly63ZFRtFBD6aJXT5rZY+mT+peHBHDBZxFuTH9mnFnMPfqgV8KP0M0gmAKcO9rJp2QLYb7pds6ZbWUkTzEtmEpTIMMFh0G4zl1jJU7sNqqjJSmFp3VpWAS6LsPlj0yr7jpEmDc7vcwbceveX1jaVXs3YTLoA6Sr0mu1HZFMVaLQBdJnOxtDoAWVJ1XlBA1vY1/O8hNnyK2cK9ROMj1TteA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 195.60.68.100) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=axis.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=axis.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Qk8DBoB2I3RPP4jjxUaQBe1LkakLHyv5F9aaqcRZekk=; b=F5wKa0pir7H2KlJJW7rEMqHsiCimKuNNvO43uakDI8dRD7gSKGUK+as04tm/wiGk7+x6JNRVdgRIjmyTVG/DJeyD+GBzhupwyUB3llHRZitk1q3Hfu+PHoN2VzYceTM3pzDqylRYt+LRWV77Oi7AYEglWBqumIlAF5fhP4KMG68= Received: from AS9PR01CA0046.eurprd01.prod.exchangelabs.com (2603:10a6:20b:542::24) by PA4PR02MB6541.eurprd02.prod.outlook.com (2603:10a6:102:fb::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.37; Tue, 23 Jan 2024 20:36:34 +0000 Received: from AMS1EPF0000003F.eurprd04.prod.outlook.com (2603:10a6:20b:542:cafe::89) by AS9PR01CA0046.outlook.office365.com (2603:10a6:20b:542::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.38 via Frontend Transport; Tue, 23 Jan 2024 20:36:34 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 195.60.68.100) smtp.mailfrom=axis.com; dkim=none (message not signed) header.d=none;dmarc=fail action=none header.from=axis.com; Received-SPF: Fail (protection.outlook.com: domain of axis.com does not designate 195.60.68.100 as permitted sender) receiver=protection.outlook.com; client-ip=195.60.68.100; helo=mail.axis.com; Received: from mail.axis.com (195.60.68.100) by AMS1EPF0000003F.mail.protection.outlook.com (10.167.16.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7202.16 via Frontend Transport; Tue, 23 Jan 2024 20:36:33 +0000 Received: from se-mail02w.axis.com (10.20.40.8) by se-mail02w.axis.com (10.20.40.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 23 Jan 2024 21:36:33 +0100 Received: from se-intmail01x.se.axis.com (10.0.5.60) by se-mail02w.axis.com (10.20.40.8) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Tue, 23 Jan 2024 21:36:33 +0100 Received: from pchp3.se.axis.com (pchp3.se.axis.com [10.88.21.53]) by se-intmail01x.se.axis.com (Postfix) with ESMTP id 4349212B3B; Tue, 23 Jan 2024 21:36:33 +0100 (CET) Received: by pchp3.se.axis.com (Postfix, from userid 171) id 4575C20425; Tue, 23 Jan 2024 21:36:33 +0100 (CET) From: Hans-Peter Nilsson To: In-Reply-To: <20240122142716.66B042041E@pchp3.se.axis.com> (message from Hans-Peter Nilsson on Mon, 22 Jan 2024 15:27:16 +0100) Subject: [PATCH v2] c/c++: Tweak warning for 'always_inline function might not be inlinable' MIME-Version: 1.0 References: <20240121133239.45A0B20422@pchp3.se.axis.com> <20240122142716.66B042041E@pchp3.se.axis.com> Message-ID: <20240123203633.4575C20425@pchp3.se.axis.com> Date: Tue, 23 Jan 2024 21:36:33 +0100 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS1EPF0000003F:EE_|PA4PR02MB6541:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e04eef6-1a24-4953-8c58-08dc1c52fcfc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gZd/UyRKiRtguvMpUPs2AOLAAg5vAw5Op2Kgq5SuBMJDqI62weeBeyfpgLXfLeOZjUDJk6Fp/1dx6T6wWFm29suK5i3qyU6I/ehi0QO/R3xpvprBGoClj/82Wk/nfjEcxuNflvZJSTWR1sVKQ7Yf5bTXH/lyUa7FZr0ZcyLU2Zp1v8/pK1Vmz4ax0D93EnB0or+ud1smhYQ2eQSnh/3FdrK6Tsir+GB5PJqhZhxpSdCt0AHpY0UVnrlrms4yfDWlgEj/dwxSYhuixwdWK5LIWiyFjPxmHoSg0GxPFX088KC2f9HgIBQBSFDMjsJSN4Zff5rjo2AawEk/SnGJRIt1Qwbwj1acuwsVH0659Lbo3CJSRsT2/obKYM8ltM3cauHsDxevD9TvN6bipz3zg4vQvlhr2pw+Rp1+tCl40USwI+wOx2ilE3Nd+n2yvG2NXFsi09Hezvrv7jPe9DC73mPyjbbSifacOy+CV5OLhJzGgw1VO7VKCriv3QSJFAeOhWKU3CHe80f7u87MSVR5qM/jrbirPbWc/bD5i5y1Vaps5Rb5/UdOA5BfXoAVqjBRD9mhWO+/0SvJ0MdChzC2on2/vhnohNJEoYsTLIadYI5NSK4nSa+TGMeQxNdUehJq8KLMkD0Bko9WVGiRMzshf+eNlF72jO1yQ7JcpuirxHf3t+XrTXpJHhAMkwOIeWXS3+f0zdg6nUqfcadaYSK91CmPFApxuJPX9QoC7Ffyeq9RfQQnlLIkUmkyflgRJqB8InN53OLEnwr52ESMFvuCE+cPT2u7wer5CVQxA4XDWSf8LWQ= X-Forefront-Antispam-Report: CIP:195.60.68.100; CTRY:SE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.axis.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(346002)(396003)(136003)(39860400002)(376002)(230173577357003)(230273577357003)(230922051799003)(1800799012)(64100799003)(82310400011)(186009)(451199024)(40470700004)(36840700001)(46966006)(40480700001)(40460700003)(84970400001)(83380400001)(42186006)(6266002)(478600001)(70586007)(336012)(5660300002)(8936002)(316002)(8676002)(70206006)(426003)(1076003)(47076005)(26005)(36860700001)(6916009)(82740400003)(81166007)(356005)(41300700001)(33656002)(2906002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: axis.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jan 2024 20:36:33.6760 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8e04eef6-1a24-4953-8c58-08dc1c52fcfc X-MS-Exchange-CrossTenant-Id: 78703d3c-b907-432f-b066-88f7af9ca3af X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=78703d3c-b907-432f-b066-88f7af9ca3af; Ip=[195.60.68.100]; Helo=[mail.axis.com] X-MS-Exchange-CrossTenant-AuthSource: AMS1EPF0000003F.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR02MB6541 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Change from v1: The message is changed as per the review. The powerpc test-case is dropped from the changes as the part quoted in a comment now does not change and so cannot cause further confusion. The commit message is tweaked. It now also mentions clang. I intend to commit this on Thursday 2024-01-25, as per Richard Biener's approval. -- >8 -- When you're not regularly exposed to this warning, it is easy to be misled by its wording, believing that there's something else in the function that stops it from being inlined, something other than the lack of also being *declared* inline. Also, clang does not warn. It's just a warning: without the inline directive, there has to be a secondary reason for the function to be inlined, other than the always_inline attribute, a reason that may be in effect despite the warning. Whenever the text is quoted in inline-related bugzilla entries, there seems to often have been an initial step of confusion that has to be cleared, for example in PR55830. A file in the powerpc-specific parts of the test-suite, gcc.target/powerpc/vec-extract-v16qiu-v2.h, has a comment and seems to be another example, and I testify as the first-hand third "experience". The wording has been the same since the warning was added. Let's just tweak the wording, adding the cause, so that the reason for the warning is clearer. This hopefully stops the user from immediately asking "'Might'? Because why?" and then going off looking at the function body - or grepping the gcc source or documentation, or enter a bug-report subsequently closed as resolved/invalid. Since the message is only appended with additional information, no test-case actually required adjustment. I still changed them, so the message is covered. gcc: * cgraphunit.cc (process_function_and_variable_attributes): Tweak the warning for an attribute-always_inline without inline declaration. gcc/testsuite: * g++.dg/Wattributes-3.C: Adjust expected warning. * gcc.dg/fail_always_inline.c: Ditto. --- gcc/cgraphunit.cc | 3 ++- gcc/testsuite/g++.dg/Wattributes-3.C | 4 ++-- gcc/testsuite/gcc.dg/fail_always_inline.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/gcc/cgraphunit.cc b/gcc/cgraphunit.cc index 38052674aaa5..5c405258ec30 100644 --- a/gcc/cgraphunit.cc +++ b/gcc/cgraphunit.cc @@ -918,7 +918,8 @@ process_function_and_variable_attributes (cgraph_node *first, /* redefining extern inline function makes it DECL_UNINLINABLE. */ && !DECL_UNINLINABLE (decl)) warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wattributes, - "% function might not be inlinable"); + "% function might not be inlinable" + " unless also declared %"); process_common_attributes (node, decl); } diff --git a/gcc/testsuite/g++.dg/Wattributes-3.C b/gcc/testsuite/g++.dg/Wattributes-3.C index 208ec6696551..dd9c2244900c 100644 --- a/gcc/testsuite/g++.dg/Wattributes-3.C +++ b/gcc/testsuite/g++.dg/Wattributes-3.C @@ -26,7 +26,7 @@ B::operator char () const { return 0; } ATTR ((__noinline__)) B::operator int () const // { dg-warning "ignoring attribute .noinline. because it conflicts with attribute .always_inline." } -// { dg-warning "function might not be inlinable" "" { target *-*-* } .-1 } +// { dg-warning "function might not be inlinable unless also declared .inline." "" { target *-*-* } .-1 } { return 0; @@ -45,7 +45,7 @@ C::operator char () { return 0; } ATTR ((__noinline__)) C::operator short () // { dg-warning "ignoring attribute .noinline. because it conflicts with attribute .always_inline." } -// { dg-warning "function might not be inlinable" "" { target *-*-* } .-1 } +// { dg-warning "function might not be inlinable unless also declared .inline." "" { target *-*-* } .-1 } { return 0; } inline ATTR ((__noinline__)) diff --git a/gcc/testsuite/gcc.dg/fail_always_inline.c b/gcc/testsuite/gcc.dg/fail_always_inline.c index 86645b850de8..16a549ca0935 100644 --- a/gcc/testsuite/gcc.dg/fail_always_inline.c +++ b/gcc/testsuite/gcc.dg/fail_always_inline.c @@ -2,7 +2,7 @@ /* { dg-add-options bind_pic_locally } */ extern __attribute__ ((always_inline)) void - bar() { } /* { dg-warning "function might not be inlinable" } */ + bar() { } /* { dg-warning "function might not be inlinable unless also declared .inline." } */ void f()