diff --git a/configure.ac b/configure.ac index ca19fa8b6f303..61a67d82d6718 100644 --- a/configure.ac +++ b/configure.ac @@ -322,7 +322,7 @@ AC_ARG_ENABLE([gprof], dnl Turn warnings into errors AC_ARG_ENABLE([werror], [AS_HELP_STRING([--enable-werror], - [Treat certain compiler warnings as errors (default is no)])], + [Treat compiler warnings as errors (default is no)])], [enable_werror=$enableval], [enable_werror=no]) @@ -450,32 +450,22 @@ if test "x$enable_werror" = "xyes"; then if test "x$CXXFLAG_WERROR" = "x"; then AC_MSG_ERROR("enable-werror set but -Werror is not usable") fi - AX_CHECK_COMPILE_FLAG([-Werror=reorder],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=reorder"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Werror=gnu],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=gnu"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Werror=vla],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=vla"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Werror=shadow-field],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=shadow-field"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Werror=switch],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=switch"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Werror=thread-safety],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=thread-safety"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Werror=range-loop-analysis],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=range-loop-analysis"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Werror=unused-variable],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=unused-variable"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Werror=date-time],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=date-time"],,[[$CXXFLAG_WERROR]]) + ERROR_CXXFLAGS=$CXXFLAG_WERROR dnl -Wreturn-type is broken in GCC for MinGW-w64. dnl https://sourceforge.net/p/mingw-w64/bugs/306/ - AX_CHECK_COMPILE_FLAG([-Werror=return-type], [ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=return-type"], [], [$CXXFLAG_WERROR], + AX_CHECK_COMPILE_FLAG([-Werror=return-type], [], [ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Wno-error=return-type"], [$CXXFLAG_WERROR], [AC_LANG_SOURCE([[#include int f(){ assert(false); }]])]) - - AX_CHECK_COMPILE_FLAG([-Werror=conditional-uninitialized],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=conditional-uninitialized"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Werror=sign-compare],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=sign-compare"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Wsuggest-override], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wsuggest-override"], [], [$CXXFLAG_WERROR]) - AX_CHECK_COMPILE_FLAG([-Werror=unreachable-code-loop-increment],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=unreachable-code-loop-increment"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Werror=mismatched-tags], [ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=mismatched-tags"], [], [$CXXFLAG_WERROR]) - AX_CHECK_COMPILE_FLAG([-Werror=implicit-fallthrough], [ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=implicit-fallthrough"], [], [$CXXFLAG_WERROR]) - - if test x$suppress_external_warnings != xno ; then - AX_CHECK_COMPILE_FLAG([-Werror=documentation],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=documentation"],,[[$CXXFLAG_WERROR]]) - fi + dnl -Wstringop-overread is broken in GCC 11. + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[]], + [[#if __GNUC__ == 11 + #error -Wstringop-overread is broken in GCC 11 + #endif + ]])], + [], + [ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Wno-stringop-overread"]) fi if test "x$CXXFLAGS_overridden" = "xno"; then @@ -484,6 +474,7 @@ if test "x$CXXFLAGS_overridden" = "xno"; then AX_CHECK_COMPILE_FLAG([-Wgnu],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wgnu"],,[[$CXXFLAG_WERROR]]) dnl some compilers will ignore -Wformat-security without -Wformat, so just combine the two here. AX_CHECK_COMPILE_FLAG([-Wformat -Wformat-security],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wformat -Wformat-security"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wreorder],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wreorder"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wvla],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wvla"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wshadow-field],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wshadow-field"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wthread-safety],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wthread-safety"],,[[$CXXFLAG_WERROR]]) @@ -496,6 +487,8 @@ if test "x$CXXFLAGS_overridden" = "xno"; then AX_CHECK_COMPILE_FLAG([-Wduplicated-cond],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wduplicated-cond"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wlogical-op],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wlogical-op"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Woverloaded-virtual],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Woverloaded-virtual"],,[[$CXXFLAG_WERROR]]) + dnl -Wsuggest-override is broken with GCC before 9.2 + dnl https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010 AX_CHECK_COMPILE_FLAG([-Wsuggest-override],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wsuggest-override"],,[[$CXXFLAG_WERROR]], [AC_LANG_SOURCE([[struct A { virtual void f(); }; struct B : A { void f() final; };]])]) AX_CHECK_COMPILE_FLAG([-Wunreachable-code-loop-increment],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wunreachable-code-loop-increment"],,[[$CXXFLAG_WERROR]]) diff --git a/src/qt/appearancewidget.cpp b/src/qt/appearancewidget.cpp index d52c03971a9b0..2a26902d017aa 100644 --- a/src/qt/appearancewidget.cpp +++ b/src/qt/appearancewidget.cpp @@ -46,11 +46,11 @@ AppearanceWidget::AppearanceWidget(QWidget* parent) : connect(ui->fontWeightNormalSlider, &QSlider::valueChanged, [this](auto nValue) { updateFontWeightNormal(nValue); }); connect(ui->fontWeightBoldSlider, &QSlider::valueChanged, [this](auto nValue) { updateFontWeightBold(nValue); }); - connect(ui->theme, &QComboBox::currentTextChanged, [=]() { Q_EMIT appearanceChanged(); }); - connect(ui->fontFamily, &QComboBox::currentTextChanged, [=]() { Q_EMIT appearanceChanged(); }); - connect(ui->fontScaleSlider, &QSlider::sliderReleased, [=]() { Q_EMIT appearanceChanged(); }); - connect(ui->fontWeightNormalSlider, &QSlider::sliderReleased, [=]() { Q_EMIT appearanceChanged(); }); - connect(ui->fontWeightBoldSlider, &QSlider::sliderReleased, [=]() { Q_EMIT appearanceChanged(); }); + connect(ui->theme, &QComboBox::currentTextChanged, [this]() { Q_EMIT appearanceChanged(); }); + connect(ui->fontFamily, &QComboBox::currentTextChanged, [this]() { Q_EMIT appearanceChanged(); }); + connect(ui->fontScaleSlider, &QSlider::sliderReleased, [this]() { Q_EMIT appearanceChanged(); }); + connect(ui->fontWeightNormalSlider, &QSlider::sliderReleased, [this]() { Q_EMIT appearanceChanged(); }); + connect(ui->fontWeightBoldSlider, &QSlider::sliderReleased, [this]() { Q_EMIT appearanceChanged(); }); } AppearanceWidget::~AppearanceWidget() diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 2628bdf3afad8..36609e80684bd 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -240,7 +240,7 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const NetworkStyle* networkStyle, bool fDebugCustomStyleSheets = gArgs.GetBoolArg("-debug-ui", false) && GUIUtil::isStyleSheetDirectoryCustom(); if (fDebugCustomStyleSheets) { timerCustomCss = new QTimer(this); - QObject::connect(timerCustomCss, &QTimer::timeout, [=]() { + QObject::connect(timerCustomCss, &QTimer::timeout, [this]() { if (!m_node.shutdownRequested()) { GUIUtil::loadStyleSheet(); } @@ -291,7 +291,7 @@ void BitcoinGUI::startSpinner() }; timerSpinner = new QTimer(this); - QObject::connect(timerSpinner, &QTimer::timeout, [=]() { + QObject::connect(timerSpinner, &QTimer::timeout, [this, getNextFrame]() { if (timerSpinner == nullptr) { return; } @@ -319,7 +319,7 @@ void BitcoinGUI::startConnectingAnimation() } timerConnecting = new QTimer(this); - QObject::connect(timerConnecting, &QTimer::timeout, [=]() { + QObject::connect(timerConnecting, &QTimer::timeout, [this]() { if (timerConnecting == nullptr) { return; @@ -1353,7 +1353,7 @@ void BitcoinGUI::openOptionsDialogWithTab(OptionsDialog::Tab tab) connect(dlg, &OptionsDialog::quitOnReset, this, &BitcoinGUI::quitRequested); dlg->setCurrentTab(tab); dlg->setModel(clientModel->getOptionsModel()); - connect(dlg, &OptionsDialog::appearanceChanged, [=]() { + connect(dlg, &OptionsDialog::appearanceChanged, [this]() { updateWidth(); }); GUIUtil::ShowModalDialogAndDeleteOnClose(dlg); diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index 903daba278af4..28fd6de091de9 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -194,7 +194,7 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) : appearanceLayout->addWidget(appearance); ui->widgetAppearance->setLayout(appearanceLayout); - connect(appearance, &AppearanceWidget::appearanceChanged, [=](){ + connect(appearance, &AppearanceWidget::appearanceChanged, [this](){ updateWidth(); Q_EMIT appearanceChanged(); }); @@ -277,13 +277,13 @@ void OptionsDialog::setModel(OptionsModel *_model) connect(ui->lang, qOverload<>(&QValueComboBox::valueChanged), [this]{ showRestartWarning(); }); connect(ui->thirdPartyTxUrls, &QLineEdit::textChanged, [this]{ showRestartWarning(); }); - connect(ui->coinJoinEnabled, &QCheckBox::clicked, [=](bool fChecked) { + connect(ui->coinJoinEnabled, &QCheckBox::clicked, [this](bool fChecked) { #ifdef ENABLE_WALLET model->node().coinJoinOptions().setEnabled(fChecked); #endif updateCoinJoinVisibility(); - if (_model != nullptr) { - _model->emitCoinJoinEnabledChanged(); + if (this->model != nullptr) { + this->model->emitCoinJoinEnabledChanged(); } updateWidth(); }); @@ -293,7 +293,7 @@ void OptionsDialog::setModel(OptionsModel *_model) // Store the current CoinJoin enabled state to recover it if it gets changed but the dialog gets not accepted but declined. #ifdef ENABLE_WALLET fCoinJoinEnabledPrev = model->node().coinJoinOptions().isEnabled(); - connect(this, &OptionsDialog::rejected, [=]() { + connect(this, &OptionsDialog::rejected, [this]() { if (fCoinJoinEnabledPrev != model->node().coinJoinOptions().isEnabled()) { ui->coinJoinEnabled->click(); } diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 6b9ace3144dff..6f9a92438d48b 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -328,7 +328,7 @@ void OverviewPage::setWalletModel(WalletModel *model) connect(model->getOptionsModel(), &OptionsModel::coinJoinRoundsChanged, this, &OverviewPage::updateCoinJoinProgress); connect(model->getOptionsModel(), &OptionsModel::coinJoinAmountChanged, this, &OverviewPage::updateCoinJoinProgress); connect(model->getOptionsModel(), &OptionsModel::AdvancedCJUIChanged, this, &OverviewPage::updateAdvancedCJUI); - connect(model->getOptionsModel(), &OptionsModel::coinJoinEnabledChanged, [=]() { + connect(model->getOptionsModel(), &OptionsModel::coinJoinEnabledChanged, [this]() { coinJoinStatus(true); });