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

via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 17 14:11:53 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>

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]


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


1 Files Affected:

- (modified) compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h (+7) 


``````````diff
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

``````````

</details>


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


More information about the llvm-commits mailing list