[PATCH] D97831: [Clang][Sema] Implement GCC -Wcast-function-type
Yuanfang Chen via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 2 21:10:18 PST 2021
ychen created this revision.
ychen added reviewers: aaron.ballman, rsmith.
ychen requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
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.
It is not part of -Wextra for now. I could add it if it is preferred.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D97831
Files:
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
clang/test/Sema/warn-cast-function-type.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97831.327664.patch
Type: text/x-patch
Size: 10911 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210303/9b5bd471/attachment.bin>
More information about the cfe-commits
mailing list