-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libc] -Wimplicit-fallthrough
, -Wwrite-strings
and non-GCC warnings
#124036
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
[libc] -Wimplicit-fallthrough
, -Wwrite-strings
and non-GCC warnings
#124036
Conversation
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
-Wunused-parameter
and few NOOPs-Wwrite-strings
and -Wextra -> -Wunused-parameter
-Wwrite-strings
and -Wextra -> -Wunused-parameter
-Wimplicit-fallthrough
and -Wwrite-strings
ca5a280
to
1c5c871
Compare
-Wimplicit-fallthrough
and -Wwrite-strings
-Wimplicit-fallthrough
, -Wwrite-strings
and non-GCC warnings
@llvm/pr-subscribers-libc Author: Vinay Deshmukh (vinay-deshmukh) Changes
See: #122835 (comment) Relates to #119281 Full diff: https://github.com/llvm/llvm-project/pull/124036.diff 1 Files Affected:
diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index 96fa6c3a707e47..e676130c6b9a81 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -33,8 +33,8 @@ function(_get_common_test_compile_options output_var c_test flags)
endif()
# list(APPEND compile_options "-Wconversion")
# list(APPEND compile_options "-Wno-sign-conversion")
- # list(APPEND compile_options "-Wimplicit-fallthrough")
- # list(APPEND compile_options "-Wwrite-strings")
+ list(APPEND compile_options "-Wimplicit-fallthrough")
+ list(APPEND compile_options "-Wwrite-strings")
list(APPEND compile_options "-Wextra-semi")
# Silence this warning because _Complex is a part of C99.
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
@@ -46,13 +46,13 @@ function(_get_common_test_compile_options output_var c_test flags)
list(APPEND compile_options "-Wno-gnu-imaginary-constant")
endif()
list(APPEND compile_options "-Wno-pedantic")
- # if(NOT CMAKE_COMPILER_IS_GNUCXX)
- # list(APPEND compile_options "-Wnewline-eof")
- # list(APPEND compile_options "-Wnonportable-system-include-path")
- # list(APPEND compile_options "-Wstrict-prototypes")
- # list(APPEND compile_options "-Wthread-safety")
- # list(APPEND compile_options "-Wglobal-constructors")
- # endif()
+ if(NOT CMAKE_COMPILER_IS_GNUCXX)
+ list(APPEND compile_options "-Wnewline-eof")
+ list(APPEND compile_options "-Wnonportable-system-include-path")
+ list(APPEND compile_options "-Wstrict-prototypes")
+ list(APPEND compile_options "-Wthread-safety")
+ # list(APPEND compile_options "-Wglobal-constructors")
+ endif()
endif()
set(${output_var} ${compile_options} PARENT_SCOPE)
endfunction()
|
Add @nickdesaulniers as reviewer Context: #122835 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the patch!
Sorry, I'm hitting some pre-existing build breakages with newer versions of gcc (#120427). I'd like to wait to get that resolved first, so that I can re-test this PR with both clang and gcc. |
Ok, I had to hack around a few issues (linked from this PR) to get our gcc-14 build working. But I'm confident this PR can land (once -Wextra-semi and -Wstrict-prototypes are moved back to clang-only for now). |
Fixes the diagnostic observed with gcc-14: llvm-project/libc/include/llvm-libc-macros/containerof-macro.h:17:13: error: cast from type ‘const char*’ to type ‘void*’ casts away qualifiers [-Werror=cast-qual] 17 | (type *)(void *)((const char *)__ptr - offsetof(type, member)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ We're trying to turn on more warnings for the tests in llvm#124036, so enable -Wcast-qual for GCC while we're at it.
@nickdesaulniers This PR should be good to go |
# Remove -fno-math-errno if it was added. | ||
if(LIBC_ADD_FNO_MATH_ERRNO) | ||
list(REMOVE_ITEM compile_options "-fno-math-errno") | ||
endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you intend to remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRFC yes, Oh I just realized that's removing -fno-math-error
let me revert that change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patch! Need us to merge this for you?
@nickdesaulniers Yes please merge it for me. Thank you! For the next work item, if I understand correctly, the plan is to uncomment these one by one and hence, patch each warning in it's own PR, right? llvm-project/libc/cmake/modules/LLVMLibCTestRules.cmake Lines 33 to 42 in 6807164
|
Exactly, thank you! |
…warnings (llvm#124036) * Enabled `-Wimplicit-fallthrough` * Enabled `-Wwrite-strings` * Enabled non-GCC warnings * Fix non-GCC to mean `clang` * Move `-Wstrict-prototypes` to common section See: llvm#122835 (comment) Relates to llvm#119281
-Wimplicit-fallthrough
-Wwrite-strings
clang
-Wstrict-prototypes
to common sectionSee: #122835 (comment)
Relates to #119281