[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:11:16 PST 2024


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

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]


>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] [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



More information about the llvm-commits mailing list