Skip to content

Commit 988fa6a

Browse files
authored
Merge pull request #4196 from kittywhiskers/override
merge bitcoin#18914, bitcoin#13306, bitcoin#16424, bitcoin#13899, bitcoin#17486, bitcoin#17880, bitcoin#18145, bitcoin#18843, bitcoin#16710: split warnings out of CXXFLAGS, add more flags
2 parents 14c6316 + b07abef commit 988fa6a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+167
-131
lines changed

configure.ac

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -362,26 +362,42 @@ if test "x$enable_werror" = "xyes"; then
362362
AC_MSG_ERROR("enable-werror set but -Werror is not usable")
363363
fi
364364
AX_CHECK_COMPILE_FLAG([-Werror=vla],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=vla"],,[[$CXXFLAG_WERROR]])
365+
AX_CHECK_COMPILE_FLAG([-Werror=switch],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=switch"],,[[$CXXFLAG_WERROR]])
365366
AX_CHECK_COMPILE_FLAG([-Werror=thread-safety],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=thread-safety"],,[[$CXXFLAG_WERROR]])
367+
AX_CHECK_COMPILE_FLAG([-Werror=unused-variable],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=unused-variable"],,[[$CXXFLAG_WERROR]])
368+
AX_CHECK_COMPILE_FLAG([-Werror=date-time],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=date-time"],,[[$CXXFLAG_WERROR]])
369+
AX_CHECK_COMPILE_FLAG([-Werror=return-type],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=return-type"],,[[$CXXFLAG_WERROR]])
370+
AX_CHECK_COMPILE_FLAG([-Werror=conditional-uninitialized],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=conditional-uninitialized"],,[[$CXXFLAG_WERROR]])
371+
dnl -Wsuggest-override is broken with GCC before 9.2
372+
dnl https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010
373+
AX_CHECK_COMPILE_FLAG([-Werror=suggest-override],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=suggest-override"],,[[$CXXFLAG_WERROR]],
374+
[AC_LANG_SOURCE([[struct A { virtual void f(); }; struct B : A { void f() final; };]])])
366375
fi
367376

368377
if test "x$CXXFLAGS_overridden" = "xno"; then
369-
AX_CHECK_COMPILE_FLAG([-Wall],[CXXFLAGS="$CXXFLAGS -Wall"],,[[$CXXFLAG_WERROR]])
370-
AX_CHECK_COMPILE_FLAG([-Wextra],[CXXFLAGS="$CXXFLAGS -Wextra"],,[[$CXXFLAG_WERROR]])
371-
AX_CHECK_COMPILE_FLAG([-Wformat],[CXXFLAGS="$CXXFLAGS -Wformat"],,[[$CXXFLAG_WERROR]])
372-
AX_CHECK_COMPILE_FLAG([-Wvla],[CXXFLAGS="$CXXFLAGS -Wvla"],,[[$CXXFLAG_WERROR]])
373-
AX_CHECK_COMPILE_FLAG([-Wformat-security],[CXXFLAGS="$CXXFLAGS -Wformat-security"],,[[$CXXFLAG_WERROR]])
374-
AX_CHECK_COMPILE_FLAG([-Wthread-safety],[CXXFLAGS="$CXXFLAGS -Wthread-safety"],,[[$CXXFLAG_WERROR]])
378+
AX_CHECK_COMPILE_FLAG([-Wall],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wall"],,[[$CXXFLAG_WERROR]])
379+
AX_CHECK_COMPILE_FLAG([-Wextra],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wextra"],,[[$CXXFLAG_WERROR]])
380+
AX_CHECK_COMPILE_FLAG([-Wformat],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wformat"],,[[$CXXFLAG_WERROR]])
381+
AX_CHECK_COMPILE_FLAG([-Wvla],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wvla"],,[[$CXXFLAG_WERROR]])
382+
AX_CHECK_COMPILE_FLAG([-Wswitch],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wswitch"],,[[$CXXFLAG_WERROR]])
383+
AX_CHECK_COMPILE_FLAG([-Wformat-security],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wformat-security"],,[[$CXXFLAG_WERROR]])
384+
AX_CHECK_COMPILE_FLAG([-Wthread-safety],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wthread-safety"],,[[$CXXFLAG_WERROR]])
375385
AX_CHECK_COMPILE_FLAG([-Wrange-loop-analysis],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wrange-loop-analysis"],,[[$CXXFLAG_WERROR]])
386+
AX_CHECK_COMPILE_FLAG([-Wredundant-decls],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wredundant-decls"],,[[$CXXFLAG_WERROR]])
387+
AX_CHECK_COMPILE_FLAG([-Wunused-variable],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wunused-variable"],,[[$CXXFLAG_WERROR]])
388+
AX_CHECK_COMPILE_FLAG([-Wdate-time],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wdate-time"],,[[$CXXFLAG_WERROR]])
389+
AX_CHECK_COMPILE_FLAG([-Wconditional-uninitialized],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wconditional-uninitialized"],,[[$CXXFLAG_WERROR]])
390+
AX_CHECK_COMPILE_FLAG([-Wsuggest-override],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wsuggest-override"],,[[$CXXFLAG_WERROR]],
391+
[AC_LANG_SOURCE([[struct A { virtual void f(); }; struct B : A { void f() final; };]])])
376392

377393
## Some compilers (gcc) ignore unknown -Wno-* options, but warn about all
378394
## unknown options if any other warning is produced. Test the -Wfoo case, and
379395
## set the -Wno-foo case if it works.
380-
AX_CHECK_COMPILE_FLAG([-Wunused-parameter],[CXXFLAGS="$CXXFLAGS -Wno-unused-parameter"],,[[$CXXFLAG_WERROR]])
381-
AX_CHECK_COMPILE_FLAG([-Wself-assign],[CXXFLAGS="$CXXFLAGS -Wno-self-assign"],,[[$CXXFLAG_WERROR]])
382-
AX_CHECK_COMPILE_FLAG([-Wunused-local-typedef],[CXXFLAGS="$CXXFLAGS -Wno-unused-local-typedef"],,[[$CXXFLAG_WERROR]])
383-
AX_CHECK_COMPILE_FLAG([-Wdeprecated-register],[CXXFLAGS="$CXXFLAGS -Wno-deprecated-register"],,[[$CXXFLAG_WERROR]])
384-
AX_CHECK_COMPILE_FLAG([-Wimplicit-fallthrough],[CXXFLAGS="$CXXFLAGS -Wno-implicit-fallthrough"],,[[$CXXFLAG_WERROR]])
396+
AX_CHECK_COMPILE_FLAG([-Wunused-parameter],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-unused-parameter"],,[[$CXXFLAG_WERROR]])
397+
AX_CHECK_COMPILE_FLAG([-Wself-assign],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-self-assign"],,[[$CXXFLAG_WERROR]])
398+
AX_CHECK_COMPILE_FLAG([-Wunused-local-typedef],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-unused-local-typedef"],,[[$CXXFLAG_WERROR]])
399+
AX_CHECK_COMPILE_FLAG([-Wdeprecated-register],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-deprecated-register"],,[[$CXXFLAG_WERROR]])
400+
AX_CHECK_COMPILE_FLAG([-Wimplicit-fallthrough],[NOWARN_CXXFLAGS="$NOWARN_CXXFLAGS -Wno-implicit-fallthrough"],,[[$CXXFLAG_WERROR]])
385401
fi
386402

387403
enable_hwcrc32=no
@@ -1459,6 +1475,8 @@ AC_SUBST(BITCOIN_TX_NAME)
14591475

14601476
AC_SUBST(RELDFLAGS)
14611477
AC_SUBST(DEBUG_CPPFLAGS)
1478+
AC_SUBST(WARN_CXXFLAGS)
1479+
AC_SUBST(NOWARN_CXXFLAGS)
14621480
AC_SUBST(DEBUG_CXXFLAGS)
14631481
AC_SUBST(ERROR_CXXFLAGS)
14641482
AC_SUBST(GPROF_CXXFLAGS)
@@ -1576,7 +1594,7 @@ echo " CC = $CC"
15761594
echo " CFLAGS = $CFLAGS"
15771595
echo " CPPFLAGS = $DEBUG_CPPFLAGS $HARDENED_CPPFLAGS $CPPFLAGS"
15781596
echo " CXX = $CXX"
1579-
echo " CXXFLAGS = $DEBUG_CXXFLAGS $HARDENED_CXXFLAGS $ERROR_CXXFLAGS $GPROF_CXXFLAGS $CXXFLAGS"
1597+
echo " CXXFLAGS = $DEBUG_CXXFLAGS $HARDENED_CXXFLAGS $WARN_CXXFLAGS $NOWARN_CXXFLAGS $ERROR_CXXFLAGS $GPROF_CXXFLAGS $CXXFLAGS"
15801598
echo " LDFLAGS = $PTHREAD_CFLAGS $HARDENED_LDFLAGS $GPROF_LDFLAGS $LDFLAGS"
15811599
echo " ARFLAGS = $ARFLAGS"
15821600
echo

src/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
DIST_SUBDIRS = secp256k1 univalue
77

88
AM_LDFLAGS = $(PTHREAD_CFLAGS) $(LIBTOOL_LDFLAGS) $(HARDENED_LDFLAGS) $(GPROF_LDFLAGS) $(SANITIZER_LDFLAGS)
9-
AM_CXXFLAGS = $(DEBUG_CXXFLAGS) $(HARDENED_CXXFLAGS) $(ERROR_CXXFLAGS) $(GPROF_CXXFLAGS) $(SANITIZER_CXXFLAGS)
9+
AM_CXXFLAGS = $(DEBUG_CXXFLAGS) $(HARDENED_CXXFLAGS) $(WARN_CXXFLAGS) $(NOWARN_CXXFLAGS) $(ERROR_CXXFLAGS) $(GPROF_CXXFLAGS) $(SANITIZER_CXXFLAGS)
1010
AM_CPPFLAGS = $(DEBUG_CPPFLAGS) $(HARDENED_CPPFLAGS)
1111
AM_LIBTOOLFLAGS = --preserve-dup-deps
1212
EXTRA_LIBRARIES =

src/Makefile.leveldb.include

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ LEVELDB_CPPFLAGS_INT += -DLEVELDB_PLATFORM_POSIX
3030
endif
3131

3232
leveldb_libleveldb_a_CPPFLAGS = $(AM_CPPFLAGS) $(LEVELDB_CPPFLAGS_INT) $(LEVELDB_CPPFLAGS)
33-
leveldb_libleveldb_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
33+
leveldb_libleveldb_a_CXXFLAGS = $(filter-out -Wconditional-uninitialized -Werror=conditional-uninitialized -Wsuggest-override -Werror=suggest-override, $(AM_CXXFLAGS)) $(PIE_FLAGS)
3434

3535
leveldb_libleveldb_a_SOURCES=
3636
leveldb_libleveldb_a_SOURCES += leveldb/port/atomic_pointer.h

src/qt/addressbookpage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class AddressBookSortFilterProxyModel final : public QSortFilterProxyModel
3838
}
3939

4040
protected:
41-
bool filterAcceptsRow(int row, const QModelIndex& parent) const
41+
bool filterAcceptsRow(int row, const QModelIndex& parent) const override
4242
{
4343
auto model = sourceModel();
4444
auto label = model->index(row, AddressTableModel::Label, parent);

src/qt/addressbookpage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class AddressBookPage : public QDialog
4444
const QString &getReturnValue() const { return returnValue; }
4545

4646
public Q_SLOTS:
47-
void done(int retval);
47+
void done(int retval) override;
4848

4949
private:
5050
Ui::AddressBookPage *ui;

src/qt/addresstablemodel.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ class AddressTableModel : public QAbstractTableModel
5252

5353
/** @name Methods overridden from QAbstractTableModel
5454
@{*/
55-
int rowCount(const QModelIndex &parent) const;
56-
int columnCount(const QModelIndex &parent) const;
57-
QVariant data(const QModelIndex &index, int role) const;
58-
bool setData(const QModelIndex &index, const QVariant &value, int role);
59-
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
60-
QModelIndex index(int row, int column, const QModelIndex &parent) const;
61-
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
62-
Qt::ItemFlags flags(const QModelIndex &index) const;
55+
int rowCount(const QModelIndex &parent) const override;
56+
int columnCount(const QModelIndex &parent) const override;
57+
QVariant data(const QModelIndex &index, int role) const override;
58+
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
59+
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
60+
QModelIndex index(int row, int column, const QModelIndex &parent) const override;
61+
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override;
62+
Qt::ItemFlags flags(const QModelIndex &index) const override;
6363
/*@}*/
6464

6565
/* Add an address to the model.

src/qt/askpassphrasedialog.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class AskPassphraseDialog : public QDialog
3131
explicit AskPassphraseDialog(Mode mode, QWidget *parent);
3232
~AskPassphraseDialog();
3333

34-
void accept();
34+
void accept() override;
3535

3636
void setModel(WalletModel *model);
3737

@@ -47,8 +47,8 @@ private Q_SLOTS:
4747
void toggleShowPassword(bool);
4848

4949
protected:
50-
bool event(QEvent *event);
51-
bool eventFilter(QObject *object, QEvent *event);
50+
bool event(QEvent *event) override;
51+
bool eventFilter(QObject *object, QEvent *event) override;
5252
};
5353

5454
#endif // BITCOIN_QT_ASKPASSPHRASEDIALOG_H

src/qt/bantablemodel.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,17 @@ class BanTableModel : public QAbstractTableModel
5757

5858
/** @name Methods overridden from QAbstractTableModel
5959
@{*/
60-
int rowCount(const QModelIndex &parent) const;
61-
int columnCount(const QModelIndex &parent) const;
62-
QVariant data(const QModelIndex &index, int role) const;
63-
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
64-
QModelIndex index(int row, int column, const QModelIndex &parent) const;
65-
Qt::ItemFlags flags(const QModelIndex &index) const;
66-
void sort(int column, Qt::SortOrder order);
67-
bool shouldShow();
60+
int rowCount(const QModelIndex &parent) const override;
61+
int columnCount(const QModelIndex &parent) const override;
62+
QVariant data(const QModelIndex &index, int role) const override;
63+
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
64+
QModelIndex index(int row, int column, const QModelIndex &parent) const override;
65+
Qt::ItemFlags flags(const QModelIndex &index) const override;
66+
void sort(int column, Qt::SortOrder order) override;
6867
/*@}*/
6968

69+
bool shouldShow();
70+
7071
public Q_SLOTS:
7172
void refresh();
7273

src/qt/bitcoinaddressvalidator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class BitcoinAddressEntryValidator : public QValidator
1717
public:
1818
explicit BitcoinAddressEntryValidator(QObject *parent, bool fAllowURI = false);
1919

20-
State validate(QString &input, int &pos) const;
20+
State validate(QString &input, int &pos) const override;
2121

2222
private:
2323
bool fAllowURI;
@@ -32,7 +32,7 @@ class BitcoinAddressCheckValidator : public QValidator
3232
public:
3333
explicit BitcoinAddressCheckValidator(QObject *parent);
3434

35-
State validate(QString &input, int &pos) const;
35+
State validate(QString &input, int &pos) const override;
3636
};
3737

3838
#endif // BITCOIN_QT_BITCOINADDRESSVALIDATOR_H

src/qt/bitcoinamountfield.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class AmountValidator : public QValidator
4343
QValidator(parent),
4444
currentUnit(BitcoinUnits::DASH) {}
4545

46-
State validate(QString &input, int &pos) const
46+
State validate(QString &input, int &pos) const override
4747
{
4848
if(input.isEmpty())
4949
return QValidator::Intermediate;
@@ -112,7 +112,7 @@ class AmountLineEdit: public QLineEdit
112112
clear();
113113
}
114114

115-
QSize minimumSizeHint() const
115+
QSize minimumSizeHint() const override
116116
{
117117
ensurePolished();
118118
const QFontMetrics fm(fontMetrics());
@@ -127,7 +127,7 @@ class AmountLineEdit: public QLineEdit
127127
int currentUnit;
128128

129129
protected:
130-
bool event(QEvent *event)
130+
bool event(QEvent *event) override
131131
{
132132
if (event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease)
133133
{

0 commit comments

Comments
 (0)