From patchwork Sun Jan 21 13:32:39 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: 189813 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp2069700dyb; Sun, 21 Jan 2024 05:33:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IHjDK8jQE0MrICcnxOYhKxGdib09KWBH3a7hE8dhzSo1Bq9rs7fu3xqFmtotXPemZz4Na5m X-Received: by 2002:a05:620a:22e:b0:783:36ac:3b4b with SMTP id u14-20020a05620a022e00b0078336ac3b4bmr3057602qkm.157.1705844005167; Sun, 21 Jan 2024 05:33:25 -0800 (PST) ARC-Seal: i=3; a=rsa-sha256; t=1705844005; cv=pass; d=google.com; s=arc-20160816; b=EeobwW5mnelnbAm9hvRxkonU+ICkQHt849EoloZdy4AWyzelBhz6LWInbvwuaYggyG zZkxZ2dHD6A9Uw2dlF1SpIRVbIBwZ83TXWkV9+Bl225wK8XbREr5FYpxFH2TKWXz3a0Z eAtEEWbiolke8A417D4Ztpa57327UFh3jly0sxSdKgNFZ8fBgj5Y2GkKq/Y87TKu8fEd LXRnxiMUvl6Tfl+0cpE+PAPp4gax/mxLtz7ky/w5dOljjTVR0APn+FjTBXisgwRTHcpE X+bQUOzCq1qTBYgF/E/lvpW/9fzsddB9DX02WOLF6b1FNvwWsxpFhvx3rsM/Beuq9QeS f5Tw== ARC-Message-Signature: i=3; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:date:message-id :content-transfer-encoding:mime-version:subject:to:from :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=uDx2ccpKqX5vi5j7ezUnfWnJEjjTc8IdtSy1OeQEVJc=; fh=gk9A5O7Gbglvz1MjrRQ4hZ2i3c68kYkpOZJg1emXh+g=; b=BOgXDb4ZWFfgdDExjw9bjE1uRlbYKnn3PwtXU+4HR9oEI6yR/wJ1B9lewq4KkDXdiE S7h6yYNw6gFU6kewPkOyMotiFXiXzO0qwnhrNGLQFxCjV6li8G5DIukLMhHLRrRSjYlb ZqPOUuv55nEzO9u6j5jeCPZ3F5Mmi2FCHK2oPY+Wy5XH/94mEkfMNL4e+hljoLTTkOsl xKwKxRs1alj3jveBe3brOydpTi71WLOgA86YF7IirgfIF4oxGzZIAYgOmj74VaCEXM/v htqhtrcJXM6N7IZitpY2jJYjf4bhF8n4dg3Xds8aCnL5QleqxGa232dsUebWYT4NzQQC 0Xww== ARC-Authentication-Results: i=3; mx.google.com; dkim=pass header.i=@axis.com header.s=selector1 header.b=rp7VKNOd; arc=pass (i=2); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id j3-20020a05620a410300b007831de73c06si3686021qko.118.2024.01.21.05.33.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 05:33:25 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@axis.com header.s=selector1 header.b=rp7VKNOd; arc=pass (i=2); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D6A423858417 for ; Sun, 21 Jan 2024 13:33:24 +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-am0eur02on2066.outbound.protection.outlook.com [40.107.247.66]) by sourceware.org (Postfix) with ESMTPS id 4157F3858D32 for ; Sun, 21 Jan 2024 13:32:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4157F3858D32 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 4157F3858D32 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.247.66 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1705843966; cv=pass; b=lPZDbC7t3baFHlmOkw2vrd7Hlq7e0yQWlp+vPpNgCUvk/FhHYbQ9PZapRb5ifynNYFa3OnsHOir+/o4aBOUYZxGcAG6zSBn/FmE1uJZexZh+PK/aYoJ7TEm6wz2mGR9G2TSQbbpb4PBqv7H7WjK4NAUKrRo4+WTz8AeMuiqF3dY= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1705843966; c=relaxed/simple; bh=FTzvYgYuaLB5jD2NubJ90TE9LYSmx9cAtgwtbFARNck=; h=DKIM-Signature:From:To:Subject:MIME-Version:Message-ID:Date; b=TbZqf0DTmKz6LUfU6JiCcMDZwBjBlySizSI1dNZMFIzTscOtGNk9uKnciEW+pUPWyEe/wRhHb2udUWOjQUJ3vCoDYZG4LMsr1c79k5aVG1ghOlQFTCzWSJ+X2EtokvTm//QNuxXRCF83XyfU55aA7OXWFdOOdbEKsgtMmDl0EKk= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZDhAxmbIpUSK6Ev96bQXIfa5+hmS1sk5Qmn3M9yBTnr7gl9zn+VcCMj8FRPFN8NqsFYm5f66S4rZUGX6Lueuw1xf0I0fqavgRf1iKwgN3Puc00ccl2aFeNY4xiztRg94ZOfPltpuQ1rPv7THwDj636unD22h6ULmPshTPWrEtuOgs9PhVp1QrjCs59d6MQjYvzrMsRjW45wVTyG0cJN4wxCRVaLhNSCxs+P5/JTPm1kr/BzxS8X/HP3Wu45DYBfYYhWJWWOSQ5KD06Bbmx8XpigVLf/dkTL9uWCY6GMKXXS1jEwH0oBDJL77aoQO4YMF6v77AKc3xFxdRiaa3vxdFQ== 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=uDx2ccpKqX5vi5j7ezUnfWnJEjjTc8IdtSy1OeQEVJc=; b=dwXGHK81Jh87SRGENptqFR2k5KSfooPQ1sJqj/fGMm+SmmtMknmZ76mS8iyGkpqbXsMJbz9JXdaqWGywYJyzg93LTzF48wHAMiFsVfRle1AWhMuuTV3+TGJtCfAYUkSxvc6JbUw5cqF9igLl7sFCIS+XfIS4s+RB4nWxxG1SeannZwyCEfSfZDVA4jlQTI8a7MnVUQG4JoDHmX5ja1GU1S0ljnPCRy3wJwdDmEGOjpzNrCMCOIt6R+AIfkLI19nCHHkyNlWeDkE6i5LWq1DRHyi9WyQfmqx0FaY9g5oB0kau3OMSrWUS+zEGyN5lfXHZPLXpYpTC2IeCs/YNqGj8Gw== 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=uDx2ccpKqX5vi5j7ezUnfWnJEjjTc8IdtSy1OeQEVJc=; b=rp7VKNOdCCC1IJvnNa96DUlAffNp4iSkXlVO6J6OF4BzbYVkXZn3FGU8wEf3dASPGEMg5xF+ElyPsptEg9C6IIUsg2yKjN6wwHccM8yf657X7isO6a3yEE/kZPBYClRXtzTlnyL25bdWFyyEhjlhMlxWe1C41xMySoWApO+EBok= Received: from AM7PR02CA0027.eurprd02.prod.outlook.com (2603:10a6:20b:100::37) by AM7PR02MB6291.eurprd02.prod.outlook.com (2603:10a6:20b:1b1::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.31; Sun, 21 Jan 2024 13:32:41 +0000 Received: from AMS0EPF0000019B.eurprd05.prod.outlook.com (2603:10a6:20b:100:cafe::e7) by AM7PR02CA0027.outlook.office365.com (2603:10a6:20b:100::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7202.31 via Frontend Transport; Sun, 21 Jan 2024 13:32:41 +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 AMS0EPF0000019B.mail.protection.outlook.com (10.167.16.247) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7202.16 via Frontend Transport; Sun, 21 Jan 2024 13:32:39 +0000 Received: from SE-MAIL21W.axis.com (10.20.40.16) by se-mail01w.axis.com (10.20.40.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Sun, 21 Jan 2024 14:32:39 +0100 Received: from se-mail01w.axis.com (10.20.40.7) by SE-MAIL21W.axis.com (10.20.40.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Sun, 21 Jan 2024 14:32:39 +0100 Received: from se-intmail01x.se.axis.com (10.0.5.60) by se-mail01w.axis.com (10.20.40.7) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Sun, 21 Jan 2024 14:32:39 +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 5485B129B2; Sun, 21 Jan 2024 14:32:39 +0100 (CET) Received: by pchp3.se.axis.com (Postfix, from userid 171) id 45A0B20422; Sun, 21 Jan 2024 14:32:39 +0100 (CET) From: Hans-Peter Nilsson To: Subject: [PATCH] c/c++: Tweak warning for 'always_inline function might not be inlinable' MIME-Version: 1.0 Message-ID: <20240121133239.45A0B20422@pchp3.se.axis.com> Date: Sun, 21 Jan 2024 14:32:39 +0100 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF0000019B:EE_|AM7PR02MB6291:EE_ X-MS-Office365-Filtering-Correlation-Id: 666d5cde-f590-4f38-28e7-08dc1a85706b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1ILqJphTc4URzcXMxDExkdlAz9QpJh0xX15jmoiBIBrk8G5bNnk53GnGvKLPHXmHcxBQf5ygC0j7ooeurD1Ydq7B2JcdD17xgcxTNp8yJCf2W66pvso7RbzK+0jn9FUP6nD3xnl0mtW7ALTgQnoeFWNGh4Z4TQdHz/ZER2k18wcXTsOzPgXNYU7HTAG2lYgObw0vKvozvzupsSjuUyPQUdYcHLGEPILNJz26tXMTAVw557TH1IsP0FKdQdXXustMMTCF7yDsw/K+sdY5sx4pJlN0mpNJyCpm6xj32ztzIuBsivz0gbEWill8faEglNpbB3gP6XkMjJVgiimghZoJe8xLRROH5t30PbxzJQiLugqSWj95I76Nw4nGTQ44p5JjDZwqIDHgxj/81iBFmQCRWjAM2QrHP2WkSB0IJy2woVFLI5BEeWz51RIRngBLeMXnZfZ2v2o6Pp9e5e6o7eicbqK0O0eW0LtB0gGUM5Scw+r0xIQNvcuhQmHFNgPS4E741XD2SbJUfdzjc/LzaBeLH8AaPigC0guH/hqQRWCoqWAbXUWJWqf6cMhFLGQfA9yc0YPHRp68pHgxTgdrksadBYWu2CyxpHSjwklCaDRfSDGjH6VBBl/p0kapaNebO7OvSRrguy1CA5k4sGppOcbfLVCkjcg2jQoe6hwArw66iZqzBX2vZ7xDL60CxRrMTvaQj6ngcSR02Whgb9flenNjM4jd1sJJsl8R/SZ0BsjwCXVD6S1jVxlflZHDfWojZr7I6lR5YrxhDiK1WJw8z+bQ1A== 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)(396003)(346002)(39850400004)(376002)(136003)(230273577357003)(230173577357003)(230922051799003)(64100799003)(186009)(82310400011)(1800799012)(451199024)(46966006)(36840700001)(33656002)(84970400001)(40480700001)(356005)(81166007)(1076003)(26005)(47076005)(36860700001)(82740400003)(83380400001)(6266002)(426003)(336012)(6916009)(8676002)(8936002)(478600001)(316002)(70586007)(70206006)(42186006)(5660300002)(2906002)(41300700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: axis.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jan 2024 13:32:39.8498 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 666d5cde-f590-4f38-28e7-08dc1a85706b 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: AMS0EPF0000019B.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR02MB6291 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788707083553786879 X-GMAIL-MSGID: 1788707083553786879 Tested x86_64-linux-gnu. Ok to commit? Or, does the message need more tweaking? (If so, suggestions from native speakers?) FWIW, I found no PR for just the message being bad. -- >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, than the lack of also being *declared* inline. It's just a warning: without the inline directive, there has to be a secondary reasons for the function to be inlined, than the always_inline attribute, reasons 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. The powerpc test-case in this patch where a comment is adjusted, 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. 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.target/powerpc/vec-extract-v16qiu-v2.h: Adjust quoted warning in comment. --- gcc/cgraphunit.cc | 3 ++- gcc/testsuite/g++.dg/Wattributes-3.C | 4 ++-- gcc/testsuite/gcc.dg/fail_always_inline.c | 2 +- gcc/testsuite/gcc.target/powerpc/vec-extract-v16qiu-v2.h | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/gcc/cgraphunit.cc b/gcc/cgraphunit.cc index 38052674aaa5..89dc1af522a4 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 is not always inlined" + " 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..4adf0944cd4f 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 is not always inlined 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 is not always inlined 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..2f48d7f5c6be 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 is not always inlined unless also declared .inline." } */ void f() diff --git a/gcc/testsuite/gcc.target/powerpc/vec-extract-v16qiu-v2.h b/gcc/testsuite/gcc.target/powerpc/vec-extract-v16qiu-v2.h index d1157599ee7c..b9800e1c950d 100644 --- a/gcc/testsuite/gcc.target/powerpc/vec-extract-v16qiu-v2.h +++ b/gcc/testsuite/gcc.target/powerpc/vec-extract-v16qiu-v2.h @@ -179,7 +179,7 @@ get_auto_15 (vector TYPE a) #ifdef DISABLE_INLINE_OF_GET_AUTO_N __attribute__ ((__noinline__)) #else -/* gcc issues warning: always_inline function might not be inlinable +/* gcc issues warning: always_inline function is not always inlined unless also declared inline __attribute__ ((__always_inline__)) */