[PATCH] D118737: [CMake] Disable LLVM_ENABLE_PEDANTIC by default for GCC

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 1 13:53:36 PST 2022


MaskRay created this revision.
MaskRay added a reviewer: mstorsjo.
Herald added a subscriber: mgorny.
MaskRay requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Motivated by D118551 <https://reviews.llvm.org/D118551>:
`warning: ISO C++11 requires at least one argument for the "..." in a variadic macro  `
cannot be suppressed by `#pragma GCC diagnostic ignored "-Wpedantic"`.
(no diagnostic in -std=c++20 mode)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118737

Files:
  llvm/CMakeLists.txt


Index: llvm/CMakeLists.txt
===================================================================
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -456,9 +456,18 @@
 option(LLVM_ENABLE_LIBCXX "Use libc++ if available." OFF)
 option(LLVM_STATIC_LINK_CXX_STDLIB "Statically link the standard library." OFF)
 option(LLVM_ENABLE_LLD "Use lld as C and C++ linker." OFF)
-option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
 option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
 
+if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+  # -pedantic may warn on extensions from newer standards that are widely ported
+  # to older language modes. They are usually of lower value and cannot be
+  # suppressed by pragma ( https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90843),
+  # so we just disable -pedantic by default.
+  option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled" OFF)
+else()
+  option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled" ON)
+endif()
+
 option(LLVM_ENABLE_DUMP "Enable dump functions even when assertions are disabled" OFF)
 
 if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118737.405094.patch
Type: text/x-patch
Size: 1133 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220201/176ceca2/attachment.bin>


More information about the llvm-commits mailing list