[clang] [Sema] -Wpointer-bool-conversion: suppress lambda function pointer conversion diagnostic during instantiation (PR #83497)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 1 05:02:34 PST 2024


================
@@ -92,6 +92,19 @@ void foo() {
   bool is_true = [](){ return true; };
   // expected-warning at -1{{address of lambda function pointer conversion operator will always evaluate to 'true'}}
 }
+
+template <typename... Ts>
+static bool IsFalse(const Ts&...) { return false; }
+template <typename T>
+static bool IsFalse(const T& p) {
+  bool b;
+  b = f7; // expected-warning {{address of lambda function pointer conversion operator will always evaluate to 'true'}}
+  return p ? false : true;
----------------
AaronBallman wrote:

```suggestion
  // Intentionally not warned on because p could be a lambda type in one instantiation, but a pointer
  // type in another.
  return p ? false : true;
```
(May need to adjust for 80-col limits.)

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


More information about the cfe-commits mailing list