Repository navigation
Conversation
|
My take on extending ancient GCC support. If we really want to. |
|
augment review |
#pragma diagnostic in core code, disable picky warnings
There was a problem hiding this comment.
Pull request overview
This PR centralizes compiler-diagnostic support detection by introducing CURL_HAVE_DIAG and updating code to use it when guarding #pragma GCC diagnostic push/pop, while also aligning warning-flag enabling to avoid unsupported pragmas on GCC < 4.6.
Changes:
- Add
CURL_HAVE_DIAGinlib/curl_setup.h(Clang or GCC >= 4.6) and remove the olderCURL_GNUC_DIAGtest-only macro. - Replace scattered
__GNUC__/__clang__/CURL_GNUC_DIAGchecks withCURL_HAVE_DIAGacross libcurl, tool, tests, and test servers. - Update Autotools and CMake picky-warning logic to keep picky warnings disabled for GCC < 4.6.
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
lib/curl_setup.h |
Defines CURL_HAVE_DIAG to gate diagnostic pragmas based on compiler capability. |
tests/libtest/first.h |
Removes CURL_GNUC_DIAG now that a global capability macro exists. |
tests/unit/unit3200.c |
Uses CURL_HAVE_DIAG around overlength-string suppression pragmas. |
tests/unit/unit2604.c |
Uses CURL_HAVE_DIAG around overlength-string suppression pragmas. |
tests/unit/unit1652.c |
Switches GCC-only diagnostic push/pop to CURL_HAVE_DIAG (excluding clang). |
tests/unit/unit1398.c |
Uses CURL_HAVE_DIAG around format-warning suppression pragmas. |
tests/server/util.c |
Uses CURL_HAVE_DIAG around nonliteral-format suppression pragmas. |
tests/libtest/lib557.c |
Uses CURL_HAVE_DIAG around format-warning suppression pragmas. |
lib/content_encoding.c |
Uses CURL_HAVE_DIAG when silencing warnings from brotli headers. |
lib/version.c |
Uses CURL_HAVE_DIAG when silencing warnings from brotli headers. |
lib/mprintf.c |
Uses CURL_HAVE_DIAG around nonliteral-format suppression pragmas. |
lib/curlx/snprintf.c |
Uses CURL_HAVE_DIAG around nonliteral-format suppression pragmas. |
src/tool_cb_prg.c |
Uses CURL_HAVE_DIAG around nonliteral-format suppression pragmas. |
src/tool_main.c |
Uses CURL_HAVE_DIAG around missing-prototypes suppression pragmas for wmain. |
src/tool_writeout.c |
Uses CURL_HAVE_DIAG around nonliteral-format suppression pragmas for strftime. |
lib/ftp.c |
Uses CURL_HAVE_DIAG for platform-specific warning suppression blocks. |
lib/if2ip.c |
Uses CURL_HAVE_DIAG for AIX-specific warning suppression in system headers. |
lib/ldap.c |
Uses CURL_HAVE_DIAG for Apple-specific deprecated-declarations suppression. |
lib/curl_gssapi.c |
Uses CURL_HAVE_DIAG for Apple-specific deprecated-declarations suppression. |
lib/socks_gssapi.c |
Uses CURL_HAVE_DIAG for Apple-specific deprecated-declarations suppression. |
lib/vauth/spnego_gssapi.c |
Uses CURL_HAVE_DIAG for Apple-specific deprecated-declarations suppression. |
lib/vauth/krb5_gssapi.c |
Uses CURL_HAVE_DIAG for Apple-specific deprecated-declarations suppression. |
m4/curl-compilers.m4 |
Avoids enabling warning options for GCC < 4.6 in Autotools warning setup. |
CMake/PickyWarnings.cmake |
Avoids enabling picky warnings for GCC < 4.6 in CMake builds. |
docs/examples/sendrecv.c |
Clarifies comment about keeping pragma usage compatible with GCC < 4.6. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
#pragma diagnostic in core code, disable picky warnings#pragma diagnostic for <4.6 in core code, disable picky warnings
🤖 Augment PR SummarySummary: This PR avoids using
🤖 Was this summary useful? React with 👍 or 👎 |
|
augment review |
There was a problem hiding this comment.
Pull request overview
This PR standardizes how the codebase guards #pragma GCC diagnostic push/pop by introducing and using a single CURL_HAVE_DIAG macro (Clang or GCC >= 4.6), avoiding build issues with older GCC versions and simplifying warning-flag logic.
Changes:
- Add
CURL_HAVE_DIAGtolib/curl_setup.hand replace scattered__GNUC__/__clang__checks across lib/tool/tests withCURL_HAVE_DIAG. - Remove the test-only
CURL_GNUC_DIAGmacro and update unit/libtest/server sources accordingly. - Update Autotools + CMake “picky warnings” logic to keep it disabled for GCC < 4.6 (since local diagnostic suppression is unavailable there).
Reviewed changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/unit3200.c | Use CURL_HAVE_DIAG to guard diagnostic push/pop around overlength string literals. |
| tests/unit/unit2604.c | Use CURL_HAVE_DIAG to guard diagnostic push/pop around overlength string literals. |
| tests/unit/unit1652.c | Switch to CURL_HAVE_DIAG while keeping GCC-only warning suppression (excluding Clang). |
| tests/unit/unit1398.c | Use CURL_HAVE_DIAG to guard diagnostic push/pop for format-warning suppression. |
| tests/server/util.c | Use CURL_HAVE_DIAG to guard diagnostic push/pop around non-literal format warning suppression. |
| tests/libtest/lib557.c | Use CURL_HAVE_DIAG to guard diagnostic push/pop around format warning suppressions. |
| tests/libtest/first.h | Remove legacy CURL_GNUC_DIAG macro (now superseded by CURL_HAVE_DIAG). |
| src/tool_writeout.c | Use CURL_HAVE_DIAG for guarding local suppression of -Wformat-nonliteral. |
| src/tool_main.c | Use CURL_HAVE_DIAG for wmain()-related diagnostic suppression on Unicode builds. |
| src/tool_cb_prg.c | Use CURL_HAVE_DIAG for guarding local suppression of -Wformat-nonliteral. |
| m4/curl-compilers.m4 | Avoid enabling warning sets for GCC < 4.6; remove now-unneeded GCC<4.6 global suppression workarounds. |
| lib/version.c | Use CURL_HAVE_DIAG to guard VLA-warning suppression around brotli headers. |
| lib/vauth/spnego_gssapi.c | Use CURL_HAVE_DIAG on Apple builds to guard deprecated-declarations suppression push/pop. |
| lib/vauth/krb5_gssapi.c | Use CURL_HAVE_DIAG on Apple builds to guard deprecated-declarations suppression push/pop. |
| lib/socks_gssapi.c | Use CURL_HAVE_DIAG on Apple builds to guard deprecated-declarations suppression push/pop. |
| lib/mprintf.c | Use CURL_HAVE_DIAG to guard local suppression of -Wformat-nonliteral. |
| lib/ldap.c | Use CURL_HAVE_DIAG on Apple builds to guard deprecated-declarations suppression push/pop. |
| lib/if2ip.c | Use CURL_HAVE_DIAG on AIX builds to guard local warning suppression around system headers. |
| lib/ftp.c | Use CURL_HAVE_DIAG to guard local suppression for unsigned time_t warning cases (DJGPP/Amiga). |
| lib/curlx/snprintf.c | Use CURL_HAVE_DIAG to guard local suppression of -Wformat-nonliteral (Windows wrapper). |
| lib/curl_setup.h | Define CURL_HAVE_DIAG for Clang or GCC >= 4.6 as the single guard for diagnostic pragmas. |
| lib/curl_gssapi.c | Use CURL_HAVE_DIAG on Apple builds to guard deprecated-declarations suppression push/pop. |
| lib/content_encoding.c | Use CURL_HAVE_DIAG to guard VLA-warning suppression around brotli headers. |
| docs/examples/sendrecv.c | Clarify intent to keep GCC diagnostic suppression at file scope for GCC < 4.6 compatibility. |
| CMake/PickyWarnings.cmake | Keep picky warnings disabled for GCC < 4.6; remove now-unneeded GCC<4.6 global suppression workarounds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
#pragma diagnostic for <4.6 in core code, disable picky warnings#pragma diagnostic in core code for <4.6, disable picky warnings
…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 f07a98a curl#20366 Fixes curl#20892 Fixes curl#20924 Closes curl#20902 Closes curl#20907
Extend
#pragma diagnostic push/popguards to the whole codebase(from tests and examples only) to disable it for GCC <4.6. Rename guard
to
CURL_HAVE_DIAGand make it include llvm/clang to be interchangeablewith
__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:
Not needed with picky warnings disabled.
Reported-by: fds242 on github
Reported-by: Sergey Fedorov
Thanks-to: Orgad Shaneh
Follow-up to f07a98a #20366
Fixes #20892
Fixes #20924
Closes #20902
CURL_GNUC_DIAGtoCURL_HAVE_DIAG, also set for__clang__, change all uses?__GNUC__uses withCURL_HAS_DIAGin non-portable lines? (in particular, Apple?)