Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix some clang/gcc warnings found integrating qtpromise #39

Merged
merged 10 commits into from
Oct 26, 2020
35 changes: 34 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions src/qtpromise/qpromise_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down Expand Up @@ -113,7 +113,7 @@ class PromiseError

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:
Expand Down Expand Up @@ -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());
}
Expand Down