Adding this warning will eliminate unexpected test failures and hard to review code. Moreover, there shouldn't be a use case in Bitcoin Core that relies on fields to be shadowed.
test: Avoid overwriting the NodeContext member of the testing setup [-Wshadow-field] #19188
pull MarcoFalke wants to merge 2 commits into bitcoin:master from MarcoFalke:2006-testNoShadowField changing 4 files +2 −3-
MarcoFalke commented at 12:14 PM on June 6, 2020: member
-
build: Add -Wshadow-field fa16e7816b
-
MarcoFalke commented at 12:15 PM on June 6, 2020: member
- MarcoFalke renamed this:
2006 test no shadow field
test: Avoid overwriting the NodeContext member of the testing setup
on Jun 6, 2020 - MarcoFalke renamed this:
test: Avoid overwriting the NodeContext member of the testing setup
test: Avoid overwriting the NodeContext member of the testing setup [-Wshadow-field]
on Jun 6, 2020 -
MarcoFalke commented at 12:17 PM on June 6, 2020: member
Can be tested by reverting the fix and observing the warning:
In file included from wallet/test/init_test_fixture.cpp:8: ./wallet/test/init_test_fixture.h:21:17: warning: non-static data member 'm_node' of 'InitWalletDirTestingSetup' shadows member inherited from type 'BasicTestingSetup' [-Wshadow-field] NodeContext m_node; ^ ./test/util/setup_common.h:76:17: note: declared here NodeContext m_node; ^ 1 warning generated. -
DrahtBot commented at 12:49 PM on June 6, 2020: member
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
Conflicts
Reviewers, this pull request conflicts with the following ones:
- #18857 (build: avoid repetitions when enabling warnings in configure.ac by vasild)
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
-
test: Avoid overwriting the NodeContext member of the testing setup fac6b9b938
- MarcoFalke force-pushed on Jun 6, 2020
- DrahtBot added the label Build system on Jun 6, 2020
- DrahtBot added the label Tests on Jun 6, 2020
- DrahtBot added the label Wallet on Jun 6, 2020
-
hebasto commented at 2:23 PM on June 6, 2020: member
Concept ACK.
- MarcoFalke removed the label Build system on Jun 6, 2020
- MarcoFalke removed the label Wallet on Jun 6, 2020
- hebasto approved
-
practicalswift commented at 5:38 PM on June 6, 2020: contributor
ACK fac6b9b938230d24c13fcb6e9be28515d674c6c8 -- patch looks correct
- MarcoFalke requested review from fanquake on Jun 7, 2020
- fanquake approved
-
fanquake commented at 5:35 AM on June 8, 2020: member
ACK fac6b9b938230d24c13fcb6e9be28515d674c6c8 - Warnings compiling fa16e7816b886b82d36457b0d8edc773cba76421 are below. No warnings with fac6b9b938230d24c13fcb6e9be28515d674c6c8. The
-Wshadow-fielddiagnostic has been available in Clang since 5.0.0. It's not available for GCC.In file included from wallet/test/wallet_test_fixture.cpp:5: ./wallet/test/wallet_test_fixture.h:22:17: warning: non-static data member 'm_node' of 'WalletTestingSetup' shadows member inherited from type 'BasicTestingSetup' [-Wshadow-field] NodeContext m_node; ^ ./test/util/setup_common.h:76:17: note: declared here NodeContext m_node; ^ 1 warning generated. .... In file included from wallet/test/init_test_fixture.cpp:8: ./wallet/test/init_test_fixture.h:21:17: warning: non-static data member 'm_node' of 'InitWalletDirTestingSetup' shadows member inherited from type 'BasicTestingSetup' [-Wshadow-field] NodeContext m_node; ^ ./test/util/setup_common.h:76:17: note: declared here NodeContext m_node; ^ 1 warning generated. ... In file included from wallet/test/wallet_test_fixture.cpp:5: ./wallet/test/wallet_test_fixture.h:22:17: warning: non-static data member 'm_node' of 'WalletTestingSetup' shadows member inherited from type 'BasicTestingSetup' [-Wshadow-field] NodeContext m_node; ^ ./test/util/setup_common.h:76:17: note: declared here NodeContext m_node; ^ 1 warning generated. ... In file included from wallet/test/init_tests.cpp:11: ./wallet/test/init_test_fixture.h:21:17: warning: non-static data member 'm_node' of 'InitWalletDirTestingSetup' shadows member inherited from type 'BasicTestingSetup' [-Wshadow-field] NodeContext m_node; ^ ./test/util/setup_common.h:76:17: note: declared here NodeContext m_node; ^ 1 warning generated. CXX test/util/libtest_util_a-mining.o CXX test/util/libtest_util_a-net.o In file included from wallet/test/psbt_wallet_tests.cpp:12: ./wallet/test/wallet_test_fixture.h:22:17: warning: non-static data member 'm_node' of 'WalletTestingSetup' shadows member inherited from type 'BasicTestingSetup' [-Wshadow-field] NodeContext m_node; ^ ./test/util/setup_common.h:76:17: note: declared here NodeContext m_node; ^ 1 warning generated. CXX test/util/libtest_util_a-setup_common.o CXX test/util/libtest_util_a-str.o CXX test/util/libtest_util_a-transaction_utils.o CXX test/util/libtest_util_a-wallet.o CXX bench/bench_bitcoin-addrman.o CXX bench/bench_bitcoin-bench_bitcoin.o CXX bench/bench_bitcoin-bench.o CXX bench/bench_bitcoin-block_assemble.o CXX bench/bench_bitcoin-checkblock.o In file included from wallet/test/coinselector_tests.cpp:12: ./wallet/test/wallet_test_fixture.h:22:17: warning: non-static data member 'm_node' of 'WalletTestingSetup' shadows member inherited from type 'BasicTestingSetup' [-Wshadow-field] NodeContext m_node; ^ ./test/util/setup_common.h:76:17: note: declared here NodeContext m_node; ^ 1 warning generated. CXX bench/bench_bitcoin-checkqueue.o In file included from wallet/test/wallet_tests.cpp:22: ./wallet/test/wallet_test_fixture.h:22:17: warning: non-static data member 'm_node' of 'WalletTestingSetup' shadows member inherited from type 'BasicTestingSetup' [-Wshadow-field] NodeContext m_node; ^ ./test/util/setup_common.h:76:17: note: declared here NodeContext m_node; ^ wallet/test/wallet_tests.cpp:538:17: warning: non-static data member 'm_node' of 'ListCoinsTestingSetup' shadows member inherited from type 'BasicTestingSetup' [-Wshadow-field] NodeContext m_node; ^ ./test/util/setup_common.h:76:17: note: declared here NodeContext m_node; ^ 2 warnings generated. - fanquake merged this on Jun 8, 2020
- fanquake closed this on Jun 8, 2020
- MarcoFalke deleted the branch on Jun 8, 2020
- jasonbcox referenced this in commit 3de58c3057 on Jul 8, 2020
- DrahtBot locked this on Feb 15, 2022