[compiler-rt] [compiler-rt] Work around a warning from -Wgnu-anonymous-struct (PR #120314)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 17 14:27:57 PST 2024


https://github.com/kazutakahirata updated https://github.com/llvm/llvm-project/pull/120314

>From 8ed101ff01b712dd8b4aaeb645d93d9635ef4b19 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 17 Dec 2024 14:05:26 -0800
Subject: [PATCH 1/2] [compiler-rt] Work around a warning from
 -Wgnu-anonymous-struct

This patch works around:

  compiler-rt/lib/tysan/../sanitizer_common/sanitizer_platform_limits_posix.h:604:3:
  error: anonymous structs are a GNU extension
  [-Werror,-Wgnu-anonymous-struct]
---
 .../lib/sanitizer_common/sanitizer_platform_limits_posix.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
index cacbb5b9959e0a..a5566d652580cb 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -601,6 +601,10 @@ struct __sanitizer_siginfo_pad {
 #if SANITIZER_LINUX
 # define SANITIZER_HAS_SIGINFO 1
 union __sanitizer_siginfo {
+# ifdef __clang__
+#  pragma clang diagnostic push
+#  pragma clang diagnostic ignored "-Wgnu-anonymous-struct"
+# endif
   struct {
     int si_signo;
 # if SANITIZER_MIPS
@@ -611,6 +615,9 @@ union __sanitizer_siginfo {
     int si_code;
 # endif
   };
+# ifdef __clang__
+#  pragma clang diagnostic pop
+# endif
   __sanitizer_siginfo_pad pad;
 };
 #else

>From 339ef9ab4c19fbd884dff1873179e8ae36ab192a Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Tue, 17 Dec 2024 14:24:08 -0800
Subject: [PATCH 2/2] Use __extension__ instead.

---
 .../sanitizer_common/sanitizer_platform_limits_posix.h   | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
index a5566d652580cb..ea0933ca64af1d 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -601,11 +601,7 @@ struct __sanitizer_siginfo_pad {
 #if SANITIZER_LINUX
 # define SANITIZER_HAS_SIGINFO 1
 union __sanitizer_siginfo {
-# ifdef __clang__
-#  pragma clang diagnostic push
-#  pragma clang diagnostic ignored "-Wgnu-anonymous-struct"
-# endif
-  struct {
+  __extension__ struct {
     int si_signo;
 # if SANITIZER_MIPS
     int si_code;
@@ -615,9 +611,6 @@ union __sanitizer_siginfo {
     int si_code;
 # endif
   };
-# ifdef __clang__
-#  pragma clang diagnostic pop
-# endif
   __sanitizer_siginfo_pad pad;
 };
 #else



More information about the llvm-commits mailing list