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
  1. MarcoFalke commented at 12:14 PM on June 6, 2020: member

    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.

  2. build: Add -Wshadow-field fa16e7816b
  3. MarcoFalke commented at 12:15 PM on June 6, 2020: member
  4. MarcoFalke renamed this:
    2006 test no shadow field
    test: Avoid overwriting the NodeContext member of the testing setup
    on Jun 6, 2020
  5. 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
  6. 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.
    
  7. 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.

  8. test: Avoid overwriting the NodeContext member of the testing setup fac6b9b938
  9. MarcoFalke force-pushed on Jun 6, 2020
  10. DrahtBot added the label Build system on Jun 6, 2020
  11. DrahtBot added the label Tests on Jun 6, 2020
  12. DrahtBot added the label Wallet on Jun 6, 2020
  13. hebasto commented at 2:23 PM on June 6, 2020: member

    Concept ACK.

  14. MarcoFalke removed the label Build system on Jun 6, 2020
  15. MarcoFalke removed the label Wallet on Jun 6, 2020
  16. hebasto approved
  17. hebasto commented at 3:35 PM on June 6, 2020: member

    ACK fac6b9b938230d24c13fcb6e9be28515d674c6c8, tested on Linux Mint 19.3 (x86_64):

    • Clang 9.0.0 accepts -Wshadow-field and works as expected
    • GCC 7.5.0 does not accept -Wshadow-field

    The wider -Wshadow was disabled in #10136.

  18. practicalswift commented at 5:38 PM on June 6, 2020: contributor

    ACK fac6b9b938230d24c13fcb6e9be28515d674c6c8 -- patch looks correct

  19. MarcoFalke requested review from fanquake on Jun 7, 2020
  20. fanquake approved
  21. fanquake commented at 5:35 AM on June 8, 2020: member

    ACK fac6b9b938230d24c13fcb6e9be28515d674c6c8 - Warnings compiling fa16e7816b886b82d36457b0d8edc773cba76421 are below. No warnings with fac6b9b938230d24c13fcb6e9be28515d674c6c8. The -Wshadow-field diagnostic 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.
    
  22. fanquake merged this on Jun 8, 2020
  23. fanquake closed this on Jun 8, 2020

  24. MarcoFalke deleted the branch on Jun 8, 2020
  25. jasonbcox referenced this in commit 3de58c3057 on Jul 8, 2020
  26. DrahtBot locked this on Feb 15, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-02 15:14 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me