summaryrefslogtreecommitdiff
path: root/src/include/c.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2018-02-15 13:41:30 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2018-02-15 13:41:30 -0500
commit51940f97607b7cb4d03bdd99e43abb1a1c6a0c47 (patch)
tree9d2036f02f567435830c38eee5b49fb343ba6f0b /src/include/c.h
parent03c5a00ea3867f5736da6cedce73b1eea88a98af (diff)
Cast to void in StaticAssertExpr, not its callers.
Seems a bit silly that many (in fact all, as of today) uses of StaticAssertExpr would need to cast it to void to avoid warnings from pickier compilers. Let's just do the cast right in the macro, instead. In passing, change StaticAssertExpr to StaticAssertStmt in one place where that seems more apropos. Discussion: https://postgr.es/m/16161.1518715186@sss.pgh.pa.us
Diffstat (limited to 'src/include/c.h')
-rw-r--r--src/include/c.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/include/c.h b/src/include/c.h
index c38ef8aed3e..6b55181e0a1 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -779,7 +779,7 @@ extern void ExceptionalCondition(const char *conditionName,
#define StaticAssertStmt(condition, errmessage) \
do { _Static_assert(condition, errmessage); } while(0)
#define StaticAssertExpr(condition, errmessage) \
- ({ StaticAssertStmt(condition, errmessage); true; })
+ ((void) ({ StaticAssertStmt(condition, errmessage); true; }))
#else /* !HAVE__STATIC_ASSERT */
#define StaticAssertStmt(condition, errmessage) \
((void) sizeof(struct { int static_assert_failure : (condition) ? 1 : -1; }))
@@ -796,7 +796,7 @@ extern void ExceptionalCondition(const char *conditionName,
#define StaticAssertStmt(condition, errmessage) \
do { struct static_assert_struct { int static_assert_failure : (condition) ? 1 : -1; }; } while(0)
#define StaticAssertExpr(condition, errmessage) \
- ({ StaticAssertStmt(condition, errmessage); })
+ ((void) ({ StaticAssertStmt(condition, errmessage); }))
#endif
#endif /* C++ */
@@ -817,14 +817,14 @@ extern void ExceptionalCondition(const char *conditionName,
StaticAssertStmt(__builtin_types_compatible_p(__typeof__(varname), typename), \
CppAsString(varname) " does not have type " CppAsString(typename))
#define AssertVariableIsOfTypeMacro(varname, typename) \
- ((void) StaticAssertExpr(__builtin_types_compatible_p(__typeof__(varname), typename), \
+ (StaticAssertExpr(__builtin_types_compatible_p(__typeof__(varname), typename), \
CppAsString(varname) " does not have type " CppAsString(typename)))
#else /* !HAVE__BUILTIN_TYPES_COMPATIBLE_P */
#define AssertVariableIsOfType(varname, typename) \
StaticAssertStmt(sizeof(varname) == sizeof(typename), \
CppAsString(varname) " does not have type " CppAsString(typename))
#define AssertVariableIsOfTypeMacro(varname, typename) \
- ((void) StaticAssertExpr(sizeof(varname) == sizeof(typename), \
+ (StaticAssertExpr(sizeof(varname) == sizeof(typename), \
CppAsString(varname) " does not have type " CppAsString(typename)))
#endif /* HAVE__BUILTIN_TYPES_COMPATIBLE_P */