[clang] [clang] Add diagnostic for usage of implicit constructor with pointer to bool convertion (PR #143990)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 26 07:25:10 PDT 2025


================
@@ -234,3 +234,34 @@ namespace Template {
   template void h<d>();
 }
 #endif // __cplusplus < 201703L
+
+namespace implicit_constructor_bool {
+
+struct B {
+  bool a;
+  B(bool V) : a(V) {} // expected-note {{'B' declared here}}
+};
+
+void test(const B& b);
+
+void test0(B* b) {
+  test(b); // expected-warning {{implicit conversion from 'B *' to 'const B' calls}}
----------------
AaronBallman wrote:

You should include the whole diagnostic text in the expected-warning.

https://github.com/llvm/llvm-project/pull/143990


More information about the cfe-commits mailing list