================ @@ -882,6 +882,11 @@ if (LLVM_ENABLE_WARNINGS AND (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL)) # The LLVM libraries have no stable C++ API, so -Wnoexcept-type is not useful. append("-Wno-noexcept-type" CMAKE_CXX_FLAGS) + # LLVM has a policy of including virtual "anchor" functions to control + # where the vtable is emitted. In `final` classes, these are exactly what + # this warning detects: unnecessary virtual methods. + add_flag_if_supported("-Wno-unnecessary-virtual-specifier" CXX_SUPPORTS_UNNECESSARY_VIRTUAL_FLAG) ---------------- mstorsjo wrote:
This has the unintended side effect of producing a lot more warning spam when building with GCC. (Also, this bit, of enabling the new warning flag in building LLVM, feels like a separate thing including the flag within `-Wextra` in Clang.) Anyway; the issue with this kind of option wrt GCC, is that GCC silently accepts any random `-Wno-foobar` even if it isn't recognized. If you're requesting to not have "foobar" warnings, and GCC doesn't even know "foobar" warnings, it certainly won't produce any such warnings - so that option gets accepted silently. However - if GCC ends up producing any other warning, it will print an extra note like this: ``` cc1plus: note: unrecognized command-line option ‘-Wno-unnecessary-virtual-specifier’ may have been intended to silence earlier diagnostics ``` Due to this, the way to add negative warning options like this, is to test for the positive form of the option, and if that is supported, add the negative form. See e546bbfda0ab91cf78c096d8c035851cc7c3b9f3 for earlier examples of how this has been done. https://github.com/llvm/llvm-project/pull/138741 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits