[m-rev.] for review: Avoid clang warning about preprocessor macro.

Peter Wang novalazy at gmail.com
Wed Feb 28 14:31:08 AEDT 2018


runtime/mercury_trail.h:
    Simplify expansion of MR_USE_TAGGED_TRAIL to prevent a clang warning:
    macro expansion producing 'defined' has undefined behavior
---
 runtime/mercury_trail.h | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/runtime/mercury_trail.h b/runtime/mercury_trail.h
index 345505823..f639b2781 100644
--- a/runtime/mercury_trail.h
+++ b/runtime/mercury_trail.h
@@ -1,6 +1,7 @@
 // vim: ts=4 sw=4 expandtab ft=c
 
 // Copyright (C) 1997-2000, 2004-2005, 2007-2008 The University of Melbourne.
+// Copyright (C) 2015-2016, 2018 The Mercury team.
 // This file may only be copied under the terms of the GNU Library General
 // Public License - see the file COPYING.LIB in the Mercury distribution.
 
@@ -180,12 +181,14 @@ typedef enum {
 } MR_trail_entry_kind;
 #define MR_LAST_TRAIL_ENTRY_KIND MR_func_entry
 
-// MR_USE_TAGGED_TRAIL is true iff we have enough tag bits to store
-// an MR_trail_entry_kind as a pointer tag and MR_FORCE_NO_TAGGED_TRAIL
-// is undefined.
+// MR_USE_TAGGED_TRAIL is true iff MR_FORCE_NO_TAGGED_TRAIL is not defined, and
+// there are enough tag bits to store an MR_trail_entry_kind as a pointer tag.
 
-#define MR_USE_TAGGED_TRAIL (!defined(MR_FORCE_NO_TAGGED_TRAIL) &&      \
-    ((1<<MR_TAGBITS) > MR_LAST_TRAIL_ENTRY_KIND))
+#ifdef MR_FORCE_NO_TAGGED_TRAIL
+  #define MR_USE_TAGGED_TRAIL (0)
+#else
+  #define MR_USE_TAGGED_TRAIL ((1<<MR_TAGBITS) > MR_LAST_TRAIL_ENTRY_KIND)
+#endif
 
 typedef void MR_untrail_func_type(void *datum, MR_untrail_reason);
 
-- 
2.16.2



More information about the reviews mailing list