Skip to content

Commit 70ad6c1

Browse files
authored
Add support for suppressing -Wcomma (#3154)
Also rework warnings.h to group by warning rather than compiler.
1 parent df06ad9 commit 70ad6c1

File tree

1 file changed

+21
-19
lines changed
  • Firestore/core/src/firebase/firestore/util

1 file changed

+21
-19
lines changed

Firestore/core/src/firebase/firestore/util/warnings.h

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,48 +42,50 @@
4242

4343
#define SUPPRESS_BEGIN_(name) _Pragma("GCC diagnostic push") _Pragma(name)
4444

45+
#define SUPPRESS_END() _Pragma("GCC diagnostic pop")
46+
4547
#elif defined(_MSC_VER)
4648
#define SUPPRESS_BEGIN_UNIMPLEMENTED_() __pragma(warning(push))
4749

4850
#define SUPPRESS_BEGIN_(name) \
4951
__pragma(warning(push)) __pragma(warning(disable : name))
5052

53+
#define SUPPRESS_END() __pragma(warning(pop))
54+
55+
#else
56+
#define SUPPRESS_BEGIN_UNIMPLEMENTED_()
57+
#define SUPPRESS_END()
5158
#endif
5259

5360
// 'Public' macros.
5461

62+
// Ignore -Wcomma warnings in Clang
63+
#if defined(__clang__)
64+
#define SUPPRESS_COMMA_WARNINGS_BEGIN() \
65+
SUPPRESS_BEGIN_("GCC diagnostic ignored \"-Wcomma\"")
66+
#else
67+
#define SUPPRESS_COMMA_WARNINGS_BEGIN() SUPPRESS_BEGIN_UNIMPLEMENTED_()
68+
#endif
69+
70+
// Ignore -Wdocumentation warnings in Clang
5571
#if defined(__clang__)
5672
#define SUPPRESS_DOCUMENTATION_WARNINGS_BEGIN() \
5773
SUPPRESS_BEGIN_("GCC diagnostic ignored \"-Wdocumentation\"")
58-
59-
#define SUPPRESS_DEPRECATED_DECLARATIONS_BEGIN() \
60-
SUPPRESS_BEGIN_("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
61-
62-
#define SUPPRESS_END() _Pragma("GCC diagnostic pop")
63-
64-
#elif defined(__GNUC__)
74+
#else
6575
#define SUPPRESS_DOCUMENTATION_WARNINGS_BEGIN() SUPPRESS_BEGIN_UNIMPLEMENTED_()
76+
#endif
6677

78+
// Ignore the use of deprecated declarations.
79+
#if defined(__clang__) || defined(__GNUC__)
6780
#define SUPPRESS_DEPRECATED_DECLARATIONS_BEGIN() \
6881
SUPPRESS_BEGIN_("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
69-
70-
#define SUPPRESS_END() _Pragma("GCC diagnostic pop")
71-
7282
#elif defined(_MSC_VER)
7383
// MSVC compiler warnings can be found here: (Look at the navbar on the left
7484
// and select the appropriate range):
7585
// https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warnings-by-compiler-version?view=vs-2017
76-
#define SUPPRESS_DOCUMENTATION_WARNINGS_BEGIN() SUPPRESS_BEGIN_UNIMPLEMENTED_()
77-
7886
#define SUPPRESS_DEPRECATED_DECLARATIONS_BEGIN() SUPPRESS_BEGIN_(4995)
79-
80-
#define SUPPRESS_END() __pragma(warning(pop))
81-
8287
#else
83-
#define SUPPRESS_DOCUMENTATION_WARNINGS_BEGIN()
84-
#define SUPPRESS_DEPRECATED_DECLARATIONS_BEGIN()
85-
#define SUPPRESS_END()
86-
88+
#define SUPPRESS_DEPRECATED_DECLARATIONS_BEGIN() SUPPRESS_BEGIN_UNIMPLEMENTED_()
8789
#endif
8890

8991
#endif // FIRESTORE_CORE_SRC_FIREBASE_FIRESTORE_UTIL_WARNINGS_H_

0 commit comments

Comments
 (0)