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

    <tr>
        <th>Summary</th>
        <td>
            [Clang] improve -Wimplicit-function-declaration wording
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

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

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

<pre>
    In the folowing code
```c
int foo1(int x) {
    return exp(x);
}
int foo2(int x) {
    return erfc(x);
}
int foo3(int x) {
    return unknown_function(x);
}
```
Clang diagnoses:
`warning: implicitly declaring library function 'exp' with type 'double (double)' [-Wimplicit-function-declaration]`
`warning: implicitly declaring library function 'erfc' with type 'double (double)' [-Wimplicit-function-declaration]`
`warning: implicit declaration of function 'unknown_function' [-Wimplicit-function-declaration]`
(<https://godbolt.org/z/zq4jsnfnh>)
Clang assumes the standard-mandated function declaration with type `double (double)` in both cases. This is fine for `exp`, however it can be a bit surprising for `erfc` which does not exist in C89.

In C89, an implicitly declared function is a variadic function returning `int`. I think (as a non-native English speaker), the current warning can possibly be interpreted as **"the function was implicitly declared (as in K&R C), *in contrast* to the standard library function that is declared with type 'double (double)"**. I think a wording like **"implicitly declaring library function 'erfc', assuming standard-mandated type 'double (double)' instead"** would be much clearer (for both cases), as it would more clearly communicate what Clang actually does generate.

The improved wording would also be suitable for more modern standard versions.

*This issue came up as a side note in a [mastodon discussion](https://mastodon.online/@manx/114790075079976894). @AaronBallman asked me to report this as an issue.*
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8Vk-P4rgT_TTmUgI5DvnDgUOaHqTR7_bTSHtcVeKCeNqxWduBZj_9qhIYerZnpzV7WIkW6cRV9eq9VxUwRnN0RFtRPInieYFj6n3YDuhefTAxLVqvr9vPDlJPcPDWX4w7Quc1CdmIUs6fTsjGuAQH7zOhar58FWoDonoSsg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