dawn/common: Fix warning-as-error for GCC
The "cfi-derived-cast" attribute is only understood by clang
Change-Id: I981ae4d5df7dd71f529dbd6456ac5d7ecd586b94
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/149681
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/dawn/common/WeakRefSupport.h b/src/dawn/common/WeakRefSupport.h
index 6aee72b..fe23778 100644
--- a/src/dawn/common/WeakRefSupport.h
+++ b/src/dawn/common/WeakRefSupport.h
@@ -63,10 +63,12 @@
template <typename T>
class WeakRefSupport : public detail::WeakRefSupportBase {
public:
+#if DAWN_COMPILER_IS(CLANG)
// Note that the static cast below fails CFI builds due to the cast. The cast itself is
// safe so we suppress the failure. See the following link regarding the cast:
// https://stackoverflow.com/questions/73172193/can-you-static-cast-this-to-a-derived-class-in-a-base-class-constructor-then-u,
DAWN_NO_SANITIZE("cfi-derived-cast")
+#endif
WeakRefSupport()
: WeakRefSupportBase(AcquireRef(new detail::WeakRefData(static_cast<T*>(this)))) {}
};