mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-31 18:24:25 +03:00
Added -Wimplicit-fallthrough
Added compiler flag to check for fall through in case statements.
This commit is contained in:
@ -5,6 +5,7 @@
|
|||||||
cmake_minimum_required (VERSION 2.8)
|
cmake_minimum_required (VERSION 2.8)
|
||||||
project (wsrep-lib)
|
project (wsrep-lib)
|
||||||
include(CheckIncludeFile)
|
include(CheckIncludeFile)
|
||||||
|
include(CheckCXXCompilerFlag)
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
|
|
||||||
@ -29,6 +30,11 @@ option(WSREP_LIB_STRICT_BUILD_FLAGS "Compile with strict build flags")
|
|||||||
# CXX flags
|
# CXX flags
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -Woverloaded-virtual -g")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -Woverloaded-virtual -g")
|
||||||
|
|
||||||
|
CHECK_CXX_COMPILER_FLAG("-Wimplicit-fallthrough" COMPILER_SUPPORTS_IMPLICIT_FALLTHROUGH)
|
||||||
|
if (COMPILER_SUPPORTS_IMPLICIT_FALLTHROUGH)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wimplicit-fallthrough")
|
||||||
|
endif()
|
||||||
|
|
||||||
if (WSREP_LIB_STRICT_BUILD_FLAGS)
|
if (WSREP_LIB_STRICT_BUILD_FLAGS)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weffc++")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weffc++")
|
||||||
endif()
|
endif()
|
||||||
|
@ -29,3 +29,11 @@
|
|||||||
#else
|
#else
|
||||||
#define WSREP_OVERRIDE
|
#define WSREP_OVERRIDE
|
||||||
#endif // __cplusplus >= 201103L
|
#endif // __cplusplus >= 201103L
|
||||||
|
|
||||||
|
#if defined(__clang__) && __cplusplus >= 201103L
|
||||||
|
#define WSREP_FALLTHROUGH [[clang::fallthrough]]
|
||||||
|
#elif (defined(__GNUC__) || defined(__GNUG__)) && (__GNUC__ >= 7)
|
||||||
|
#define WSREP_FALLTHROUGH __attribute__((fallthrough))
|
||||||
|
#else
|
||||||
|
#define WSREP_FALLTHROUGH
|
||||||
|
#endif
|
||||||
|
@ -875,7 +875,7 @@ void wsrep::server_state::on_sync()
|
|||||||
break;
|
break;
|
||||||
case s_connected:
|
case s_connected:
|
||||||
state(lock, s_joiner);
|
state(lock, s_joiner);
|
||||||
// fall through
|
WSREP_FALLTHROUGH;
|
||||||
case s_joiner:
|
case s_joiner:
|
||||||
state(lock, s_initializing);
|
state(lock, s_initializing);
|
||||||
break;
|
break;
|
||||||
@ -885,7 +885,7 @@ void wsrep::server_state::on_sync()
|
|||||||
break;
|
break;
|
||||||
case s_initialized:
|
case s_initialized:
|
||||||
state(lock, s_joined);
|
state(lock, s_joined);
|
||||||
// fall through
|
WSREP_FALLTHROUGH;
|
||||||
default:
|
default:
|
||||||
/* State */
|
/* State */
|
||||||
state(lock, s_synced);
|
state(lock, s_synced);
|
||||||
|
@ -551,7 +551,7 @@ int wsrep::transaction::before_rollback()
|
|||||||
case s_preparing:
|
case s_preparing:
|
||||||
// Error detected during prepare phase
|
// Error detected during prepare phase
|
||||||
state(lock, s_must_abort);
|
state(lock, s_must_abort);
|
||||||
// fall through
|
WSREP_FALLTHROUGH;
|
||||||
case s_executing:
|
case s_executing:
|
||||||
// Voluntary rollback
|
// Voluntary rollback
|
||||||
if (is_streaming())
|
if (is_streaming())
|
||||||
@ -697,7 +697,7 @@ int wsrep::transaction::after_statement()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Continue to replay if rollback() changed the state to s_must_replay
|
// Continue to replay if rollback() changed the state to s_must_replay
|
||||||
// Fall through
|
WSREP_FALLTHROUGH;
|
||||||
case s_must_replay:
|
case s_must_replay:
|
||||||
{
|
{
|
||||||
state(lock, s_replaying);
|
state(lock, s_replaying);
|
||||||
|
Reference in New Issue
Block a user