mirror of
https://github.com/simonbrunel/qtpromise.git
synced 2024-11-22 02:34:30 +08:00
Fix Clang/GCC warnings and update compile options (#39)
This commit is contained in:
parent
f7639e921e
commit
60b36e7a70
@ -33,12 +33,45 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
-Wpedantic
|
||||
-Wall
|
||||
-Wextra
|
||||
|
||||
-Wconversion
|
||||
-Wsign-conversion
|
||||
-Wdouble-promotion
|
||||
-Wformat=2
|
||||
-Wlogical-op
|
||||
-Wmissing-noreturn
|
||||
-Wold-style-cast
|
||||
# -Wshadow # disabled due to many findings in the current code
|
||||
-Wsign-conversion
|
||||
-Wswitch-default
|
||||
-Wunused-local-typedefs
|
||||
# -Wuseless-cast # disabled due to Qt's moc warnings
|
||||
|
||||
-pedantic-errors
|
||||
)
|
||||
|
||||
# https://github.com/Barro/compiler-warnings/blob/master/gcc/warnings-gcc-6.txt
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 6)
|
||||
add_compile_options(
|
||||
-Wduplicated-cond
|
||||
)
|
||||
endif()
|
||||
|
||||
# https://github.com/Barro/compiler-warnings/blob/master/gcc/warnings-gcc-7.txt
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 7)
|
||||
add_compile_options(
|
||||
-Wduplicated-branches
|
||||
)
|
||||
endif()
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
# https://clang.llvm.org/docs/DiagnosticsReference.html
|
||||
add_compile_options(
|
||||
-Wall
|
||||
-Wextra
|
||||
-Wpedantic
|
||||
|
||||
-Wsuggest-destructor-override
|
||||
-Wsuggest-override
|
||||
)
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
# https://docs.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level
|
||||
add_compile_options(
|
||||
|
@ -52,7 +52,7 @@ static void qtpromise_defer(F&& f, const QPointer<QThread>& thread)
|
||||
{
|
||||
Event(FType&& f) : QEvent{QEvent::None}, m_f{std::move(f)} { }
|
||||
Event(const FType& f) : QEvent{QEvent::None}, m_f{f} { }
|
||||
~Event() { m_f(); }
|
||||
~Event() override { m_f(); }
|
||||
FType m_f;
|
||||
};
|
||||
|
||||
@ -113,7 +113,7 @@ public:
|
||||
|
||||
PromiseError() { }
|
||||
PromiseError(const std::exception_ptr& exception) : m_data{exception} { }
|
||||
void rethrow() const { std::rethrow_exception(m_data); }
|
||||
Q_NORETURN void rethrow() const { std::rethrow_exception(m_data); }
|
||||
bool isNull() const { return m_data == nullptr; }
|
||||
|
||||
private:
|
||||
@ -329,8 +329,8 @@ struct PromiseCatcher
|
||||
return [=](const PromiseError& error) {
|
||||
try {
|
||||
error.rethrow();
|
||||
} catch (const TArg& error) {
|
||||
PromiseDispatch<ResType>::call(resolve, reject, handler, error);
|
||||
} catch (const TArg& argError) {
|
||||
PromiseDispatch<ResType>::call(resolve, reject, handler, argError);
|
||||
} catch (...) {
|
||||
reject(std::current_exception());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user