test: Add linter to make sure single parameter constructors are marked explicit#14505
Conversation
|
Concept ACK. @practicalswift is there a compiler flag to detect these? |
|
@promag Perhaps surprisingly clang and GCC lack such a warning AFAIK, but the Intel C++ Compiler has it. Also most C++ linters support flagging single parameter constructors not declared |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
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. |
95d1431 to
8113aeb
Compare
8113aeb to
dcd77cc
Compare
934811f to
1236d01
Compare
|
@MarcoFalke Good point! I've now added a Travis check that will catch newly introduced single-argument constructors not declare |
710e02a to
5a4b5fa
Compare
5a4b5fa to
c191011
Compare
|
@promag Would you mind reviewing the updated version which contains the automatic Travis checking for If merged we'll never have to think about |
|
utACK c191011 - could squash the first five commits, and "all" is not strictly accurate given the linter exceptions. |
|
@MarcoFalke Can this one get a release milestone? :-) |
|
This is controversial in its current form. See #14505 (comment) I guess I'd be ok with it if it would never fail (and only print the warnings), like the spell-checker. |
6871f37 to
2eb79c3
Compare
|
@MarcoFalke Updated. The updated version never fails: it only prints the warnings -- like the spell-checker. Looks good? :-) |
|
utACK 2eb79c3601bfb4bff140693b3225aa4779d73390 |
|
utACK 2eb79c3 |
48fda19 to
64b0cf1
Compare
|
Fixed typo identified by @Empact and squashed. @Empact @MarcoFalke @promag Would you mind re-reviewing? :-) |
64b0cf1 to
c4606b8
Compare
|
ACK c4606b8 |
…tors are marked explicit c4606b8 Add Travis check for single parameter constructors not marked "explicit" (practicalswift) Pull request description: Make single parameter constructors `explicit` (C++11). Rationale from the developer notes: > - By default, declare single-argument constructors `explicit`. > - *Rationale*: This is a precaution to avoid unintended conversions that might > arise when single-argument constructors are used as implicit conversion > functions. ACKs for top commit: laanwj: ACK c4606b8 Tree-SHA512: 3e6fd51935fd93b2604b2188664692973d0897469f814cd745b5147d71b99ea5d73c1081cfde9f6393f51f56969e412fcda35d2d54e938a3235b8d40945f31fd
| echo "Advice not applicable in this specific case? Add an exception by updating" | ||
| echo "IGNORED_WARNINGS in $0" | ||
| # Uncomment to enforce the developer note policy "By default, declare single-argument constructors `explicit`" | ||
| # exit 1 |
There was a problem hiding this comment.
It could be enabled, but guarded by a allow_failures travis flag?
…onstructors are marked explicit c4606b8 Add Travis check for single parameter constructors not marked "explicit" (practicalswift) Pull request description: Make single parameter constructors `explicit` (C++11). Rationale from the developer notes: > - By default, declare single-argument constructors `explicit`. > - *Rationale*: This is a precaution to avoid unintended conversions that might > arise when single-argument constructors are used as implicit conversion > functions. ACKs for top commit: laanwj: ACK c4606b8 Tree-SHA512: 3e6fd51935fd93b2604b2188664692973d0897469f814cd745b5147d71b99ea5d73c1081cfde9f6393f51f56969e412fcda35d2d54e938a3235b8d40945f31fd
Summary: This is a backport of core [[bitcoin/bitcoin#14505 | PR14505]], but the linter part will be set in another diff. Test Plan: ninja all check Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D6547
…onstructors are marked explicit c4606b8 Add Travis check for single parameter constructors not marked "explicit" (practicalswift) Pull request description: Make single parameter constructors `explicit` (C++11). Rationale from the developer notes: > - By default, declare single-argument constructors `explicit`. > - *Rationale*: This is a precaution to avoid unintended conversions that might > arise when single-argument constructors are used as implicit conversion > functions. ACKs for top commit: laanwj: ACK c4606b8 Tree-SHA512: 3e6fd51935fd93b2604b2188664692973d0897469f814cd745b5147d71b99ea5d73c1081cfde9f6393f51f56969e412fcda35d2d54e938a3235b8d40945f31fd
Make single parameter constructors
explicit(C++11).Rationale from the developer notes: