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

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 24 14:28:51 PDT 2024


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

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.


>From 69285168c9c009d2a760167ea79060cc84fdea9d Mon Sep 17 00:00:00 2001
From: Fangrui Song <i at maskray.me>
Date: Wed, 24 Apr 2024 14:28:41 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.5-bogner
---
 llvm/tools/gold/gold-plugin.cpp | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

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;



More information about the llvm-commits mailing list