| 1 | // RUN: %check_clang_tidy %s google-explicit-constructor %t -std=c++20-or-later |
| 2 | |
| 3 | namespace issue_81121 |
| 4 | { |
| 5 | |
| 6 | static constexpr bool ConstFalse = false; |
| 7 | static constexpr bool ConstTrue = true; |
| 8 | |
| 9 | struct A { |
| 10 | explicit(true) A(int); |
| 11 | }; |
| 12 | |
| 13 | struct B { |
| 14 | explicit(false) B(int); |
| 15 | }; |
| 16 | |
| 17 | struct C { |
| 18 | explicit(ConstTrue) C(int); |
| 19 | }; |
| 20 | |
| 21 | struct D { |
| 22 | explicit(ConstFalse) D(int); |
| 23 | // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: single-argument constructors explicit expression evaluates to 'false' [google-explicit-constructor] |
| 24 | }; |
| 25 | |
| 26 | template <typename> |
| 27 | struct E { |
| 28 | explicit(true) E(int); |
| 29 | }; |
| 30 | |
| 31 | template <typename> |
| 32 | struct F { |
| 33 | explicit(false) F(int); |
| 34 | }; |
| 35 | |
| 36 | template <typename> |
| 37 | struct G { |
| 38 | explicit(ConstTrue) G(int); |
| 39 | }; |
| 40 | |
| 41 | template <typename> |
| 42 | struct H { |
| 43 | explicit(ConstFalse) H(int); |
| 44 | // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: single-argument constructors explicit expression evaluates to 'false' [google-explicit-constructor] |
| 45 | }; |
| 46 | |
| 47 | template <int Val> |
| 48 | struct I { |
| 49 | explicit(Val > 0) I(int); |
| 50 | }; |
| 51 | |
| 52 | template <int Val> |
| 53 | struct J { |
| 54 | explicit(Val > 0) J(int); |
| 55 | }; |
| 56 | |
| 57 | void useJ(J<0>, J<100>); |
| 58 | |
| 59 | } // namespace issue_81121 |
| 60 | |