]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[PATCH 1/9] ENABLE_CHECKING refactoring
authorMikhail Maltsev <maltsevm@gmail.com>
Wed, 21 Oct 2015 21:16:31 +0000 (21:16 +0000)
committerJeff Law <law@gcc.gnu.org>
Wed, 21 Oct 2015 21:16:31 +0000 (15:16 -0600)
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

gcc/ChangeLog
gcc/config.in
gcc/configure
gcc/configure.ac
gcc/system.h
libcpp/ChangeLog
libcpp/config.in
libcpp/configure
libcpp/configure.ac
libcpp/system.h

index bc3cfa7cb939f7c4399eac08c02ec45c7597afca..f12681937f676ff7fd568c3e16e6bbceecc0761a 100644 (file)
@@ -1,3 +1,10 @@
+2015-10-21  Mikhail Maltsev  <maltsevm@gmail.com>
+
+       * config.in: Regenerate.
+       * configure: Regenerate.
+       * configure.ac (CHECKING_P): Define.
+       * system.h: Use CHECKING_P.
+
 2015-10-11  Jan Hubicka  <hubicka@ucw.cz>
 
        PR ipa/67056
index 093478c28408db8aedf9a011d93e1aab5f87f045..48d7e6441e6bed5c1f82f1ea26c75ccc09ef647a 100644 (file)
 #endif
 
 
+/* Define to 1 if you want more run-time sanity checks. This one gets a grab
+   bag of miscellaneous but relatively cheap checks. */
+#ifndef USED_FOR_TARGET
+#undef CHECKING_P
+#endif
+
+
 /* Define 0/1 to force the choice for exception handling model. */
 #ifndef USED_FOR_TARGET
 #undef CONFIG_SJLJ_EXCEPTIONS
index 6b160ae44a21d9f88ee4b14ee6ebed9381459c4a..3122499da26d2e8597095941073fbbbef046ca89 100755 (executable)
@@ -7096,7 +7096,12 @@ if test x$ac_checking != x ; then
 
 $as_echo "#define ENABLE_CHECKING 1" >>confdefs.h
 
+  $as_echo "#define CHECKING_P 1" >>confdefs.h
+
   nocommon_flag=-fno-common
+else
+  $as_echo "#define CHECKING_P 0" >>confdefs.h
+
 fi
 
 if test x$ac_df_checking != x ; then
@@ -18385,7 +18390,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18388 "configure"
+#line 18393 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18491,7 +18496,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18494 "configure"
+#line 18499 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
index be721e6db3b0235dd3ca2524aeecb5914eee3b85..a30bb3b89e819db3722a6a207d246354e746465c 100644 (file)
@@ -569,7 +569,12 @@ if test x$ac_checking != x ; then
   AC_DEFINE(ENABLE_CHECKING, 1,
 [Define if you want more run-time sanity checks.  This one gets a grab
    bag of miscellaneous but relatively cheap checks.])
+  AC_DEFINE(CHECKING_P, 1,
+[Define to 1 if you want more run-time sanity checks.  This one gets a grab
+   bag of miscellaneous but relatively cheap checks.])
   nocommon_flag=-fno-common
+else
+  AC_DEFINE(CHECKING_P, 0)
 fi
 AC_SUBST(nocommon_flag)
 if test x$ac_df_checking != x ; then
index 61790d74a726e29a88e193fc731e5eefbd80e26c..f9c7e2a612893814dabc06988b94f4625fdf25f3 100644 (file)
@@ -714,13 +714,11 @@ extern void fancy_abort (const char *, int, const char *) ATTRIBUTE_NORETURN;
 #define gcc_assert(EXPR) ((void)(0 && (EXPR)))
 #endif
 
-#ifdef ENABLE_CHECKING
+#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
 
 /* Use gcc_unreachable() to mark unreachable locations (like an
index d14a26108ceafbcc7735256318212495efa79e1b..972e9a5606fd45446ef4647f590ff780ae712a35 100644 (file)
@@ -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.
index 8df00ec2357209a0f0b4af3b02fa19fe48a24f30..5865eb363fc84d84e19a60ac876d38b3a4a7178a 100644 (file)
@@ -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.
    */
index 8cf2f77cacebb8193989cc32914029655b6d5460..1c70c75eb4457ceca767e3c5e8a92e72e120cad8 100755 (executable)
@@ -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
index 5f008a4a67fc8d4aed5b53330efe0bbe34216e27..3fcbe84f33e9e61753d3c34701ee141b45e2d68e 100644 (file)
@@ -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
index 20f07bbe2614fb5f1bc419fd0616fe7252b692cc..2250f10459c28430a6beef2e3e182087f6e114e9 100644 (file)
@@ -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