Fix Android standalone compilation Fixes standalone Android compilation not working due to `memcpy` not being flagged as unsafe. This appears to be due to an incompatibility between how Clang's checker works and how `memcpy` is defined for Android. This is worked around by omitting the failing test when compiling for Android. Bug: 520153663 Change-Id: I783ba9c804f677bad1e9011ad0890dab077bd49a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/323495 Commit-Queue: Brian Sheedy <bsheedy@google.com> Auto-Submit: Brian Sheedy <bsheedy@google.com> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Kai Ninomiya <kainino@chromium.org>
diff --git a/src/utils/warning_nocompile.nc b/src/utils/warning_nocompile.nc index 2596a0f..5f7cb45 100644 --- a/src/utils/warning_nocompile.nc +++ b/src/utils/warning_nocompile.nc
@@ -67,11 +67,18 @@ } // -Wunsafe-buffer-usage-in-libc-call: memcpy() +// This is skipped on Android because with Android Bionic's _FORTIFY_SOURCE, +// memcpy is a static inline wrapper (__BIONIC_FORTIFY_INLINE). This causes +// Clang's unsafe-buffer-usage checker to ignore it (as it only matches global +// functions or std:: functions), which then causes the expected error to not +// be raised. +#if !defined(__ANDROID__) void TestUnsafeBuffersMemcpy() { int x = 1; int y = 2; memcpy(&y, &x, sizeof(int)); // expected-error {{function 'memcpy' is unsafe}} } +#endif // !defined(__ANDROID__) // -Wunsafe-buffer-usage: std::span() constructors void TestUnsafeBuffersStdSpanConstructors() {