gcc: guard #pragma diagnostic in core code for <4.6, disable picky warnings

Extend `#pragma diagnostic push`/`pop` guards to the whole codebase
(from tests and examples only) to disable it for GCC <4.6. Rename guard
to `CURL_HAVE_DIAG` and make it include llvm/clang to be interchangeable
with `__GNUC__ || __clang__` in this context.

The above means no longer disabling certain warnings locally, so pair
this with disabling all picky warnings for GCC <4.6.

Also:
- drop global workarounds for misbehaving GCC <4.6 compiler warnings.
  Not needed with picky warnings disabled.

Reported-by: fds242 on github
Reported-by: Sergey Fedorov
Thanks-to: Orgad Shaneh
Follow-up to f07a98ae11 #20366
Fixes #20892
Fixes #20924
Closes #20902
Closes #20907
This commit is contained in:
Viktor Szakats 2026-03-12 10:58:35 +01:00
parent c3f04e76ae
commit 578ee6b79b
No known key found for this signature in database
25 changed files with 56 additions and 68 deletions

View file

@ -31,13 +31,13 @@
#endif
#ifdef HAVE_BROTLI
#if defined(__GNUC__) || defined(__clang__)
#ifdef CURL_HAVE_DIAG
/* Ignore -Wvla warnings in brotli headers */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wvla"
#endif
#include <brotli/decode.h>
#if defined(__GNUC__) || defined(__clang__)
#ifdef CURL_HAVE_DIAG
#pragma GCC diagnostic pop
#endif
#endif