build: Enable some commonly enabled compiler diagnostics
as discussed in #17344
There is a large overlap between this list and Jason Turner's list of recommended compiler diagnostics in the Collaborative Collection of C++ Best Practices (cppbestpractices) project. There is also an overlap with the recommendations given in the C++ Core Guidelines (with editors Bjarne Stroustrup and Herb Sutter).
This is a backport of core#19015
Disable -Wduplicated-branches for secp256k1, because of some exotic intentional use of ternary operator duplicated branches in test_inverse_scalar.
cmake .. -GNinja -DCMAKE_CXX_FLAGS=-Werror -DCMAKE_C_FLAGS=-Werror ninja && ninja check && ninja check-secp256k1 rm -Rf * cmake .. -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS=-Werror -DCMAKE_C_FLAGS=-Werror ninja && ninja check && ninja check-secp256k1
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D10113