From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7275A3858C5F; Sat, 20 May 2023 09:45:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7275A3858C5F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684575900; bh=a61tTkOmUWsvZDA0HnkFz+zv6rPl7sSrjWAg1EPR5j0=; h=From:To:Subject:Date:From; b=wO0FGiQ0BWl3khqLr2OPEW92hB2ZfUcRwT+h1crtiNfsmMXdit8xglmJieX35YXl0 vfGURR9Q7k8+T1zzco+i0JilkHbVyNi9AT2Oe6d/YviXX4FU+abu2kk6zlX6Ky0Lrc Gd/aCBQmAzx0Zi4OH1xZ7cwkmSzJN83frK5zCnb8= From: "bruno at clisp dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/109914] New: --suggest-attribute=pure misdiagnoses static functions Date: Sat, 20 May 2023 09:44:59 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: 13.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: bruno at clisp dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter cc target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109914 Bug ID: 109914 Summary: --suggest-attribute=3Dpure misdiagnoses static functions Product: gcc Version: 13.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ipa Assignee: unassigned at gcc dot gnu.org Reporter: bruno at clisp dot org CC: marxin at gcc dot gnu.org Target Milestone: --- Created attachment 55125 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D55125&action=3Dedit test case GCC's --suggest-attribute=3Dpure diagnoses static functions, even though the 'pure' attribute is useless for static functions (after all, the compiler h= as deduced the property on its own). This is leading to my having to litter co= de with '__attribute__ (pure)' declarations merely to pacify GCC. GCC should t= reat the 'pure' attribute like other attributes (e.g., malloc, const), and should issue the diagnostic only for non-static functions where the attribute is in fact useful. How to reproduce: $ gcc --version gcc (GCC) 13.1.0 ... $ gcc -Wsuggest-attribute=3Dpure -O2 -S file-has-acl.c file-has-acl.c: In function =E2=80=98have_xattr=E2=80=99: file-has-acl.c:3385:14: warning: function might be candidate for attribute =E2=80=98pure=E2=80=99 if it is known to return normally [-Wsuggest-attribu= te=3Dpure] 3385 | static _Bool have_xattr (char const *attr, char const *listbuf, ssi= ze_t listsize) | ^~~~~~~~~~=