mirror of
https://git.openafs.org/openafs.git
synced 2025-01-31 05:27:44 +00:00
opr: Disable some warnings during opr assertions
Detect _Pragma(), a C99 extension for inline #pragma's, and use it to disable to certain warnings during the use of opr_Verify() and opr_Assert(). Because some versions of clang support _Pragma, do not have support for -Wtautological-pointer-compare, and do set -Werror and -Wunknown-pragmas, we must explicitly check for pragma support for -Wtautological-pointer-compare as well. Change-Id: Id3d5ee347f320a366a0571572b58414aa7044bf7 Reviewed-on: http://gerrit.openafs.org/11852 Reviewed-by: Michael Meffie <mmeffie@sinenomine.net> Reviewed-by: Benjamin Kaduk <kaduk@mit.edu> Tested-by: BuildBot <buildbot@rampaginggeek.com>
This commit is contained in:
parent
5fbf45b562
commit
04661c4139
@ -1621,6 +1621,7 @@ OPENAFS_ROKEN()
|
|||||||
OPENAFS_HCRYPTO()
|
OPENAFS_HCRYPTO()
|
||||||
OPENAFS_CURSES()
|
OPENAFS_CURSES()
|
||||||
OPENAFS_C_ATTRIBUTE()
|
OPENAFS_C_ATTRIBUTE()
|
||||||
|
OPENAFS_C_PRAGMA()
|
||||||
|
|
||||||
dnl Functions that Heimdal's libroken provides, but that we
|
dnl Functions that Heimdal's libroken provides, but that we
|
||||||
dnl haven't found a need for yet, and so haven't imported
|
dnl haven't found a need for yet, and so haven't imported
|
||||||
|
46
src/cf/c-pragma.m4
Normal file
46
src/cf/c-pragma.m4
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
dnl
|
||||||
|
dnl Test for _Pragma and how we need to use it
|
||||||
|
dnl
|
||||||
|
AC_DEFUN([OPENAFS_C_PRAGMA_TAUTOLOGICAL_POINTER_COMPARE],[
|
||||||
|
AC_MSG_CHECKING(for _Pragma recognition of -Wtautological-pointer-compare)
|
||||||
|
AC_CACHE_VAL(ac_cv__Pragma_tautological_pointer_compare, [
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
||||||
|
_Pragma("clang diagnostic error \"-Wunknown-pragmas\"")
|
||||||
|
_Pragma("clang diagnostic ignored \"-Wtautological-pointer-compare\"")
|
||||||
|
|
||||||
|
void func(void)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
]])],
|
||||||
|
[ac_cv__Pragma_tautological_pointer_compare=yes],
|
||||||
|
[ac_cv__Pragma_tautological_pointer_compare=no])])
|
||||||
|
AC_MSG_RESULT($ac_cv__Pragma_tautological_pointer_compare)
|
||||||
|
])
|
||||||
|
|
||||||
|
AC_DEFUN([_OPENAFS_C_PRAGMA], [
|
||||||
|
AC_MSG_CHECKING(for _Pragma)
|
||||||
|
AC_CACHE_VAL(ac_cv__Pragma, [
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
||||||
|
_Pragma("")
|
||||||
|
|
||||||
|
void func(void)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
]])],
|
||||||
|
[ac_cv__Pragma=yes],
|
||||||
|
[ac_cv__Pragma=no])])
|
||||||
|
AC_MSG_RESULT($ac_cv__Pragma)])
|
||||||
|
|
||||||
|
AC_DEFUN([OPENAFS_C_PRAGMA], [
|
||||||
|
_OPENAFS_C_PRAGMA
|
||||||
|
if test "$ac_cv__Pragma" = "yes"; then
|
||||||
|
AC_DEFINE(HAVE__PRAGMA, 1, [define if your compiler has _Pragma])
|
||||||
|
OPENAFS_C_PRAGMA_TAUTOLOGICAL_POINTER_COMPARE
|
||||||
|
if test "$ac_cv__Pragma_tautological_pointer_compare" = "yes"; then
|
||||||
|
AC_DEFINE(HAVE__PRAGMA_TAUTOLOGICAL_POINTER_COMPARE, 1,
|
||||||
|
[define if your compiler has _Pragma and recognizes -Wtautological-pointer-compare])
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
])
|
@ -24,16 +24,36 @@ extern void opr_AssertFailU(const char *, const char *, int) AFS_NORETURN;
|
|||||||
* to a no-op if NDEBUG is defined
|
* to a no-op if NDEBUG is defined
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define opr_Assert(ex) \
|
#define __opr_Assert(ex) \
|
||||||
do {if (!(ex)) opr_AssertionFailed(__FILE__, __LINE__);} while(0)
|
do {if (!(ex)) opr_AssertionFailed(__FILE__, __LINE__);} while(0)
|
||||||
|
|
||||||
|
#if defined(HAVE__PRAGMA_TAUTOLOGICAL_POINTER_COMPARE) && defined(__clang__)
|
||||||
|
# define opr_Assert(ex) \
|
||||||
|
_Pragma("clang diagnostic push") \
|
||||||
|
_Pragma("clang diagnostic ignored \"-Wtautological-pointer-compare\"") \
|
||||||
|
__opr_Assert(ex) \
|
||||||
|
_Pragma("clang diagnostic pop")
|
||||||
|
#else
|
||||||
|
# define opr_Assert(ex) __opr_Assert(ex)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* opr_Verify is an assertion function which is guaranteed to always
|
/* opr_Verify is an assertion function which is guaranteed to always
|
||||||
* invoke its expression, regardless of the debugging level selected
|
* invoke its expression, regardless of the debugging level selected
|
||||||
* at compile time */
|
* at compile time */
|
||||||
|
|
||||||
#define opr_Verify(ex) \
|
#define __opr_Verify(ex) \
|
||||||
do {if (!(ex)) opr_AssertionFailed(__FILE__, __LINE__);} while(0)
|
do {if (!(ex)) opr_AssertionFailed(__FILE__, __LINE__);} while(0)
|
||||||
|
|
||||||
|
#if defined(HAVE__PRAGMA_TAUTOLOGICAL_POINTER_COMPARE) && defined(__clang__)
|
||||||
|
# define opr_Verify(ex) \
|
||||||
|
_Pragma("clang diagnostic push") \
|
||||||
|
_Pragma("clang diagnostic ignored \"-Wtautological-pointer-compare\"") \
|
||||||
|
__opr_Verify(ex) \
|
||||||
|
_Pragma("clang diagnostic pop")
|
||||||
|
#else
|
||||||
|
# define opr_Verify(ex) __opr_Verify(ex)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* casestrcpy.c */
|
/* casestrcpy.c */
|
||||||
#define lcstring opr_lcstring
|
#define lcstring opr_lcstring
|
||||||
#define ucstring opr_ucstring
|
#define ucstring opr_ucstring
|
||||||
|
Loading…
x
Reference in New Issue
Block a user