@@ -36,17 +36,18 @@ enum {
3636BSON_IF_GNU_LIKE (_Pragma ("GCC diagnostic ignored \"-Wshadow\"" ))
3737#endif
3838
39- #define _bsonDSL_disableWarnings () \
40- if (1) { \
41- BSON_IF_GNU_LIKE (_Pragma ("GCC diagnostic push");) \
42- BSON_IF_GNU_LIKE (_Pragma ("GCC diagnostic ignored \"-Wshadow\"");) \
43- } else \
39+ #define _bsonDSL_disableWarnings () \
40+ if (1) { \
41+ mlib_diagnostic_push (); \
42+ mlib_gnu_warning_disable ("-Wshadow"); \
43+ mlib_msvc_warning (disable : 4456); \
44+ } else \
4445 ((void) 0)
4546
46- #define _bsonDSL_restoreWarnings () \
47- if (1) { \
48- BSON_IF_GNU_LIKE (_Pragma ("GCC diagnostic pop");) \
49- } else \
47+ #define _bsonDSL_restoreWarnings () \
48+ if (1) { \
49+ mlib_diagnostic_pop (); \
50+ } else \
5051 ((void) 0)
5152
5253/**
@@ -58,9 +59,12 @@ BSON_IF_GNU_LIKE (_Pragma ("GCC diagnostic ignored \"-Wshadow\""))
5859 _bsonDSL_begin ("bsonParse(%s)", _bsonDSL_str (Document)); \
5960 _bsonDSL_disableWarnings (); \
6061 bsonParseError = NULL; \
61- BSON_MAYBE_UNUSED bool _bvHalt = false; \
62- BSON_MAYBE_UNUSED const bool _bvContinue = false; \
63- BSON_MAYBE_UNUSED const bool _bvBreak = false; \
62+ bool _bvHalt = false; \
63+ const bool _bvContinue = false; \
64+ const bool _bvBreak = false; \
65+ (void) _bvHalt; \
66+ (void) _bvContinue; \
67+ (void) _bvBreak; \
6468 _bsonDSL_eval (_bsonParse ((Document), __VA_ARGS__)); \
6569 _bsonDSL_restoreWarnings (); \
6670 _bsonDSL_end
@@ -71,7 +75,8 @@ BSON_IF_GNU_LIKE (_Pragma ("GCC diagnostic ignored \"-Wshadow\""))
7175#define bsonVisitEach (Document , ...) \
7276 _bsonDSL_begin ("bsonVisitEach(%s)", _bsonDSL_str (Document)); \
7377 _bsonDSL_disableWarnings (); \
74- BSON_MAYBE_UNUSED bool _bvHalt = false; \
78+ bool _bvHalt = false; \
79+ (void) _bvHalt; \
7580 _bsonDSL_eval (_bsonVisitEach ((Document), __VA_ARGS__)); \
7681 _bsonDSL_restoreWarnings (); \
7782 _bsonDSL_end
@@ -516,7 +521,8 @@ BSON_IF_GNU_LIKE (_Pragma ("GCC diagnostic ignored \"-Wshadow\""))
516521
517522#define _bsonVisitOperation_case (...) \
518523 _bsonDSL_begin ("case:%s", ""); \
519- BSON_MAYBE_UNUSED bool _bvCaseMatched = false; \
524+ bool _bvCaseMatched = false; \
525+ (void) _bvCaseMatched; \
520526 _bsonDSL_mapMacro (_bsonVisitCase, ~, __VA_ARGS__); \
521527 _bsonDSL_end
522528
@@ -544,8 +550,10 @@ BSON_IF_GNU_LIKE (_Pragma ("GCC diagnostic ignored \"-Wshadow\""))
544550 if (!bson_iter_init (& _bvCtx .iter , & (Doc ))) { \
545551 bsonParseError = "Invalid BSON data [a]" ; \
546552 } \
547- BSON_MAYBE_UNUSED bool _bvBreak = false; \
548- BSON_MAYBE_UNUSED bool _bvContinue = false; \
553+ bool _bvBreak = false; \
554+ bool _bvContinue = false; \
555+ (void ) _bvBreak ; \
556+ (void ) _bvContinue ; \
549557 while (bson_iter_next (& _bvCtx .iter ) && !_bvHalt && !bsonParseError && !_bvBreak ) { \
550558 _bvContinue = false; \
551559 _bsonVisit_applyOps (__VA_ARGS__ ); \
@@ -622,19 +630,23 @@ BSON_IF_GNU_LIKE (_Pragma ("GCC diagnostic ignored \"-Wshadow\""))
622630 } \
623631 } while (0);
624632
625- #define _bsonParse (Doc , ...) \
626- do { \
627- BSON_MAYBE_UNUSED const bson_t *_bpDoc = &(Doc); \
628- /* Keep track of which elements have been visited based on their index*/ \
629- uint64_t _bpVisitBits_static [4 ] = {0 }; \
630- BSON_MAYBE_UNUSED uint64_t * _bpVisitBits = _bpVisitBits_static ; \
631- BSON_MAYBE_UNUSED size_t _bpNumVisitBitInts = sizeof _bpVisitBits_static / sizeof (uint64_t ); \
632- BSON_MAYBE_UNUSED bool _bpFoundElement = false; \
633- _bsonParse_applyOps (__VA_ARGS__ ); \
634- /* We may have allocated for visit bits */ \
635- if (_bpVisitBits != _bpVisitBits_static ) { \
636- bson_free (_bpVisitBits ); \
637- } \
633+ #define _bsonParse (Doc , ...) \
634+ do { \
635+ /* Keep track of which elements have been visited based on their index*/ \
636+ uint64_t _bpVisitBits_static [4 ] = {0 }; \
637+ const bson_t * _bpDoc = & (Doc ); \
638+ uint64_t * _bpVisitBits = _bpVisitBits_static ; \
639+ size_t _bpNumVisitBitInts = sizeof _bpVisitBits_static / sizeof (uint64_t ); \
640+ bool _bpFoundElement = false; \
641+ (void ) _bpDoc ; \
642+ (void ) _bpVisitBits ; \
643+ (void ) _bpNumVisitBitInts ; \
644+ (void ) _bpFoundElement ; \
645+ _bsonParse_applyOps (__VA_ARGS__ ); \
646+ /* We may have allocated for visit bits */ \
647+ if (_bpVisitBits != _bpVisitBits_static ) { \
648+ bson_free (_bpVisitBits ); \
649+ } \
638650 } while (0 )
639651
640652#define _bsonParse_applyOps (...) _bsonDSL_mapMacro (_bsonParse_applyOp, ~, __VA_ARGS__)
0 commit comments