]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
elf: Suppress unused function clang for __ifunc_resolver
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Fri, 3 Jan 2025 11:33:16 +0000 (08:33 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 13 Jan 2025 13:17:42 +0000 (10:17 -0300)
The __ifunc_resolver macro expands to:

  extern __typeof (__redirect_name) name __attribute__ ((ifunc ("iname_ifunc")));
  static __typeof (__redirect_name) *name_ifunc (void) { [...] };

And although NAME_IFUNC is and alias for NAME, clang-18 still emits
an 'unused function 'name_ifunc' [-Werror,-Wunused-function]'
warning.

elf/ifuncmain9.c
elf/tst-ifunc-fault-lazy.c

index b2c9547db37079df0c6d51ec5b75cfb83c342e58..64539b4a86adcf70850a4aeece9bc04707a9d3ce 100644 (file)
@@ -22,6 +22,7 @@
 
 #include <stdbool.h>
 #include <stdio.h>
+#include <libc-diag.h>
 
 #if __GNUC_PREREQ (5, 5)
 /* Do not use the test framework, so that the process setup is not
@@ -41,6 +42,8 @@ implementation (void)
   return random_constant;
 }
 
+DIAG_PUSH_NEEDS_COMMENT_CLANG;
+DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wunused-function");
 static __typeof__ (implementation) *
 inhibit_stack_protector
 resolver (void)
@@ -50,6 +53,7 @@ resolver (void)
 }
 
 static int magic (void) __attribute__ ((ifunc ("resolver")));
+DIAG_POP_NEEDS_COMMENT_CLANG;
 
 int
 main (void)
index c86edde06c876b30ebbfde249e58d19f12a5a71b..072d2c6a7b065bef116eef7f490333a0e540b27e 100644 (file)
@@ -21,6 +21,7 @@
    relocations.  */
 
 #include <config.h>
+#include <libc-diag.h>
 
 #ifdef HAVE_GCC_IFUNC
 
@@ -34,6 +35,8 @@ implementation (void)
   *p = 0;
 }
 
+DIAG_PUSH_NEEDS_COMMENT_CLANG;
+DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wunused-function");
 static __typeof__ (implementation) *
 resolver (void)
 {
@@ -42,6 +45,7 @@ resolver (void)
   *p = 0;
   return implementation;
 }
+DIAG_POP_NEEDS_COMMENT_CLANG;
 
 static void magic (void) __attribute__ ((ifunc ("resolver")));