]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
build: always revert `#pragma GCC diagnostic` after use
authorViktor Szakats <commit@vsz.me>
Fri, 17 Nov 2023 19:13:13 +0000 (19:13 +0000)
committerViktor Szakats <commit@vsz.me>
Sat, 18 Nov 2023 11:16:32 +0000 (11:16 +0000)
Before this patch some source files were overriding gcc warning options,
but without restoring them at the end of the file. In CMake UNITY builds
these options spilled over to the remainder of the source code,
effecitvely disabling them for a larger portion of the codebase than
intended.

`#pragma clang diagnostic` didn't have such issue in the codebase.

Reviewed-by: Marcel Raad
Closes #12352

lib/vssh/libssh.c
lib/vtls/sectransp.c
src/tool_main.c
tests/unit/unit3200.c

index 4d5445be49b802891ad1737d0f6f776d6c0f2b61..76e6344ffae81743192813cf0979a97013dcb332 100644 (file)
@@ -93,6 +93,7 @@
 #if defined(__GNUC__) &&                        \
   (LIBSSH_VERSION_MINOR >= 10) ||               \
   (LIBSSH_VERSION_MAJOR > 0)
+#pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 #endif
 
@@ -2946,4 +2947,10 @@ void Curl_ssh_version(char *buffer, size_t buflen)
   (void)msnprintf(buffer, buflen, "libssh/%s", ssh_version(0));
 }
 
+#if defined(__GNUC__) &&                        \
+  (LIBSSH_VERSION_MINOR >= 10) ||               \
+  (LIBSSH_VERSION_MAJOR > 0)
+#pragma GCC diagnostic pop
+#endif
+
 #endif                          /* USE_LIBSSH */
index 5ec7d9e50198156f662135ee390c02c764b7dcc3..4122623dd9c6324b329f4d62850e003d9e7fd53e 100644 (file)
@@ -46,6 +46,7 @@
 #endif /* __clang__ */
 
 #ifdef __GNUC__
+#pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Waddress"
 #pragma GCC diagnostic ignored "-Wundef"
 #endif
@@ -3500,6 +3501,10 @@ const struct Curl_ssl Curl_ssl_sectransp = {
   sectransp_send,                     /* send data to encrypt */
 };
 
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
+
 #ifdef __clang__
 #pragma clang diagnostic pop
 #endif
index 2f132e2d29c52453257b94f774704ff6c920eb82..66b1df7465b0eb24faa26297d95f77f126c8d5e2 100644 (file)
@@ -220,6 +220,7 @@ static void main_free(struct GlobalConfig *config)
 #ifdef _UNICODE
 #if defined(__GNUC__)
 /* GCC doesn't know about wmain() */
+#pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wmissing-prototypes"
 #pragma GCC diagnostic ignored "-Wmissing-declarations"
 #endif
@@ -287,4 +288,10 @@ int main(int argc, char *argv[])
 #endif
 }
 
+#ifdef _UNICODE
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
+#endif
+
 #endif /* ndef UNITTESTS */
index eff56677208222023c5fd12a5950f8c9ef99ac42..0544bcc938d9d20ace4cdce5f3295116454a81d5 100644 (file)
@@ -47,6 +47,7 @@ static CURLcode unit_stop(void)
 }
 
 #ifdef __GNUC__
+#pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Woverlength-strings"
 #endif
 
@@ -161,6 +162,10 @@ UNITTEST_START
   }
 UNITTEST_STOP
 
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif
+
 #else
 static CURLcode unit_setup(void)
 {