[llvm] 621d1d0 - [cmake] Add -Wcast-qual to C flags if LLVM_ENABLE_WARNINGS is defined.
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 18 16:45:06 PDT 2023
Author: Alex MacLean
Date: 2023-07-18T23:44:55Z
New Revision: 621d1d07d9c426875323ed7a996758477ae33517
URL: https://github.com/llvm/llvm-project/commit/621d1d07d9c426875323ed7a996758477ae33517
DIFF: https://github.com/llvm/llvm-project/commit/621d1d07d9c426875323ed7a996758477ae33517.diff
LOG: [cmake] Add -Wcast-qual to C flags if LLVM_ENABLE_WARNINGS is defined.
Disable this warning for specific cast in llvm_regcomp().
Reviewed By: dblaikie
Differential Revision: https://reviews.llvm.org/D153911
Added:
Modified:
llvm/cmake/modules/HandleLLVMOptions.cmake
llvm/lib/Support/regcomp.c
Removed:
################################################################################
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 365c8b962d42eb..8692af9039ac52 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -741,7 +741,7 @@ if (LLVM_ENABLE_WARNINGS AND (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL))
endif()
append("-Wextra -Wno-unused-parameter -Wwrite-strings" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
- append("-Wcast-qual" CMAKE_CXX_FLAGS)
+ append("-Wcast-qual" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
# Turn off missing field initializer warnings for gcc to avoid noise from
# false positives with empty {}. Turn them on otherwise (they're off by
diff --git a/llvm/lib/Support/regcomp.c b/llvm/lib/Support/regcomp.c
index 9d484195a6d6d2..4e9082cec45696 100644
--- a/llvm/lib/Support/regcomp.c
+++ b/llvm/lib/Support/regcomp.c
@@ -329,7 +329,15 @@ llvm_regcomp(llvm_regex_t *preg, const char *pattern, int cflags)
/* set things up */
p->g = g;
+ /* suppress warning from the following explicit cast. */
+#ifdef __GNUC__
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-qual"
+#endif /* __GNUC__ */
p->next = (char *)pattern; /* convenience; we do not modify it */
+#ifdef __GNUC__
+#pragma GCC diagnostic pop
+#endif /* __GNUC__ */
p->end = p->next + len;
p->error = 0;
p->ncsalloc = 0;
More information about the llvm-commits
mailing list