Implement multiple kind of workarounds for GCC 12

as it produces more false warnings

Include missing header in C++ mode
This commit is contained in:
Patrick Pelissier committed 2022-12-22 20:42:20 +01:00
1 parent 9da0d1d94b
commit f5bbc0a7fb
4 files changed
+16 -3

No files matched your search

+9 -1
View File
@@ -181,10 +181,18 @@
#elif defined(__GNUC__)
#if __GNUC__ >= 12
/* Warnings disabled for GNU C in C mode (Wstringop-overflow produces false warnings) */
#define M_BEGIN_PROTECTED_CODE \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"") \
_Pragma("GCC diagnostic ignored \"-Wstringop-overflow\"")
#else
/* Warnings disabled for GNU C in C mode */
#define M_BEGIN_PROTECTED_CODE \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"")
#endif
#define M_END_PROTECTED_CODE \
_Pragma("GCC diagnostic pop")
@@ -2771,7 +2779,7 @@ namespace m_lib {
#define M_CSTR(...) \
(m_lib::m_char_array<M_USE_CSTR_ALLOC>(__VA_ARGS__)).m_get()
#elif defined(__GNUC__) && !defined(M_ADDRESS_SANITIZER)
#elif defined(__GNUC__) && !defined(M_ADDRESS_SANITIZER) && __GNUC__ < 12
/* Return a constant string constructed based on the printf-liked formated string
and its arguments.
+3 -1
View File
@@ -310,7 +310,9 @@
) \
) \
{ \
struct M_C(name, _s) *self = (struct M_C(name, _s) *)(void*)_self; \
/* Let's go through an uintptr_t to avoid [broken] aliasing detection by compiler */ \
uintptr_t __self = (uintptr_t) _self; \
struct M_C(name, _s) *self = (struct M_C(name, _s) *)(void*)__self; \
(void) self; /* maybe unused */ \
callback_core; \
} \
+2 -1
View File
@@ -1632,7 +1632,8 @@ m_str1ng_utf8_decode(char c, m_str1ng_utf8_state_e *state,
const unsigned int type = m_core_clz32((unsigned char)~c) - (unsigned) (sizeof(uint32_t) - 1) * CHAR_BIT;
const m_string_unicode_t mask1 = (UINT32_MAX - (m_string_unicode_t)(*state != M_STR1NG_UTF8_STARTING) + 1);
const m_string_unicode_t mask2 = (0xFFU >> type);
*unicode = ((*unicode << 6) & mask1) | ((unsigned int) c & mask2);
const m_string_unicode_t c1 = (m_string_unicode_t) c;
*unicode = ((*unicode << 6) & mask1) | (c1 & mask2);
*state = (m_str1ng_utf8_state_e) M_STR1NG_UTF8_STATE_TAB[(unsigned int) *state + type];
}
+2
View File
@@ -449,6 +449,8 @@ static void test_double(void)
/* For this, we need new placement support */
#include <new>
/* For std::move */
#include <utility>
/* Some Simple Oplist for a C++ class (using new placement feature)
Some features may not be always available (like comparison or I/O).