Skip to content

Commit c0a74f8

Browse files
committed
Hinge GCC #pragma diagnostics on version 4.6, not 4.2.
GCC release notes document all GCC diagnostic pragmas as new in GCC 4.6, but this is not entirely true: in GCC 4.4.5 "push" and "pop" are indeed not available, but "error", "warning" and "ignored" are (the warnings stand for DIAG_OFF_DEPRECATION and DIAG_ON_DEPRECATION respectively): tcpdump.c: At top level: tcpdump.c:3451: warning: expected [error|warning|ignored] after '#pragma GCC diagnostic' tcpdump.c:3480: warning: expected [error|warning|ignored] after '#pragma GCC diagnostic' Before commit 39f09d6 in 2021 the code indeed required GCC 4.6 for "push" and "pop" consistently with libpcap, but during the refactoring the requirement erroneously became 4.2, so make it 4.6 again.
1 parent f9f9e3d commit c0a74f8

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

diag-control.h

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
#define DIAG_ON_STRICT_PROTOTYPES \
133133
DIAG_DO_PRAGMA(clang diagnostic pop)
134134
#endif
135-
#elif ND_IS_AT_LEAST_GNUC_VERSION(4,2)
135+
#elif ND_IS_AT_LEAST_GNUC_VERSION(4,6)
136136
/* GCC apparently doesn't complain about ORing enums together. */
137137

138138
/*
@@ -145,21 +145,19 @@
145145
#define DIAG_ON_CAST_QUAL \
146146
DIAG_DO_PRAGMA(GCC diagnostic pop)
147147

148-
#if ND_IS_AT_LEAST_GNUC_VERSION(4,5)
149-
/*
150-
* GCC warns about unused return values if a function is marked as
151-
* "warn about ignoring this function's return value".
152-
*
153-
* Clang appears to let you ignore a result without a warning by
154-
* casting the function result to void, so we don't appear to
155-
* need this for Clang.
156-
*/
157-
#define DIAG_OFF_WARN_UNUSED_RESULT \
158-
DIAG_DO_PRAGMA(GCC diagnostic push) \
159-
DIAG_DO_PRAGMA(GCC diagnostic ignored "-Wunused-result")
160-
#define DIAG_ON_WARN_UNUSED_RESULT \
161-
DIAG_DO_PRAGMA(GCC diagnostic pop)
162-
#endif
148+
/*
149+
* GCC warns about unused return values if a function is marked as
150+
* "warn about ignoring this function's return value".
151+
*
152+
* Clang appears to let you ignore a result without a warning by
153+
* casting the function result to void, so we don't appear to
154+
* need this for Clang.
155+
*/
156+
#define DIAG_OFF_WARN_UNUSED_RESULT \
157+
DIAG_DO_PRAGMA(GCC diagnostic push) \
158+
DIAG_DO_PRAGMA(GCC diagnostic ignored "-Wunused-result")
159+
#define DIAG_ON_WARN_UNUSED_RESULT \
160+
DIAG_DO_PRAGMA(GCC diagnostic pop)
163161

164162
/*
165163
* Suppress deprecation warnings.

0 commit comments

Comments
 (0)