<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/106392>106392</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            extend `returns_nonnull` function attribute diagnostics
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            enhancement,
            clang:diagnostics
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          firewave
      </td>
    </tr>
</table>

<pre>
    ```cpp
__attribute__((returns_nonnull)) void* func();

static void f1()
{
    if (func()) {} // warning
}

static void f2()
{
    void* p = func();
    if (p) {} // no warning
}
```

```
<source>:5:9: warning: nonnull function call 'func()' will evaluate to 'true' on first encounter [-Wpointer-bool-conversion]
    5 |     if (func()) {} // warning
 |     ~~  ^~~~~~
<source>:1:16: note: declared 'returns_nonnull' here
 1 | __attribute__((returns_nonnull)) void* func();
      | 
```

https://godbolt.org/z/x3r5oP6db

I guess this is out of scope of the existing warning and would require a clang-tidy or static analyzer check instead.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVE1zqzgQ_DXDZcoukMzXgYMTP1ftbW97dAlpAO0qEqsPJ3mH_PYtsBO78pI9bK3LIEA9090zAyIEPVqiDsoHKA-ZSHFyvhu0p2dxpqx36rWDKr_85TxDfoB8fzqJGL3uU6TTCVgDrPEUk7fhZJ21yRhgLbAWz04rYHsckpUrrgX-cMlxOYcoopYrDofiCrns11cgIqIeEFhzl4W1uADqAwI7Ajvis_BW2_E99vAtCfuW5F3sjMAPX0m-KZl_FWDddxrey3cv6fND_hhc8pKA_wC-L4HvW-D7j4x8j9fCrrqidhalMAaB1fdVqfFZG4N0FiaJSBjdgog-0bLnLA7ah4hkpUs2kkcoHzZ_zE4vN5veObORzp7JB-0slIeb7xKhfsT_0IuPuLc3RCh_vC2_L10Xy1FdvEZaVkXSCE9qMfHLgNU4kacrSbHS_B9zuWpds_1L-6YY5wB8fzE8OtU7E7fOj8COP4EdX7gv3e-V6u-DfsMxUQgYJx1QB3QpohswSDfTchEnQnrRIWo7vtcQhVX47JJR6OnvpD2hQGmEHTdRq1d0Hq_TLawwrz_Jo5xI_oXahkhCbTPVcdXyVmTUFTXbNSWrqyqbupoKxfqmEUIxvuOqqkUrSTQ9qaqkoc10x3K2yxvWFHxX5dW2HkQ5NIPa7QpZtUUJu5yehDZbY85Pi_lMh5CoK_KKtywzoicT1i8LY2QnYSU9kY3AGLBHYGy1AXyvtBitC1HLsOyVh8x3S8pNn8YAu9zoEMONJOpoqKOXSFYhVPnnDlf57R35GAe8I8mSN92nDuo4pX4r3ROw48J0XTazd3-SjMCOq7cA7Hi1d-7YPwEAAP__ZFuO6g">