diff options
author | Mikhail Maltsev <maltsevm@gmail.com> | 2015-10-21 21:16:31 +0000 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 2015-10-21 15:16:31 -0600 |
commit | 7ec491c07be298679b27d5939accc30de01d62d0 (patch) | |
tree | 0e7336163388dbd3f57d87088d5662843ae8a6fd /libcpp | |
parent | 74bb77094f3b512e146f61c2e218c842f4a8d53b (diff) | |
download | gcc-7ec491c07be298679b27d5939accc30de01d62d0.zip gcc-7ec491c07be298679b27d5939accc30de01d62d0.tar.gz gcc-7ec491c07be298679b27d5939accc30de01d62d0.tar.bz2 |
[PATCH 1/9] ENABLE_CHECKING refactoring
gcc/
* config.in: Regenerate.
* configure: Regenerate.
* configure.ac (CHECKING_P): Define.
* system.h: Use CHECKING_P.
libcpp/
* config.in: Regenerate.
* configure: Regenerate.
* configure.ac (CHECKING_P): Define.
* system.h (fancy_abort): Declare.
(abort): Define.
(gcc_assert): Define. Use CHECKING_P.
From-SVN: r229149
Diffstat (limited to 'libcpp')
-rw-r--r-- | libcpp/ChangeLog | 9 | ||||
-rw-r--r-- | libcpp/config.in | 3 | ||||
-rwxr-xr-x | libcpp/configure | 5 | ||||
-rw-r--r-- | libcpp/configure.ac | 4 | ||||
-rw-r--r-- | libcpp/system.h | 21 |
5 files changed, 39 insertions, 3 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog index d14a261..972e9a5 100644 --- a/libcpp/ChangeLog +++ b/libcpp/ChangeLog @@ -1,3 +1,12 @@ +2015-10-21 Mikhail Maltsev <maltsevm@gmail.com> + + * config.in: Regenerate. + * configure: Regenerate. + * configure.ac (CHECKING_P): Define. + * system.h (fancy_abort): Declare. + (abort): Define. + (gcc_assert): Define. Use CHECKING_P. + 2015-10-13 Mikhail Maltsev <maltsevm@gmail.com> * system.h (CHECKING_P, gcc_checking_assert): Define. diff --git a/libcpp/config.in b/libcpp/config.in index 8df00ec..5865eb3 100644 --- a/libcpp/config.in +++ b/libcpp/config.in @@ -3,6 +3,9 @@ /* Define if building universal (internal helper macro) */ #undef AC_APPLE_UNIVERSAL_BUILD +/* Define to 1 if you want more run-time sanity checks. */ +#undef CHECKING_P + /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP systems. This function is required for `alloca.c' support on those systems. */ diff --git a/libcpp/configure b/libcpp/configure index 8cf2f77..1c70c75 100755 --- a/libcpp/configure +++ b/libcpp/configure @@ -7300,6 +7300,11 @@ if test x$ac_checking != x ; then $as_echo "#define ENABLE_CHECKING 1" >>confdefs.h + $as_echo "#define CHECKING_P 1" >>confdefs.h + +else + $as_echo "#define CHECKING_P 0" >>confdefs.h + fi if test x$ac_valgrind_checking != x ; then diff --git a/libcpp/configure.ac b/libcpp/configure.ac index 5f008a4..3fcbe84 100644 --- a/libcpp/configure.ac +++ b/libcpp/configure.ac @@ -166,6 +166,10 @@ IFS="$ac_save_IFS" if test x$ac_checking != x ; then AC_DEFINE(ENABLE_CHECKING, 1, [Define if you want more run-time sanity checks.]) + AC_DEFINE(CHECKING_P, 1, +[Define to 1 if you want more run-time sanity checks.]) +else + AC_DEFINE(CHECKING_P, 0) fi if test x$ac_valgrind_checking != x ; then diff --git a/libcpp/system.h b/libcpp/system.h index 20f07bb..2250f10 100644 --- a/libcpp/system.h +++ b/libcpp/system.h @@ -391,13 +391,28 @@ extern void abort (void); #define __builtin_expect(a, b) (a) #endif -#ifdef ENABLE_CHECKING +/* Redefine abort to report an internal error w/o coredump, and + reporting the location of the error in the source file. */ +extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN; +#define abort() fancy_abort (__FILE__, __LINE__, __FUNCTION__) + +/* Use gcc_assert(EXPR) to test invariants. */ +#if ENABLE_ASSERT_CHECKING +#define gcc_assert(EXPR) \ + ((void)(!(EXPR) ? fancy_abort (__FILE__, __LINE__, __FUNCTION__), 0 : 0)) +#elif (GCC_VERSION >= 4005) +#define gcc_assert(EXPR) \ + ((void)(__builtin_expect (!(EXPR), 0) ? __builtin_unreachable (), 0 : 0)) +#else +/* Include EXPR, so that unused variable warnings do not occur. */ +#define gcc_assert(EXPR) ((void)(0 && (EXPR))) +#endif + +#if CHECKING_P #define gcc_checking_assert(EXPR) gcc_assert (EXPR) -#define CHECKING_P 1 #else /* N.B.: in release build EXPR is not evaluated. */ #define gcc_checking_assert(EXPR) ((void)(0 && (EXPR))) -#define CHECKING_P 1 #endif /* Provide a fake boolean type. We make no attempt to use the |