[Clang][Sema] Implement GCC -Wcast-function-type
authorYuanfang Chen <yuanfang.chen@sony.com>
Wed, 24 Mar 2021 23:03:13 +0000 (16:03 -0700)
committerYuanfang Chen <yuanfang.chen@sony.com>
Wed, 24 Mar 2021 23:04:18 +0000 (16:04 -0700)
commit217f0f735afec57a51fa6f9ab863d4713a2f85e2
treea0fe7682c39c95c80c680280c62edf5f64c4c75e
parentef69aa961d12dee2141a79b05c9637d8cc9c0c74
[Clang][Sema] Implement GCC -Wcast-function-type

```
Warn when a function pointer is cast to an incompatible function
pointer. In a cast involving function types with a variable argument
list only the types of initial arguments that are provided are
considered. Any parameter of pointer-type matches any other
pointer-type. Any benign differences in integral types are ignored, like
int vs. long on ILP32 targets. Likewise type qualifiers are ignored. The
function type void (*) (void) is special and matches everything, which
can be used to suppress this warning. In a cast involving pointer to
member types this warning warns whenever the type cast is changing the
pointer to member type. This warning is enabled by -Wextra.
```

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D97831
clang/docs/DiagnosticsReference.rst
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaCast.cpp
clang/test/Sema/warn-cast-function-type.c [new file with mode: 0644]
clang/test/Sema/warn-cast-function-type.cpp [new file with mode: 0644]