aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--epan/diam_dict.l21
-rw-r--r--epan/dtd_parse.l16
-rw-r--r--epan/uat_load.l6
-rw-r--r--plugins/epan/wimaxasncp/wimaxasncp_dict.l21
-rw-r--r--text2pcap-scanner.l7
-rw-r--r--ui/text_import_scanner.l7
-rw-r--r--wiretap/ascend_scanner.l12
-rw-r--r--wiretap/k12text.l10
-rw-r--r--ws_diag_control.h44
9 files changed, 96 insertions, 48 deletions
diff --git a/epan/diam_dict.l b/epan/diam_dict.l
index 5d1a31e39d..44e9d910d1 100644
--- a/epan/diam_dict.l
+++ b/epan/diam_dict.l
@@ -1,12 +1,6 @@
%top {
/* Include this before everything else, for various large-file definitions */
#include "config.h"
-
-// warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable : 4267)
-#endif
}
/*
@@ -106,7 +100,10 @@
#include <epan/to_str.h>
#include <wsutil/file_util.h>
-DIAG_OFF(sign-compare)
+/*
+ * Disable diagnostics in the code generated by Flex.
+ */
+DIAG_OFF_FLEX
typedef struct entity_t {
char* name;
@@ -626,14 +623,12 @@ description_attr description=\042
<OUTSIDE>. ;
-
-
-
-
-
%%
-DIAG_ON(sign-compare)
+/*
+ * Turn diagnostics back on, so we check the code that we've written.
+ */
+DIAG_ON_FLEX
static int debugging = 0;
diff --git a/epan/dtd_parse.l b/epan/dtd_parse.l
index 158a1f0c4f..e9bc00ed97 100644
--- a/epan/dtd_parse.l
+++ b/epan/dtd_parse.l
@@ -1,12 +1,6 @@
%top {
/* Include this before everything else, for various large-file definitions */
#include "config.h"
-
-// warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable : 4267)
-#endif
}
/*
@@ -94,7 +88,10 @@
#include "dtd_grammar.h"
#include "dtd_parse.h"
-DIAG_OFF(sign-compare)
+/*
+ * Disable diagnostics in the code generated by Flex.
+ */
+DIAG_OFF_FLEX
struct _proto_xmlpi_attr {
const gchar* name;
@@ -352,7 +349,10 @@ squoted ['][^\']*[']
%%
-DIAG_ON(sign-compare)
+/*
+ * Turn diagnostics back on, so we check the code that we've written.
+ */
+DIAG_ON_FLEX
static dtd_token_data_t* new_token(gchar* text, gchar* location) {
dtd_token_data_t* t = g_new(dtd_token_data_t,1);
diff --git a/epan/uat_load.l b/epan/uat_load.l
index d645d0b4dc..981a362139 100644
--- a/epan/uat_load.l
+++ b/epan/uat_load.l
@@ -1,12 +1,6 @@
%top {
/* Include this before everything else, for various large-file definitions */
#include "config.h"
-
-// warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable : 4267)
-#endif
}
/*
diff --git a/plugins/epan/wimaxasncp/wimaxasncp_dict.l b/plugins/epan/wimaxasncp/wimaxasncp_dict.l
index dab2836a93..3dc4dbf887 100644
--- a/plugins/epan/wimaxasncp/wimaxasncp_dict.l
+++ b/plugins/epan/wimaxasncp/wimaxasncp_dict.l
@@ -1,12 +1,6 @@
%top {
/* Include this before everything else, for various large-file definitions */
#include "config.h"
-
-// warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable : 4267)
-#endif
}
/*
@@ -106,7 +100,10 @@
#include "wimaxasncp_dict.h"
-DIAG_OFF(sign-compare)
+/*
+ * Disable diagnostics in the code generated by Flex.
+ */
+DIAG_OFF_FLEX
typedef struct entity_t {
gchar *name;
@@ -514,14 +511,12 @@ since_attr since=\042
<OUTSIDE>. ;
-
-
-
-
-
%%
-DIAG_ON(sign-compare)
+/*
+ * Turn diagnostics back on, so we check the code that we've written.
+ */
+DIAG_ON_FLEX
static int debugging = 0;
diff --git a/text2pcap-scanner.l b/text2pcap-scanner.l
index b4024b162d..c233999d4d 100644
--- a/text2pcap-scanner.l
+++ b/text2pcap-scanner.l
@@ -106,3 +106,10 @@ eol \r?\n\r?
if (parse_token(T_EOL, NULL) != EXIT_SUCCESS) return EXIT_FAILURE; }
{comment} { if (parse_token(T_EOL, NULL) != EXIT_SUCCESS) return EXIT_FAILURE; }
{text} { if (parse_token(T_TEXT, yytext) != EXIT_SUCCESS) return EXIT_FAILURE; }
+
+%%
+
+/*
+ * Turn diagnostics back on, so we check the code that we've written.
+ */
+DIAG_ON_FLEX
diff --git a/ui/text_import_scanner.l b/ui/text_import_scanner.l
index 5e7d65048e..70255e6f77 100644
--- a/ui/text_import_scanner.l
+++ b/ui/text_import_scanner.l
@@ -135,3 +135,10 @@ eol \r?\n\r?
{text} { parse_token(T_TEXT, yytext); }
<<EOF>> { write_current_packet(); yyterminate(); }
+
+%%
+
+/*
+ * Turn diagnostics back on, so we check the code that we've written.
+ */
+DIAG_ON_FLEX
diff --git a/wiretap/ascend_scanner.l b/wiretap/ascend_scanner.l
index 0fb90184da..133f0dfc5a 100644
--- a/wiretap/ascend_scanner.l
+++ b/wiretap/ascend_scanner.l
@@ -65,7 +65,10 @@
#include "ascend.h"
#include "file_wrappers.h"
-DIAG_OFF(sign-compare)
+/*
+ * Disable diagnostics in the code generated by Flex.
+ */
+DIAG_OFF_FLEX
#define YY_INPUT(buf,result,max_size) { \
ascend_state_t *parser_state = ascendget_extra(yyscanner); \
@@ -372,3 +375,10 @@ task:|task|at|time:|octets { return KEYWORD; }
<<EOF>> { yyterminate(); }
(.|\n) ;
+
+%%
+
+/*
+ * Turn diagnostics back on, so we check the code that we've written.
+ */
+DIAG_ON_FLEX
diff --git a/wiretap/k12text.l b/wiretap/k12text.l
index 5451b5eff8..be5d51379f 100644
--- a/wiretap/k12text.l
+++ b/wiretap/k12text.l
@@ -101,7 +101,10 @@
#define YY_NO_UNISTD_H
#endif
-DIAG_OFF(sign-compare)
+/*
+ * Disable diagnostics in the code generated by Flex.
+ */
+DIAG_OFF_FLEX
/*
* State kept by the scanner.
@@ -233,7 +236,10 @@ hdlc HDLC
%%
-DIAG_ON(sign-compare)
+/*
+ * Turn diagnostics back on, so we check the code that we've written.
+ */
+DIAG_ON_FLEX
/* Fill in pkthdr */
diff --git a/ws_diag_control.h b/ws_diag_control.h
index 155c143077..e3ee28ed9c 100644
--- a/ws_diag_control.h
+++ b/ws_diag_control.h
@@ -100,15 +100,49 @@ extern "C" {
* generated by that version of Flex triggers?
*/
#if defined(_MSC_VER)
+ /*
+ * Suppress:
+ *
+ * warning C4018: signed/unsigned mismatch
+ * warning C4267: 'argument' : conversion from 'size_t' to 'int', possible loss of data
+ */
#define DIAG_OFF_FLEX \
__pragma(warning(push)) \
- __pragma(warning(disable:4018))
+ __pragma(warning(disable:4018)) \
+ __pragma(warning(disable:4267))
#define DIAG_ON_FLEX __pragma(warning(pop))
#else
- #define DIAG_OFF_FLEX \
- DIAG_OFF(sign-compare)
- #define DIAG_ON_FLEX \
- DIAG_ON(sign-compare)
+ /*
+ * Suppress:
+ *
+ * -Wsigned-compare warnings
+ * -Wshorten-64-to-32 warnings, if the compiler *has* -Wshorten-64-to-32
+ *
+ * We use DIAG_OFF() and DIAG_ON(), so we only use features that the
+ * compiler supports.
+ *
+ * We disable -Wshorten-64-to-32 if we're using Clang, or if __APPLE__
+ * is defined; that option was originally added to an Apple version of
+ * GCC, and at least some versions of Clang support it - given that
+ * the Clang work started at Apple, it may be in all versions of Clang.
+ *
+ * (Does no version of GCC or Clang support the same generic "you're
+ * narrowing a value, and you didn't throw in a cast to assert that
+ * you know what you're doing" warning that MSVC does?)
+ */
+ #if defined(__clang__) || defined(__APPLE__)
+ #define DIAG_OFF_FLEX \
+ DIAG_OFF(sign-compare) \
+ DIAG_OFF(shorten-64-to-32)
+ #define DIAG_ON_FLEX \
+ DIAG_ON(shorten-64-to-32) \
+ DIAG_ON(sign-compare)
+ #else
+ #define DIAG_OFF_FLEX \
+ DIAG_OFF(sign-compare)
+ #define DIAG_ON_FLEX \
+ DIAG_ON(sign-compare)
+ #endif
#endif
/*