@@ -36,17 +36,18 @@ enum {
36
36
BSON_IF_GNU_LIKE (_Pragma ("GCC diagnostic ignored \"-Wshadow\"" ))
37
37
#endif
38
38
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 \
44
45
((void) 0)
45
46
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 \
50
51
((void) 0)
51
52
52
53
/**
@@ -58,9 +59,12 @@ BSON_IF_GNU_LIKE (_Pragma ("GCC diagnostic ignored \"-Wshadow\""))
58
59
_bsonDSL_begin ("bsonParse(%s)", _bsonDSL_str (Document)); \
59
60
_bsonDSL_disableWarnings (); \
60
61
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; \
64
68
_bsonDSL_eval (_bsonParse ((Document), __VA_ARGS__)); \
65
69
_bsonDSL_restoreWarnings (); \
66
70
_bsonDSL_end
@@ -71,7 +75,8 @@ BSON_IF_GNU_LIKE (_Pragma ("GCC diagnostic ignored \"-Wshadow\""))
71
75
#define bsonVisitEach (Document , ...) \
72
76
_bsonDSL_begin ("bsonVisitEach(%s)", _bsonDSL_str (Document)); \
73
77
_bsonDSL_disableWarnings (); \
74
- BSON_MAYBE_UNUSED bool _bvHalt = false; \
78
+ bool _bvHalt = false; \
79
+ (void) _bvHalt; \
75
80
_bsonDSL_eval (_bsonVisitEach ((Document), __VA_ARGS__)); \
76
81
_bsonDSL_restoreWarnings (); \
77
82
_bsonDSL_end
@@ -516,7 +521,8 @@ BSON_IF_GNU_LIKE (_Pragma ("GCC diagnostic ignored \"-Wshadow\""))
516
521
517
522
#define _bsonVisitOperation_case (...) \
518
523
_bsonDSL_begin ("case:%s", ""); \
519
- BSON_MAYBE_UNUSED bool _bvCaseMatched = false; \
524
+ bool _bvCaseMatched = false; \
525
+ (void) _bvCaseMatched; \
520
526
_bsonDSL_mapMacro (_bsonVisitCase, ~, __VA_ARGS__); \
521
527
_bsonDSL_end
522
528
@@ -544,8 +550,10 @@ BSON_IF_GNU_LIKE (_Pragma ("GCC diagnostic ignored \"-Wshadow\""))
544
550
if (!bson_iter_init (& _bvCtx .iter , & (Doc ))) { \
545
551
bsonParseError = "Invalid BSON data [a]" ; \
546
552
} \
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 ; \
549
557
while (bson_iter_next (& _bvCtx .iter ) && !_bvHalt && !bsonParseError && !_bvBreak ) { \
550
558
_bvContinue = false; \
551
559
_bsonVisit_applyOps (__VA_ARGS__ ); \
@@ -622,19 +630,23 @@ BSON_IF_GNU_LIKE (_Pragma ("GCC diagnostic ignored \"-Wshadow\""))
622
630
} \
623
631
} while (0);
624
632
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
+ } \
638
650
} while (0 )
639
651
640
652
#define _bsonParse_applyOps (...) _bsonDSL_mapMacro (_bsonParse_applyOp, ~, __VA_ARGS__)
0 commit comments