[libc-commits] [libc] 9b8dbe2 - [libc][complex] Fix compiler warnings for usage of complex.h header. (#112282)

via libc-commits libc-commits at lists.llvm.org
Mon Oct 14 16:33:25 PDT 2024


Author: lntue
Date: 2024-10-14T19:33:22-04:00
New Revision: 9b8dbe2c8d8f9ba31db572d218ed00dcb283eaba

URL: https://github.com/llvm/llvm-project/commit/9b8dbe2c8d8f9ba31db572d218ed00dcb283eaba
DIFF: https://github.com/llvm/llvm-project/commit/9b8dbe2c8d8f9ba31db572d218ed00dcb283eaba.diff

LOG: [libc][complex] Fix compiler warnings for usage of complex.h header. (#112282)

Added: 
    

Modified: 
    libc/cmake/modules/LLVMLibCCompileOptionRules.cmake

Removed: 
    


################################################################################
diff  --git a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
index e3a111c62cdb71..3846c597e6894f 100644
--- a/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
+++ b/libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
@@ -153,8 +153,13 @@ function(_get_common_compile_options output_var flags)
     list(APPEND compile_options "-Wconversion")
     list(APPEND compile_options "-Wno-sign-conversion")
     # Silence this warning because _Complex is a part of C99.
-    list(APPEND compile_options "-Wno-c99-extensions")
-    list(APPEND compile_options "-Wno-pedantic")
+    if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+      list(APPEND compile_options "-fext-numeric-literals")
+      list(APPEND compile_options "-Wno-pedantic")
+    else()
+      list(APPEND compile_options "-Wno-c99-extensions")
+      list(APPEND compile_options "-Wno-gnu-imaginary-constant")
+    endif()
     list(APPEND compile_options "-Wimplicit-fallthrough")
     list(APPEND compile_options "-Wwrite-strings")
     list(APPEND compile_options "-Wextra-semi")
@@ -210,7 +215,7 @@ function(_get_common_test_compile_options output_var c_test flags)
       list(APPEND compile_options "-fno-exceptions")
       list(APPEND compile_options "-fno-unwind-tables")
       list(APPEND compile_options "-fno-asynchronous-unwind-tables")
-      if(NOT ${c_test})
+      if(NOT c_test)
         list(APPEND compile_options "-fno-rtti")
       endif()
     endif()
@@ -231,8 +236,15 @@ function(_get_common_test_compile_options output_var c_test flags)
     # list(APPEND compile_options "-Wwrite-strings")
     # list(APPEND compile_options "-Wextra-semi")
     # Silence this warning because _Complex is a part of C99.
-    list(APPEND compile_options "-Wno-c99-extensions")
-    list(APPEND compile_options "-Wno-pedantic")
+    if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+      if(NOT c_test)
+        list(APPEND compile_options "-fext-numeric-literals")
+        list(APPEND compile_options "-Wno-pedantic")
+      endif()
+    else()
+      list(APPEND compile_options "-Wno-c99-extensions")
+      list(APPEND compile_options "-Wno-gnu-imaginary-constant")
+    endif()
     # if(NOT CMAKE_COMPILER_IS_GNUCXX)
     #   list(APPEND compile_options "-Wnewline-eof")
     #   list(APPEND compile_options "-Wnonportable-system-include-path")


        


More information about the libc-commits mailing list