[PATCH] Do not expand macros to 'defined'

Павел Крюков kryukov@frtk.ru
Wed Jan 16 06:34:00 GMT 2019


Expanding a macro which contains 'defined' PP keyword is UB.

sim/common/Changelog:
2019-01-16  Pavel I. Kryukov  <kryukov@frtk.ru>

        * sim-arange.c: eliminate DEFINE_NON_INLINE_P
---
 sim/common/sim-arange.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/sim/common/sim-arange.c b/sim/common/sim-arange.c
index 6373b742ce8..b3488ab564a 100644
--- a/sim/common/sim-arange.c
+++ b/sim/common/sim-arange.c
@@ -32,10 +32,7 @@ along with this program.  If not, see
<http://www.gnu.org/licenses/>.  */
 #include <string.h>
 #endif

-#define DEFINE_INLINE_P (! defined (SIM_ARANGE_C_INCLUDED))
-#define DEFINE_NON_INLINE_P defined (SIM_ARANGE_C_INCLUDED)
-
-#if DEFINE_NON_INLINE_P
+#ifdef SIM_ARANGE_C_INCLUDED

 /* Insert a range.  */

@@ -280,9 +277,7 @@ sim_addr_range_delete (ADDR_RANGE *ar,
address_word start, address_word end)
   build_search_tree (ar);
 }

-#endif /* DEFINE_NON_INLINE_P */
-
-#if DEFINE_INLINE_P
+#else /* SIM_ARANGE_C_INCLUDED */

 SIM_ARANGE_INLINE int
 sim_addr_range_hit_p (ADDR_RANGE *ar, address_word addr)
@@ -301,4 +296,4 @@ sim_addr_range_hit_p (ADDR_RANGE *ar, address_word addr)
   return 0;
 }

-#endif /* DEFINE_INLINE_P */
+#endif /* SIM_ARANGE_C_INCLUDED */



More information about the Gdb-patches mailing list