diff --git a/epan/dfilter/grammar.lemon b/epan/dfilter/grammar.lemon index 3815587c57..d6caa0d927 100644 --- a/epan/dfilter/grammar.lemon +++ b/epan/dfilter/grammar.lemon @@ -15,9 +15,6 @@ #include "grammar.h" -/* Generated lemon code warns on this. */ -DIAG_OFF(unreachable-code) - #ifdef _WIN32 #pragma warning(disable:4671) #endif @@ -27,7 +24,11 @@ new_function(dfwork_t *dfw, stnode_t *node); #define FAIL(dfw, node, ...) dfilter_fail(dfw, stnode_location(node), __VA_ARGS__) -/* End of C code */ +DIAG_OFF_LEMON() +} /* end of %include */ + +%code { +DIAG_ON_LEMON() } /* Parser Information */ diff --git a/epan/dfilter/scanner.l b/epan/dfilter/scanner.l index e1d428c032..b90f1a28b3 100644 --- a/epan/dfilter/scanner.l +++ b/epan/dfilter/scanner.l @@ -75,7 +75,7 @@ /* * Disable diagnostics in the code generated by Flex. */ -DIAG_OFF_FLEX +DIAG_OFF_FLEX() stnode_t *df_lval; @@ -475,7 +475,7 @@ hyphen-bytes {hex2}(-{hex2})+ /* * Turn diagnostics back on, so we check the code that we've written. */ -DIAG_ON_FLEX +DIAG_ON_FLEX() static void _update_location(df_scanner_state_t *state, size_t len) diff --git a/epan/diam_dict.l b/epan/diam_dict.l index afb5edb002..8506ade177 100644 --- a/epan/diam_dict.l +++ b/epan/diam_dict.l @@ -104,7 +104,7 @@ /* * Disable diagnostics in the code generated by Flex. */ -DIAG_OFF_FLEX +DIAG_OFF_FLEX() typedef struct entity_t { char* name; @@ -630,7 +630,7 @@ description_attr description=\042 /* * Turn diagnostics back on, so we check the code that we've written. */ -DIAG_ON_FLEX +DIAG_ON_FLEX() static int debugging = 0; diff --git a/epan/dtd_grammar.lemon b/epan/dtd_grammar.lemon index 58f9c7ff0c..253da126cb 100644 --- a/epan/dtd_grammar.lemon +++ b/epan/dtd_grammar.lemon @@ -22,9 +22,6 @@ #include "dtd.h" #include "dtd_parse.h" -/* Generated lemon code warns on this. */ -DIAG_OFF(unreachable-code) - static dtd_named_list_t* dtd_named_list_new(gchar* name, GPtrArray* list) { dtd_named_list_t* nl = g_new(dtd_named_list_t,1); @@ -45,6 +42,11 @@ static GPtrArray* g_ptr_array_join(GPtrArray* a, GPtrArray* b){ return a; } +DIAG_OFF_LEMON() +} /* end of %include */ + +%code { +DIAG_ON_LEMON() } %name DtdParse diff --git a/epan/dtd_parse.l b/epan/dtd_parse.l index f8da374c44..9d7677d8bf 100644 --- a/epan/dtd_parse.l +++ b/epan/dtd_parse.l @@ -92,7 +92,7 @@ /* * Disable diagnostics in the code generated by Flex. */ -DIAG_OFF_FLEX +DIAG_OFF_FLEX() struct _proto_xmlpi_attr { const gchar* name; @@ -353,7 +353,7 @@ squoted ['][^\']*['] /* * Turn diagnostics back on, so we check the code that we've written. */ -DIAG_ON_FLEX +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/dtd_preparse.l b/epan/dtd_preparse.l index 5a01c6977a..ff8ab141c1 100644 --- a/epan/dtd_preparse.l +++ b/epan/dtd_preparse.l @@ -101,7 +101,7 @@ /* * Disable diagnostics in the code generated by Flex. */ -DIAG_OFF_FLEX +DIAG_OFF_FLEX() #define ECHO g_string_append(yyextra->current,yytext); @@ -213,7 +213,7 @@ newline \n /* * Turn diagnostics back on, so we check the code that we've written. */ -DIAG_ON_FLEX +DIAG_ON_FLEX() static const gchar* replace_entity(Dtd_PreParse_scanner_state_t* state, gchar* entity) { GString* replacement; diff --git a/epan/protobuf_lang_parser.lemon b/epan/protobuf_lang_parser.lemon index 11034febff..820b99f340 100644 --- a/epan/protobuf_lang_parser.lemon +++ b/epan/protobuf_lang_parser.lemon @@ -30,9 +30,6 @@ #include "protobuf_lang_parser.h" #include "protobuf_lang_scanner_lex.h" -/* Generated lemon code warns on this. */ -DIAG_OFF(unreachable-code) - #define NAME_TO_BE_SET "" #define NEED_NOT_NAME "" @@ -51,8 +48,13 @@ void pbl_parser_error(protobuf_lang_state_t *state, const char *fmt, ...); pbl_set_node_name() later. */ #define CUR_LINENO (protobuf_lang_get_lineno(state->scanner)) +DIAG_OFF_LEMON() } /* end of %include */ +%code { +DIAG_ON_LEMON() +} + %name ProtobufLangParser %extra_argument { protobuf_lang_state_t *state } diff --git a/epan/protobuf_lang_scanner.l b/epan/protobuf_lang_scanner.l index 187ba06839..335d960397 100644 --- a/epan/protobuf_lang_scanner.l +++ b/epan/protobuf_lang_scanner.l @@ -64,7 +64,7 @@ /* * Disable diagnostics in the code generated by Flex. */ -DIAG_OFF_FLEX +DIAG_OFF_FLEX() /* * Sleazy hack to suppress compiler warnings in yy_fatal_error(). @@ -191,4 +191,4 @@ strdup_and_store(void* yyscanner, const char* text) { /* * Turn diagnostics back on, so we check the code that we've written. */ -DIAG_ON_FLEX +DIAG_ON_FLEX() diff --git a/epan/radius_dict.l b/epan/radius_dict.l index 97a0d3aa50..c8c1825c13 100644 --- a/epan/radius_dict.l +++ b/epan/radius_dict.l @@ -96,7 +96,7 @@ /* * Disable diagnostics in the code generated by Flex. */ -DIAG_OFF_FLEX +DIAG_OFF_FLEX() /* * See @@ -413,7 +413,7 @@ static void add_value(Radius_scanner_state_t* state, const gchar* attrib_name, c /* * Turn diagnostics back on, so we check the code that we've written. */ -DIAG_ON_FLEX +DIAG_ON_FLEX() static void add_vendor(Radius_scanner_state_t* state, const gchar* name, guint32 id, guint type_octets, guint length_octets, gboolean has_flags) { radius_vendor_info_t* v; diff --git a/epan/uat_load.l b/epan/uat_load.l index c9d0bcfe5e..06ab49ee23 100644 --- a/epan/uat_load.l +++ b/epan/uat_load.l @@ -98,7 +98,7 @@ /* * Disable diagnostics in the code generated by Flex. */ -DIAG_OFF_FLEX +DIAG_OFF_FLEX() typedef struct { uat_t* uat; @@ -391,7 +391,7 @@ comment #[^\n]*\n /* * Turn diagnostics back on, so we check the code that we've written. */ -DIAG_ON_FLEX +DIAG_ON_FLEX() gboolean uat_load(uat_t *uat, const gchar *filename, char **errx) diff --git a/include/ws_diag_control.h b/include/ws_diag_control.h index a1ca422694..c4f7500633 100644 --- a/include/ws_diag_control.h +++ b/include/ws_diag_control.h @@ -164,7 +164,7 @@ extern "C" { * warning C6387: 'XXX' could be '0' * warning C28182: Dereferencing NULL pointer */ - #define DIAG_OFF_FLEX \ + #define DIAG_OFF_FLEX() \ __pragma(warning(push)) \ __pragma(warning(disable:4018)) \ __pragma(warning(disable:4244)) \ @@ -174,7 +174,8 @@ extern "C" { __pragma(warning(disable:6386)) \ __pragma(warning(disable:6387)) \ __pragma(warning(disable:28182)) - #define DIAG_ON_FLEX __pragma(warning(pop)) + #define DIAG_ON_FLEX() \ + __pragma(warning(pop)) #else /* * Suppress: @@ -198,24 +199,35 @@ extern "C" { * you know what you're doing" warning that MSVC does?) */ #if defined(__clang__) || defined(__APPLE__) - #define DIAG_OFF_FLEX \ + #define DIAG_OFF_FLEX() \ DIAG_OFF(sign-compare) \ DIAG_OFF(shorten-64-to-32) \ DIAG_OFF(unreachable-code) \ DIAG_OFF(documentation) - #define DIAG_ON_FLEX \ + #define DIAG_ON_FLEX() \ DIAG_ON(documentation) \ DIAG_ON(unreachable-code) \ DIAG_ON(shorten-64-to-32) \ DIAG_ON(sign-compare) #else - #define DIAG_OFF_FLEX \ + #define DIAG_OFF_FLEX() \ DIAG_OFF(sign-compare) - #define DIAG_ON_FLEX \ + #define DIAG_ON_FLEX() \ DIAG_ON(sign-compare) #endif #endif +/* Disable Lemon warnings. */ +#if defined(_MSC_VER) + #define DIAG_OFF_LEMON() + #define DIAG_ON_LEMON() +#else + #define DIAG_OFF_LEMON() \ + DIAG_OFF_CLANG(unreachable-code) + #define DIAG_ON_LEMON() \ + DIAG_ON_CLANG(unreachable-code) +#endif + /* * Suppress warnings about casting away constness. * Do this only if you know that the pointer is to something that can diff --git a/plugins/epan/mate/mate_grammar.lemon b/plugins/epan/mate/mate_grammar.lemon index 802c6b8dab..be66915928 100644 --- a/plugins/epan/mate/mate_grammar.lemon +++ b/plugins/epan/mate/mate_grammar.lemon @@ -26,9 +26,6 @@ #include #include -/* Generated lemon code warns on this. */ -DIAG_OFF(unreachable-code) - #define DUMMY void* typedef struct _extraction { @@ -171,6 +168,11 @@ static gchar* recolonize(mate_config* mc, gchar* s) { return r; } +DIAG_OFF_LEMON() +} /* end of %include */ + +%code { +DIAG_ON_LEMON() } %name MateParser diff --git a/plugins/epan/mate/mate_parser.l b/plugins/epan/mate/mate_parser.l index ad08c9ea7a..6e423abccd 100644 --- a/plugins/epan/mate/mate_parser.l +++ b/plugins/epan/mate/mate_parser.l @@ -87,7 +87,7 @@ /* * Disable diagnostics in the code generated by Flex. */ -DIAG_OFF_FLEX +DIAG_OFF_FLEX() void MateParseTrace(FILE*,char*); @@ -337,7 +337,7 @@ blk_cmnt_stop "*/" /* * Turn diagnostics back on, so we check the code that we've written. */ -DIAG_ON_FLEX +DIAG_ON_FLEX() static void ptr_array_free(gpointer data, gpointer user_data _U_) { diff --git a/plugins/epan/wimaxasncp/wimaxasncp_dict.l b/plugins/epan/wimaxasncp/wimaxasncp_dict.l index 3b42207e5e..05fa2e51eb 100644 --- a/plugins/epan/wimaxasncp/wimaxasncp_dict.l +++ b/plugins/epan/wimaxasncp/wimaxasncp_dict.l @@ -104,7 +104,7 @@ /* * Disable diagnostics in the code generated by Flex. */ -DIAG_OFF_FLEX +DIAG_OFF_FLEX() typedef struct entity_t { gchar *name; @@ -517,7 +517,7 @@ since_attr since=\042 /* * Turn diagnostics back on, so we check the code that we've written. */ -DIAG_ON_FLEX +DIAG_ON_FLEX() static int debugging = 0; diff --git a/ui/text_import_scanner.l b/ui/text_import_scanner.l index 3918252a37..5dd466cb10 100644 --- a/ui/text_import_scanner.l +++ b/ui/text_import_scanner.l @@ -76,7 +76,7 @@ /* * Disable diagnostics in the code generated by Flex. */ -DIAG_OFF_FLEX +DIAG_OFF_FLEX() /* * Flex (v 2.5.35) uses this symbol to "exclude" unistd.h @@ -132,7 +132,7 @@ eol \r?\n\r? /* * Turn diagnostics back on, so we check the code that we've written. */ -DIAG_ON_FLEX +DIAG_ON_FLEX() import_status_t text_import_scan(FILE *input_file) diff --git a/wiretap/ascend_parser.lemon b/wiretap/ascend_parser.lemon index f9192f210a..89df92680f 100644 --- a/wiretap/ascend_parser.lemon +++ b/wiretap/ascend_parser.lemon @@ -140,10 +140,12 @@ static void AscendParserFree(void *p, void (*freeProc)(void*)); #define ascend_debug(...) #endif -/* Generated lemon code warns on this. */ -DIAG_OFF(unreachable-code) +DIAG_OFF_LEMON() +} /* end of %include */ -} // %include +%code { +DIAG_ON_LEMON() +} %name AscendParser diff --git a/wiretap/ascend_scanner.l b/wiretap/ascend_scanner.l index 9b42fcf8e3..f6fe4032f0 100644 --- a/wiretap/ascend_scanner.l +++ b/wiretap/ascend_scanner.l @@ -64,7 +64,7 @@ /* * Disable diagnostics in the code generated by Flex. */ -DIAG_OFF_FLEX +DIAG_OFF_FLEX() static int ascend_yyinput(void *buf, ascend_state_t *parser_state) { int c = file_getc(parser_state->fh); @@ -406,4 +406,4 @@ task:|task|at|time:|octets { return KEYWORD; } /* * Turn diagnostics back on, so we check the code that we've written. */ -DIAG_ON_FLEX +DIAG_ON_FLEX() diff --git a/wiretap/busmaster_parser.lemon b/wiretap/busmaster_parser.lemon index 3e346bfb7a..ce62aada88 100644 --- a/wiretap/busmaster_parser.lemon +++ b/wiretap/busmaster_parser.lemon @@ -34,8 +34,11 @@ static void merge_msg_data(msg_data_t *dst, const msg_data_t *a, const msg_data_ memcpy(&dst->data[a->length], &b->data[0], b->length); } -DIAG_OFF(unreachable-code) +DIAG_OFF_LEMON() +} /* end of %include */ +%code { +DIAG_ON_LEMON() } %name BusmasterParser @@ -369,8 +372,6 @@ data64(R) ::= data32(A) data32(B) . { merge_msg_data(&R, &A, &B); } %code { -DIAG_ON(unreachable-code) - #include "busmaster_scanner_lex.h" #include "busmaster_parser.h" diff --git a/wiretap/busmaster_scanner.l b/wiretap/busmaster_scanner.l index 419b9b3b92..eeaa88f563 100644 --- a/wiretap/busmaster_scanner.l +++ b/wiretap/busmaster_scanner.l @@ -86,7 +86,7 @@ static int busmaster_yyinput(void *buf, unsigned int length, busmaster_state_t * #define busmaster_realloc(ptr, size, yyscanner) (void *)realloc((char *)(ptr), (size)) #define busmaster_free(ptr, yyscanner) free((char *)(ptr)) -DIAG_OFF_FLEX +DIAG_OFF_FLEX() %} @@ -196,4 +196,4 @@ NUM (0x)?[0-9A-Fa-f]+ %% -DIAG_ON_FLEX +DIAG_ON_FLEX() diff --git a/wiretap/candump_parser.lemon b/wiretap/candump_parser.lemon index 3fd659cc05..149c3a7dfa 100644 --- a/wiretap/candump_parser.lemon +++ b/wiretap/candump_parser.lemon @@ -34,8 +34,11 @@ static void merge_msg_data(msg_data_t *dst, const msg_data_t *a, const msg_data_ memcpy(&dst->data[a->length], &b->data[0], b->length); } -DIAG_OFF(unreachable-code) +DIAG_OFF_LEMON() +} /* end of %include */ +%code { +DIAG_ON_LEMON() } %name CandumpParser @@ -268,8 +271,6 @@ data64(R) ::= data32(A) data32(B) . { merge_msg_data(&R, &A, &B); } %code { -DIAG_ON(unreachable-code) - #include "candump_scanner_lex.h" #include "candump_parser.h" diff --git a/wiretap/candump_scanner.l b/wiretap/candump_scanner.l index bc1cdb38a2..c43c5349c2 100644 --- a/wiretap/candump_scanner.l +++ b/wiretap/candump_scanner.l @@ -89,7 +89,7 @@ static int candump_yyinput(void *buf, candump_state_t *state) #define candump_realloc(ptr, size, yyscanner) (void *)realloc((char *)(ptr), (size)) #define candump_free(ptr, yyscanner) free((char *)(ptr)) -DIAG_OFF_FLEX +DIAG_OFF_FLEX() %} @@ -141,4 +141,4 @@ R { %% -DIAG_ON_FLEX +DIAG_ON_FLEX() diff --git a/wiretap/k12text.l b/wiretap/k12text.l index 0bf009161c..d996db12cd 100644 --- a/wiretap/k12text.l +++ b/wiretap/k12text.l @@ -106,7 +106,7 @@ /* * Disable diagnostics in the code generated by Flex. */ -DIAG_OFF_FLEX +DIAG_OFF_FLEX() /* * State kept by the scanner. @@ -245,7 +245,7 @@ hdlc HDLC /* * Turn diagnostics back on, so we check the code that we've written. */ -DIAG_ON_FLEX +DIAG_ON_FLEX() /* Fill in pkthdr */