Issue |
146924
|
Summary |
[Clang] improve -Wimplicit-function-declaration wording
|
Labels |
clang
|
Assignees |
|
Reporter |
manxorist
|
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.*
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs