MINOR: compiler: define a __attribute__warning() macro

__attribute__((deprecated)) is convenient to discourage from using
something deprecated, but gcc >= 4.3 provides __attribute__((warning(x)))
that allows to display a specific warning if something is used. This is
particularly convenient to give indications when some API parts need to
be adapted. Let's just define it as a macro that falls back to the older
deprecated attribute when not available.

It's supported on clang 14 as well but works differently and errors
out when redefined (while the main purpose precisely is to add such a
redefinition). Thus instead on clang we use deprecated(msg) which is
OK. See https://github.com/llvm/llvm-project/issues/56519
diff --git a/include/haproxy/compiler.h b/include/haproxy/compiler.h
index 3e00493..86d4ddf 100644
--- a/include/haproxy/compiler.h
+++ b/include/haproxy/compiler.h
@@ -90,6 +90,25 @@
 #define __attribute__(x) __attribute__(x)
 #endif
 
+/* attribute(warning) was added in gcc 4.3 */
+#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
+#  define __has_attribute_warning 1
+#endif
+
+/* __attribute__warning(x) does __attribute__((warning(x))) if supported by the
+ * compiler, otherwise __attribute__((deprecated)). Clang supports it since v14
+ * but is a bit capricious in that it refuses a redefinition with a warning
+ * attribute that wasn't there the first time. However it's OK with deprecated(x)
+ * so better use this one. See: https://github.com/llvm/llvm-project/issues/56519
+ */
+#if defined(__clang__)
+#  define __attribute__warning(x) __attribute__((deprecated(x)))
+#elif __has_attribute(warning)
+#  define __attribute__warning(x) __attribute__((warning(x)))
+#else
+#  define __attribute__warning(x) __attribute__((deprecated))
+#endif
+
 /* By default, gcc does not inline large chunks of code, but we want it to
  * respect our choices.
  */