[llvm] [LLVMgold] Suppress -Wcast-function-type-mismatch diagnostic (PR #89994)

via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 24 14:29:29 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lto

Author: Fangrui Song (MaskRay)

<details>
<summary>Changes</summary>

llvm/cmake/modules/HandleLLVMOptions.cmake adds -Wextra.
-Wcast-function-type-mismatch was recently added to -Wextra, leading to
a warning for the `get_wrap_symbols` code (https://reviews.llvm.org/D44235).

Suppress the diagnostic.


---
Full diff: https://github.com/llvm/llvm-project/pull/89994.diff


1 Files Affected:

- (modified) llvm/tools/gold/gold-plugin.cpp (+8-2) 


``````````diff
diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp
index b8a33f74bd570f..b8431334f8487c 100644
--- a/llvm/tools/gold/gold-plugin.cpp
+++ b/llvm/tools/gold/gold-plugin.cpp
@@ -434,8 +434,14 @@ ld_plugin_status onload(ld_plugin_tv *tv) {
       // FIXME: When binutils 2.31 (containing gold 1.16) is the minimum
       // required version, this should be changed to:
       // get_wrap_symbols = tv->tv_u.tv_get_wrap_symbols;
-      get_wrap_symbols =
-          (ld_plugin_get_wrap_symbols)tv->tv_u.tv_message;
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wcast-function-type"
+#endif
+      get_wrap_symbols = (ld_plugin_get_wrap_symbols)tv->tv_u.tv_message;
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
       break;
     default:
       break;

``````````

</details>


https://github.com/llvm/llvm-project/pull/89994


More information about the llvm-commits mailing list