Git development
 help / color / mirror / Atom feed
* [PATCH] compat/posix.h: enable UNUSED warning messages for Clang
@ 2026-05-03 15:12 Dominik Loidolt
  2026-05-04  1:10 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Dominik Loidolt @ 2026-05-03 15:12 UTC (permalink / raw)
  To: git
  Cc: Dominik Loidolt, Alejandro R Sedeño,
	Alejandro R. Sedeño, Ævar Arnfjörð Bjarmason,
	Junio C Hamano

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.

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-04  1:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2026-05-04  1:41   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox