mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
Bug#45288: pb2 returns a lot of compilation warnings
Fix assorted warnings that are generated in optimized builds. Most of it is silencing variables that are set but unused. This patch also introduces the MY_ASSERT_UNREACHABLE macro which helps the compiler to deduce that a certain piece of code is unreachable. include/my_compiler.h: Use GCC's __builtin_unreachable if available. It allows GCC to deduce the unreachability of certain code paths, thus avoiding warnings that, for example, accused that a variable could be used without being initialized (due to unreachable code paths).
This commit is contained in:
@@ -32,8 +32,15 @@
|
||||
|
||||
/* GNU C/C++ */
|
||||
#if defined __GNUC__
|
||||
/* Convenience macro to test the minimum required GCC version. */
|
||||
# define MY_GNUC_PREREQ(maj, min) \
|
||||
((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
|
||||
/* Any after 2.95... */
|
||||
# define MY_ALIGN_EXT
|
||||
/* Comunicate to the compiler the unreachability of the code. */
|
||||
# if MY_GNUC_PREREQ(4,5)
|
||||
# define MY_ASSERT_UNREACHABLE() __builtin_unreachable()
|
||||
# endif
|
||||
|
||||
/* Microsoft Visual C++ */
|
||||
#elif defined _MSC_VER
|
||||
@@ -67,7 +74,7 @@
|
||||
#endif
|
||||
|
||||
/**
|
||||
Generic compiler-dependent features.
|
||||
Generic (compiler-independent) features.
|
||||
*/
|
||||
#ifndef MY_ALIGNOF
|
||||
# ifdef __cplusplus
|
||||
@@ -79,6 +86,10 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef MY_ASSERT_UNREACHABLE
|
||||
# define MY_ASSERT_UNREACHABLE() do { assert(0); } while (0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
C++ Type Traits
|
||||
*/
|
||||
|
Reference in New Issue
Block a user