[PATCH] D34176: [cmake] Make sure that -Wcast-qual is not a error in preparation for clang's -Wcast-qual for C++

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 13 15:07:22 PDT 2017


lebedev.ri created this revision.
Herald added a subscriber: mgorny.

Diagnostic `-Wcast-qual` is not enabled by default in gcc/clang, It was enabled explicitly some time ago.
Later, clang has learned to do `-Wcast-qual`, like gcc does.
While that clang diagnostic is compatible with gcc's, it additionally catches one more case, see https://reviews.llvm.org/D34153.
And last but not least, clang's diagnostic `-Wcast-qual` only works for `C` code (sic!)
In https://reviews.llvm.org/D33102, i have extended it to work for `C++` code too.
Once that landed, `-Werror` buildbots broke. That is when i was made aware that this diagnostic is enabled in llvm builds.
I have fixed that particular buildbot-discovered failure in https://reviews.llvm.org/D34153.
However, when i tried building clang stage2 with self-built clang stage1 (with https://reviews.llvm.org/D33102), i have quickly discovered that some sub-projects also exhibit this warning.
Specifically, **openmp** and **libcxx** subprojects produce **401** -Wcast-qual warnings, and i //believe// not all of these warnings are clang-specific.
(i don't think i have all subprojects checked-out, so there may be even more)
This tells two things:

- these subprojects are not being built by `-Werror` buildbots. (at least as part of LLVM, not standalone)
- no one builds LLVM by GCC with these subprojects with `-Werror` enabled.

So, if https://reviews.llvm.org/D33102 is to land, this //may// not break `-Werror` buildbots. This is bad and good.
But. If someone wants to build LLVM with these subprojects and with  `-Werror`, he/she/it will face a lot of fatal warnings.
It is unfeasible for me to fix all these warnings before re-landing https://reviews.llvm.org/D33102, thus i propose this diff.

After https://reviews.llvm.org/D33102 has landed, the buildbots should //probably// be adjusted to catch these cases, and i will see if i can help fix these issues and revert this patch.

Thoughts?


Repository:
  rL LLVM

https://reviews.llvm.org/D34176

Files:
  cmake/modules/HandleLLVMOptions.cmake


Index: cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- cmake/modules/HandleLLVMOptions.cmake
+++ cmake/modules/HandleLLVMOptions.cmake
@@ -521,6 +521,7 @@
 if (LLVM_ENABLE_WARNINGS AND (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL))
   append("-Wall -W -Wno-unused-parameter -Wwrite-strings" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
   append("-Wcast-qual" CMAKE_CXX_FLAGS)
+  append("-Wno-error=cast-qual" 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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34176.102422.patch
Type: text/x-patch
Size: 629 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170613/c6d62d7c/attachment.bin>


More information about the llvm-commits mailing list