diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -736,7 +736,7 @@ 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 --- a/llvm/lib/Support/regcomp.c +++ b/llvm/lib/Support/regcomp.c @@ -329,7 +329,15 @@ /* 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;