[cmake] Enable Clang warnings about redundant semicolons
authorMartin Storsjö <martin@martin.st>
Fri, 19 Mar 2021 11:47:43 +0000 (13:47 +0200)
committerMartin Storsjö <martin@martin.st>
Fri, 19 Mar 2021 16:49:05 +0000 (18:49 +0200)
This matches what GCC warns about when -pedantic is enabled.

This should avoid such redundant semicolons creeping into the codebase.

Differential Revision: https://reviews.llvm.org/D98941

llvm/cmake/modules/HandleLLVMOptions.cmake

index d85fe13..c250a77 100644 (file)
@@ -668,6 +668,11 @@ if (LLVM_ENABLE_WARNINGS AND (LLVM_COMPILER_IS_GCC_COMPATIBLE OR CLANG_CL))
   if (LLVM_ENABLE_PEDANTIC AND LLVM_COMPILER_IS_GCC_COMPATIBLE)
     append("-pedantic" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
     append("-Wno-long-long" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+
+    # GCC warns about redundant toplevel semicolons (enabled by -pedantic
+    # above), while Clang doesn't. Enable the corresponding Clang option to
+    # pick up on these even in builds with Clang.
+    add_flag_if_supported("-Wc++98-compat-extra-semi" CXX98_COMPAT_EXTRA_SEMI_FLAG)
   endif()
 
   add_flag_if_supported("-Wimplicit-fallthrough" IMPLICIT_FALLTHROUGH_FLAG)