Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 18, 2024

Conversation

kazutakahirata
Copy link
Contributor

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]

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]
@llvmbot
Copy link
Member

llvmbot commented Dec 17, 2024

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

Author: Kazu Hirata (kazutakahirata)

Changes

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

Copy link

github-actions bot commented Dec 17, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@tavianator
Copy link
Contributor

tavianator commented Dec 17, 2024

Would it work to just add __extension__ instead?

@kazutakahirata
Copy link
Contributor Author

Would it work to just add __extension__ instead?

That works. It's a lot simpler. Thanks!

Copy link
Contributor

@chapuni chapuni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please go ahead. Better than nothing. Thanks!

@kazutakahirata kazutakahirata merged commit f8b497e into llvm:main Dec 18, 2024
7 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_000 branch December 18, 2024 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants