[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
This commit is contained in:
Alex MacLean 2023-07-18 23:44:26 +00:00 committed by David Blaikie
parent b43df5bfe7
commit 621d1d07d9
2 changed files with 9 additions and 1 deletions

View File

@ -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

View File

@ -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;