Fix build for external boost 1.56.0
authorRoland Schulz <roland@utk.edu>
Fri, 5 Sep 2014 20:23:19 +0000 (16:23 -0400)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Sun, 7 Sep 2014 15:07:24 +0000 (17:07 +0200)
exception/detail/attribute_noreturn.hpp has been removed in 1.56. We
shouldn't have used a detail header in the first place. Use Gromacs
own noreturn attribute.

Also:
- rename GMX_ATTRIBUTE_NORETURN to gmx_noreturn to match unused,
  restrict, and inline
- moved gmx_noreturn to basedefinitions.h
- defined gmx_noreturn for MSVC.
- always use attribute at the beginning not the end, to make it work
  with MSVC (also is more consistent)

Change-Id: Ieaeec03182be9a9d248bb460dae389270e806045

src/gromacs/pbcutil/mshift.cpp
src/gromacs/utility/basedefinitions.h
src/gromacs/utility/fatalerror.cpp
src/gromacs/utility/fatalerror.h
src/gromacs/utility/gmxassert.h

index 94dc35bd2b6bbb8d7f9f6c977bda22d5a37242e8..fa47a80e1a19bf4ee2b77073af9216c325f32d91 100644 (file)
@@ -145,7 +145,7 @@ static void mk_igraph(t_graph *g, int ftype, t_ilist *il,
     }
 }
 
-GMX_ATTRIBUTE_NORETURN static void g_error(int line, const char *file)
+gmx_noreturn static void g_error(int line, const char *file)
 {
     gmx_fatal(FARGS, "Tring to print non existant graph (file %s, line %d)",
               file, line);
index faa4395328c4c3eaefabbf99dc4b2a2bf2e60ac2..4c554c5f8356080f43645b2337c72babf8a062c3 100644 (file)
@@ -207,4 +207,25 @@ typedef uint64_t gmx_uint64_t;
 #endif
 #endif
 
+#ifndef __has_feature
+/** For compatibility with non-clang compilers. */
+#define __has_feature(x) 0
+#endif
+
+/*! \def gmx_noreturn
+ * \brief
+ * Indicate that a function is not expected to return.
+ *
+ */
+#ifndef gmx_noreturn
+#if defined(__GNUC__) || __has_feature(attribute_analyzer_noreturn)
+#define gmx_noreturn __attribute__((noreturn))
+#elif defined (_MSC_VER)
+#define gmx_noreturn __declspec(noreturn)
+#else
+#define gmx_noreturn
+#endif
+#endif
+
+
 #endif
index 1dd7e79edd4e0649674ed41c958e03e69be64c86..f242e2d4483cd52133a7b552f647b6b067a9bd42 100644 (file)
@@ -206,7 +206,7 @@ static void call_error_handler(const char *key, const char *file, int line, cons
     gmx_error_handler(buf);
 }
 
-GMX_ATTRIBUTE_NORETURN static void do_exit(bool bMaster, bool bFinalize)
+gmx_noreturn static void do_exit(bool bMaster, bool bFinalize)
 {
     if (debug)
     {
index 1430d185488bdcbc73b43ecbf02771b52df0d0fc..7d380bc419122c43a0e50157b3b4180db52a76e3 100644 (file)
 extern "C" {
 #endif
 
-#ifndef __has_feature
-/** For compatibility with non-clang compilers. */
-#define __has_feature(x) 0
-#endif
-
-/*! \def GMX_ATTRIBUTE_NORETURN
- * \brief
- * Indicate that a function is not expected to return.
- *
- * \todo
- * There are functions outside this header that need the same attribute.
- * This could be moved to a generic header and made it affect also compiler
- * code generation.
- */
-#ifndef GMX_ATTRIBUTE_NORETURN
-#if defined(__GNUC__) || __has_feature(attribute_analyzer_noreturn)
-#define GMX_ATTRIBUTE_NORETURN __attribute__((noreturn))
-#else
-#define GMX_ATTRIBUTE_NORETURN
-#endif
-#endif
-
 /*! \brief
  * Debug log file.
  *
@@ -140,9 +118,9 @@ set_gmx_error_handler(void (*func)(const char *msg));
  * This is used to implement gmx_fatal_collective() (which cannot be declared
  * here, since it would bring with it mdrun-specific dependencies).
  */
-void
+gmx_noreturn void
 gmx_fatal_mpi_va(int fatal_errno, const char *file, int line, gmx_bool bMaster,
-                 gmx_bool bFinalize, const char *fmt, va_list ap) GMX_ATTRIBUTE_NORETURN;
+                 gmx_bool bFinalize, const char *fmt, va_list ap);
 
 /*! \brief
  * Fatal error reporting routine for \Gromacs.
@@ -165,8 +143,8 @@ gmx_fatal_mpi_va(int fatal_errno, const char *file, int line, gmx_bool bMaster,
    gmx_fatal(FARGS, fmt, ...);
    \endcode
  */
-void
-gmx_fatal(int fatal_errno, const char *file, int line, const char *fmt, ...) GMX_ATTRIBUTE_NORETURN;
+gmx_noreturn void
+gmx_fatal(int fatal_errno, const char *file, int line, const char *fmt, ...);
 /** Helper macro to pass first three parameters to gmx_fatal(). */
 #define FARGS 0, __FILE__, __LINE__
 
@@ -179,7 +157,7 @@ gmx_fatal(int fatal_errno, const char *file, int line, const char *fmt, ...) GMX
 char *gmx_strerror(const char *key);
 
 /** Implementation for gmx_error(). */
-void _gmx_error(const char *key, const char *msg, const char *file, int line) GMX_ATTRIBUTE_NORETURN;
+gmx_noreturn void _gmx_error(const char *key, const char *msg, const char *file, int line);
 /*! \brief
  * Alternative fatal error routine with canned messages.
  *
index 0259b611f14a354b6b2bed1d9f8a6e6410d4eed5..b47d9d093331d0ecfb28aa667e67d578d1e50171 100644 (file)
@@ -44,7 +44,8 @@
 #define GMX_UTILITY_GMXASSERT_H
 
 #include <boost/current_function.hpp>
-#include <boost/exception/detail/attribute_noreturn.hpp>
+
+#include "basedefinitions.h"
 
 //! \addtogroup module_utility
 //! \{
@@ -100,7 +101,7 @@ namespace internal
  *
  * \ingroup module_utility
  */
-BOOST_ATTRIBUTE_NORETURN
+gmx_noreturn
 void assertHandler(const char *condition, const char *msg,
                    const char *func, const char *file, int line);