summaryrefslogtreecommitdiffstats
path: root/googletest
diff options
context:
space:
mode:
authorDerek Mauro <dmauro@google.com>2022-10-17 23:15:24 (GMT)
committerCopybara-Service <copybara-worker@google.com>2022-10-17 23:15:59 (GMT)
commit26d3ab54422257b65452d5feeb080c015eabf5e8 (patch)
tree3ff56b4293a64431fb6ef4877de1fd020f385b95 /googletest
parent6d71d901e1a5dc3460cdcdce091e4e99e68940dd (diff)
downloadgoogletest-26d3ab54422257b65452d5feeb080c015eabf5e8.zip
googletest-26d3ab54422257b65452d5feeb080c015eabf5e8.tar.gz
googletest-26d3ab54422257b65452d5feeb080c015eabf5e8.tar.bz2
Fix detection of the no_sanitize("hwaddress") attribute
PiperOrigin-RevId: 481765573 Change-Id: I1ba829c3cbf364a51d3ba383ee3b474c0e109578
Diffstat (limited to 'googletest')
-rw-r--r--googletest/include/gtest/internal/gtest-port.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h
index 50d4c41..005a0c0 100644
--- a/googletest/include/gtest/internal/gtest-port.h
+++ b/googletest/include/gtest/internal/gtest-port.h
@@ -658,6 +658,16 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
#define GTEST_HAVE_ATTRIBUTE_(x) 0
#endif
+// GTEST_HAVE_FEATURE_
+//
+// A function-like feature checking macro that is a wrapper around
+// `__has_feature`.
+#ifdef __has_feature
+#define GTEST_HAVE_FEATURE_(x) __has_feature(x)
+#else
+#define GTEST_HAVE_FEATURE_(x) 0
+#endif
+
// Use this annotation at the end of a struct/class definition to
// prevent the compiler from optimizing away instances that are never
// used. This is useful when all interesting logic happens inside the
@@ -812,7 +822,8 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION;
#endif
// A function level attribute to disable HWAddressSanitizer instrumentation.
-#if GTEST_HAVE_ATTRIBUTE_(no_sanitize)
+#if GTEST_HAVE_FEATURE_(hwaddress_sanitizer) && \
+ GTEST_HAVE_ATTRIBUTE_(no_sanitize)
#define GTEST_ATTRIBUTE_NO_SANITIZE_HWADDRESS_ \
__attribute__((no_sanitize("hwaddress")))
#else