From: Paolo Bonzini <pbonzini@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>, qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Thomas Huth" <thuth@redhat.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>
Subject: Re: [PATCH-for-9.0? v2 4/4] meson: Enable -Wstatic-in-inline
Date: Wed, 27 Mar 2024 10:26:00 +0100 [thread overview]
Message-ID: <8cf13d4d-0b1a-487a-8a7c-1aea4cb107c5@redhat.com> (raw)
In-Reply-To: <20240326171009.26696-5-philmd@linaro.org>
On 3/26/24 18:10, Philippe Mathieu-Daudé wrote:
> Compilers are clever enough to inline code when necessary.
>
> The only case we accept an inline function is static in
> header (we use C, not C++).
>
> Add the -Wstatic-in-inline CPPFLAG to prevent public and
> inline function to be added in the code base.
No problem with the first three patches, but -Wstatic-in-inline is not
warning for non-static inline functions. The warning is enabled by
default by GCC (which has no way to disable it even) and by clang
outside headers:
f.h:
static int y;
inline int f()
{
return y;
}
f.c:
#include "f.h"
int main()
{
}
$ clang f.c
./f.h:5:12: warning: static variable 'y' is used in an inline function with external linkage [-Wstatic-in-inline]
$ gcc f.c
f.h:5:12: warning: ‘y’ is static but used in inline function ‘f’ which is not static
The actual effect of this patch is to enable the warning on clang *even
outside headers* (clang only enables the warning in headers by default
because, if a static variable belongs to the main source file, it has a
single definition anyway unlike if it's defined in an included file).
For now I'm queuing patches 1-3 only.
Paolo
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> Message-Id: <20240313184954.42513-5-philmd@linaro.org>
> Reviewed-by: Thomas Huth <thuth@redhat.com>
> ---
> meson.build | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/meson.build b/meson.build
> index c9c3217ba4..f400f7d36c 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -591,6 +591,7 @@ warn_flags = [
> '-Wold-style-definition',
> '-Wredundant-decls',
> '-Wshadow=local',
> + '-Wstatic-in-inline',
> '-Wstrict-prototypes',
> '-Wtype-limits',
> '-Wundef',
next prev parent reply other threads:[~2024-03-27 9:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-26 17:10 [PATCH-for-9.0? v2 0/4] overall: Avoid using inlined functions with external linkage again Philippe Mathieu-Daudé
2024-03-26 17:10 ` [PATCH-for-9.0? v2 1/4] hw/arm/smmu: " Philippe Mathieu-Daudé
2024-03-26 17:33 ` Eric Auger
2024-03-26 17:10 ` [PATCH-for-9.0? v2 2/4] accel/hvf: Un-inline hvf_arch_supports_guest_debug() Philippe Mathieu-Daudé
2024-03-26 17:10 ` [PATCH-for-9.0? v2 3/4] qtest/libqos: Reduce size_to_prdtl() declaration scope Philippe Mathieu-Daudé
2024-03-26 17:19 ` Peter Maydell
2024-03-26 17:24 ` Thomas Huth
2024-03-26 17:10 ` [PATCH-for-9.0? v2 4/4] meson: Enable -Wstatic-in-inline Philippe Mathieu-Daudé
2024-03-26 17:28 ` Thomas Huth
2024-03-27 7:49 ` Philippe Mathieu-Daudé
2024-03-27 9:26 ` Paolo Bonzini [this message]
2024-03-27 12:42 ` Philippe Mathieu-Daudé
2024-03-27 14:12 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8cf13d4d-0b1a-487a-8a7c-1aea4cb107c5@redhat.com \
--to=pbonzini@redhat.com \
--cc=berrange@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).