From: Junio C Hamano <gitster@pobox.com>
To: Dominik Loidolt <dominik.loidolt@univie.ac.at>
Cc: git@vger.kernel.org, "Alejandro R Sedeño" <asedeno@google.com>,
"Alejandro R. Sedeño" <asedeno@MIT.EDU>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: Re: [PATCH] compat/posix.h: enable UNUSED warning messages for Clang
Date: Mon, 04 May 2026 10:10:26 +0900 [thread overview]
Message-ID: <xmqq1pfsq8sd.fsf@gitster.g> (raw)
In-Reply-To: <20260503151210.36036-1-dominik.loidolt@univie.ac.at> (Dominik Loidolt's message of "Sun, 3 May 2026 17:12:10 +0200")
Dominik Loidolt <dominik.loidolt@univie.ac.at> writes:
> Treat Clang like GCC 4.5+ so using an UNUSED parameter emits the
> intended warning message.
>
> Commit 7c07f36ad2 (git-compat-util.h: GCC deprecated message arg only in
> GCC 4.5+, 2022-10-05) restricted use of the deprecated attribute's
> message argument in the UNUSED macro to GCC 4.5 or newer.
>
> Clang identifies itself as GNUC 4.2.1 for compatibility, causing the
> current check to use the deprecated attribute without a message, even
> though Clang supports deprecated("...") since version 2.9 (2011).
>
> Signed-off-by: Dominik Loidolt <dominik.loidolt@univie.ac.at>
> ---
> I am not familiar with git's minimum compiler version but this patch
> drops support for Clang < 2.9 from 2011.
Does this "drop support" because you force _all_ versions of Clang
to use the "deprecated" attribute, even though you _know_ some older
versions do not understand it? Don't these versions identify
themselves so that you can do
#if defined(__clang__) && CLANG_VERSION >= 2.9
I do not know if the userbase of GCC and Clang upgrade with a
similar cadence, or we seem to say that we care about GCC 4.5
(2010), so giving a similar version detection for Clang and exclude
ones older than 2.9 sounds more appropriate.
> Dominik
> P.S. This is my first patch sent by email. Please let me know if I
> missed something.
>
> compat/posix.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/compat/posix.h b/compat/posix.h
> index 245386fa4a..ed83a4d9d4 100644
> --- a/compat/posix.h
> +++ b/compat/posix.h
> @@ -35,7 +35,7 @@
> * When a parameter may be used or unused, depending on conditional
> * compilation, consider using MAYBE_UNUSED instead.
> */
> -#if GIT_GNUC_PREREQ(4, 5)
> +#if GIT_GNUC_PREREQ(4, 5) || defined(__clang__)
> #define UNUSED __attribute__((unused)) \
> __attribute__((deprecated ("parameter declared as UNUSED")))
> #elif defined(__GNUC__)
>
> base-commit: 67ad42147a7acc2af6074753ebd03d904476118f
> --
> 2.54.0
next prev parent reply other threads:[~2026-05-04 1:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-03 15:12 [PATCH] compat/posix.h: enable UNUSED warning messages for Clang Dominik Loidolt
2026-05-04 1:10 ` Junio C Hamano [this message]
2026-05-04 1:41 ` Junio C Hamano
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=xmqq1pfsq8sd.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=asedeno@MIT.EDU \
--cc=asedeno@google.com \
--cc=avarab@gmail.com \
--cc=dominik.loidolt@univie.ac.at \
--cc=git@vger.kernel.org \
/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