-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[clang] move -Wcast-function-type under -Wextra #76872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi! This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:
If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below. |
@llvm/issue-subscribers-good-first-issue Author: Nick Desaulniers (nickdesaulniers)
via https://github.com//issues/74617, I was looking into why I observe this diagnostic with gcc but not clang. It looks like our project (llvmlibc) builds with -Wextra but not -Wcast-function-type. GCC 8 added support for that flag, and did so under -Wextra.
|
The GCC build is producing the following diagnostic: llvm-project/libc/src/signal/linux/signal_utils.h: In member function ‘__llvm_libc_18_0_0_git::KernelSigaction& __llvm_libc_18_0_0_git::KernelSigaction::operator=(const sigaction&)’: llvm-project/libc/src/signal/linux/signal_utils.h:38:20: warning: cast between incompatible function types from ‘void (*)(int, siginfo_t*, void*)’ to ‘void (*)(int)’ [-Wcast-function-type] 38 | sa_handler = reinterpret_cast<HandlerType *>(sa.sa_sigaction); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ llvm-project/libc/src/signal/linux/signal_utils.h: In member function ‘__llvm_libc_18_0_0_git::KernelSigaction::operator sigaction() const’: llvm-project/libc/src/signal/linux/signal_utils.h:51:25: warning: cast between incompatible function types from ‘void (*)(int)’ to ‘void (*)(int, siginfo_t*, void*)’ [-Wcast-function-type] 51 | sa.sa_sigaction = reinterpret_cast<SiginfoHandlerType *>(sa_handler); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Two issues here: 1. Clang supports -Wcast-function-type, but not as part of the -Wextra group. 2. The existing implementation tried to work around the oddity that is the kernel's struct sigaction != POSIX via reinterpret_cast in a way that's not compatible with -Wcast-function-type. Just use a union which is well defined (and two function pointers are the same size.) Link: llvm#76872 Fixes: llvm#74617
#76875) The GCC build is producing the following diagnostic: llvm-project/libc/src/signal/linux/signal_utils.h: In member function ‘__llvm_libc_18_0_0_git::KernelSigaction& __llvm_libc_18_0_0_git::KernelSigaction::operator=(const sigaction&)’: llvm-project/libc/src/signal/linux/signal_utils.h:38:20: warning: cast between incompatible function types from ‘void (*)(int, siginfo_t*, void*)’ to ‘void (*)(int)’ [-Wcast-function-type] 38 | sa_handler = reinterpret_cast<HandlerType *>(sa.sa_sigaction); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ llvm-project/libc/src/signal/linux/signal_utils.h: In member function ‘__llvm_libc_18_0_0_git::KernelSigaction::operator sigaction() const’: llvm-project/libc/src/signal/linux/signal_utils.h:51:25: warning: cast between incompatible function types from ‘void (*)(int)’ to ‘void (*)(int, siginfo_t*, void*)’ [-Wcast-function-type] 51 | sa.sa_sigaction = reinterpret_cast<SiginfoHandlerType *>(sa_handler); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Two issues here: 1. Clang supports -Wcast-function-type, but not as part of the -Wextra group. 2. The existing implementation tried to work around the oddity that is the kernel's struct sigaction != POSIX via reinterpret_cast in a way that's not compatible with -Wcast-function-type. Just use a union which is well defined (and two function pointers are the same size.) Link: #76872 Fixes: #74617
Can I pick up this issue? |
@Abhinkop sure. I'd expect you to change clang/include/clang/Basic/DiagnosticGroups.td's record of |
@nickdesaulniers Here is the pull request #77178. |
The -Wcast-fuction-type-strict has been moved under dignstic group -Wextra. Edited the test cases for -Wcast-fuction-type-strict and -Wcast-fuction-type in Sema an SemaCXX. Added a new test case which include a functionality that was already in the -Wextra group, i.e -Wignored-qualifiers with -Wcast-fuction-type-strict. Fixes: #76872
The -Wcast-fuction-type-strict has been moved under dignstic group -Wextra. Edited the test cases for -Wcast-fuction-type-strict and -Wcast-fuction-type in Sema an SemaCXX. Added a new test case which include a functionality that was already in the -Wextra group, i.e -Wignored-qualifiers with -Wcast-fuction-type-strict. Fixes: llvm#76872
The -Wcast-fuction-type-strict has been moved under dignstic group -Wextra. Edited the test cases for -Wcast-fuction-type-strict and -Wcast-fuction-type in Sema an SemaCXX. Added a new test case which include a functionality that was already in the -Wextra group, i.e -Wignored-qualifiers with -Wcast-fuction-type-strict. Fixes: llvm#76872 Change-Id: I800fdce58c0429df56c07bfa17a7e3ba98684e8d
|
via #74617, I was looking into why I observe this diagnostic with gcc but not clang. It looks like our project (llvmlibc) builds with -Wextra but not -Wcast-function-type. GCC 8 added support for that flag, and did so under -Wextra.
The text was updated successfully, but these errors were encountered: