unit: Fix ASAN detection for GCC. (#2561)
authorMathias Preiner <mathias.preiner@gmail.com>
Wed, 3 Oct 2018 00:30:54 +0000 (17:30 -0700)
committerAina Niemetz <aina.niemetz@gmail.com>
Wed, 3 Oct 2018 00:30:54 +0000 (17:30 -0700)
test/unit/memory.h

index 86b024fa9c2932983cdf5db63ad41b52e6ad3a2d..a4d650b3b610d76c519dab595443c076434e5ec0 100644 (file)
 #  define CVC4_MEMORY_LIMITING_DISABLED 1
 #  define CVC4_MEMORY_LIMITING_DISABLED_REASON "setrlimit() is broken on Mac."
 #else /* __APPLE__ */
+// Clang test
 #  if defined(__has_feature)
 #    if __has_feature(address_sanitizer)
-// Tests cannot expect bad_alloc to be thrown due to limit memory using
-// setrlimit when ASAN is enable. ASAN instead aborts on mmap failures.
-#      define CVC4_MEMORY_LIMITING_DISABLED 1
-#      define CVC4_MEMORY_LIMITING_DISABLED_REASON "ASAN's mmap failures abort."
+#      define _IS_ASAN_BUILD
 #    endif /* __has_feature(address_sanitizer) */
 #  endif /* defined(__has_feature) */
+
+// GCC test
+#  if defined(__SANITIZE_ADDRESS__)
+#    define _IS_ASAN_BUILD
+#  endif /* defined(__SANITIZE_ADDRESS__) */
+
+// Tests cannot expect bad_alloc to be thrown due to limit memory using
+// setrlimit when ASAN is enable. ASAN instead aborts on mmap failures.
+#  if defined(_IS_ASAN_BUILD)
+#    define CVC4_MEMORY_LIMITING_DISABLED 1
+#    define CVC4_MEMORY_LIMITING_DISABLED_REASON "ASAN's mmap failures abort."
+#    undef _IS_ASAN_BUILD
+#  endif /* defined(_IS_ASAN_BUILD) */
 #endif