[binutils-gdb] Re: Define BFD_ASAN to detect asan
Alan Modra via Binutils-cvs <[email protected]>
| Newsgroups | gmane.comp.gnu.binutils.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0b58bc79598ae63a5b515ac497ade86cd671a5c3 commit 0b58bc79598ae63a5b515ac497ade86cd671a5c3 Author: Alan Modra <[email protected]> Date: Tue Mar 3 12:40:18 2026 +1030 Re: Define BFD_ASAN to detect asan Avoid a complaint from older preprocessors about a "missing binary operator" between an undefined __has_feature macro and its parameter. Diff: --- bfd/bfd-in.h | 12 +++++++++--- bfd/bfd-in2.h | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h index 8650fa12d82..8fd45e82c51 100644 --- a/bfd/bfd-in.h +++ b/bfd/bfd-in.h @@ -153,10 +153,16 @@ struct orl; /* Detect whether we are compiling with -fsanitize=address. */ #ifndef BFD_ASAN -# if ((defined (__SANITIZE_ADDRESS__) && __SANITIZE_ADDRESS__) \ - || (defined __has_feature && __has_feature (address_sanitizer))) +/* gcc. */ +# if defined __SANITIZE_ADDRESS__ # define BFD_ASAN 1 -# else +/* clang. */ +# elif defined __has_feature +# if __has_feature(address_sanitizer) +# define BFD_ASAN 1 +# endif +# endif +# ifndef BFD_ASAN # define BFD_ASAN 0 # endif #endif diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index cd5307beef4..7e8d0e4053e 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -160,10 +160,16 @@ struct orl; /* Detect whether we are compiling with -fsanitize=address. */ #ifndef BFD_ASAN -# if ((defined (__SANITIZE_ADDRESS__) && __SANITIZE_ADDRESS__) \ - || (defined __has_feature && __has_feature (address_sanitizer))) +/* gcc. */ +# if defined __SANITIZE_ADDRESS__ # define BFD_ASAN 1 -# else +/* clang. */ +# elif defined __has_feature +# if __has_feature(address_sanitizer) +# define BFD_ASAN 1 +# endif +# endif +# ifndef BFD_ASAN # define BFD_ASAN 0 # endif #endif