diff options
author | Peter Simons <simons@cryp.to> | 2010-01-05 13:52:31 +0100 |
---|---|---|
committer | Peter Simons <simons@cryp.to> | 2010-01-05 13:54:31 +0100 |
commit | 4339f0a8a2803e1e954f461319b39c7f1a1f60fb (patch) | |
tree | c9e0cca620ab19c82cc7d3458374080012b18ac2 /m4 | |
parent | 7b6c46dd3a6b8b5f35e6d182fe8db51cda744762 (diff) | |
download | autoconf-archive-4339f0a8a2803e1e954f461319b39c7f1a1f60fb.tar.gz |
AX_CXX_VERBOSE_TERMINATE_HANDLER: replaced by a more generic implementation that's not limited to GNU libstdc++
Submitted by Kevin Locke in <https://savannah.nongnu.org/patch/?7005>.
Diffstat (limited to 'm4')
-rw-r--r-- | m4/ax_cxx_helpful_terminate_handler.m4 | 74 | ||||
-rw-r--r-- | m4/ax_cxx_verbose_terminate_handler.m4 | 73 |
2 files changed, 54 insertions, 93 deletions
diff --git a/m4/ax_cxx_helpful_terminate_handler.m4 b/m4/ax_cxx_helpful_terminate_handler.m4 deleted file mode 100644 index 411f4a1..0000000 --- a/m4/ax_cxx_helpful_terminate_handler.m4 +++ /dev/null @@ -1,74 +0,0 @@ -# ============================================================================== -# http://www.nongnu.org/autoconf-archive/ax_cxx_helpful_terminate_handler.html -# ============================================================================== -# -# SYNOPSIS -# -# AX_CXX_HELPFUL_TERMINATE_HANDLER -# -# DESCRIPTION -# -# Check if the terminate handler for the current compiler/standard library -# prints useful information to stdout/stderr (i.e. the type of the -# uncaught exception and/or the what() string). -# -# The intended use case for this check is to help program authors decide -# if they need to add a top-level try-catch or custom terminate handler to -# print useful information if an uncaught exception occurs, or if this -# task can be left to the standard library implementation. Alternatively, -# it can be used to detect if such output needs to be silenced with a -# custom terminate handler. -# -# Output: -# -# Define HAVE_HELPFUL_TERMINATE_HANDLER if useful information is printed. -# -# LICENSE -# -# Copyright (c) 2009 Kevin Locke <klocke@digitalenginesoftware.com> -# -# Copying and distribution of this file, with or without modification, is -# permitted in any medium, without royalty, provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -AC_DEFUN([AX_CXX_HELPFUL_TERMINATE_HANDLER], -[AC_CACHE_CHECK([whether the terminate function prints useful information], -[ax_cv_cxx_helpful_terminate_handler], -[ - AC_LANG_PUSH([C++]) - AC_RUN_IFELSE( - [AC_LANG_PROGRAM( - [#include <stdexcept>], - [throw std::runtime_error("Test of unhandled exception AABBCCDDEE");])], - - dnl The test should never return 0, since it aborts - [ax_cv_cxx_helpful_terminate_handler=no], - - dnl If the compilation was successful, run it and capture the output - [AS_IF([test -x conftest$EXEEXT], - [_output="$(./conftest$EXEEXT 2>&1)"], - [_output=""]) - - dnl Check that the output contains the what() string - AS_CASE("$_output", - [*AABBCCDDEE*], - - dnl Check that the output also contains the exception type - [AS_CASE("$_output", - [*runtime_error*], - [ax_cv_cxx_helpful_terminate_handler=yes], - [ax_cv_cxx_helpful_terminate_handler=no])], - [ax_cv_cxx_helpful_terminate_handler=no]) - - ], - - dnl When cross-compiling, assume messages are not helpful - [ax_cv_cxx_helpful_terminate_handler=no]) - AC_LANG_POP([C++]) -]) -if test "$ax_cv_cxx_helpful_terminate_handler" = yes; then - AC_DEFINE([HAVE_HELPFUL_TERMINATE_HANDLER], 1, - [define if the terminate function prints useful information]) -fi -]) diff --git a/m4/ax_cxx_verbose_terminate_handler.m4 b/m4/ax_cxx_verbose_terminate_handler.m4 index 9cdf350..6b0e801 100644 --- a/m4/ax_cxx_verbose_terminate_handler.m4 +++ b/m4/ax_cxx_verbose_terminate_handler.m4 @@ -8,33 +8,68 @@ # # DESCRIPTION # -# If the compiler does have the verbose terminate handler, define -# HAVE_VERBOSE_TERMINATE_HANDLER. +# Check if the terminate handler for the current compiler/standard library +# prints useful information to stdout/stderr (i.e. the type of the +# uncaught exception and/or the what() string). +# +# The intended use case for this check is to help program authors decide +# if they need to add a top-level try-catch or custom terminate handler to +# print useful information if an uncaught exception occurs, or if this +# task can be left to the standard library implementation. Alternatively, +# it can be used to detect if such output needs to be silenced with a +# custom terminate handler. +# +# Output: +# +# Define HAVE_VERBOSE_TERMINATE_HANDLER if useful information is printed. # # LICENSE # +# Copyright (c) 2009 Kevin Locke <klocke@digitalenginesoftware.com> # Copyright (c) 2008 Lapo Luchini <lapo@lapo.it> # -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. +# Copying and distribution of this file, with or without modification, is +# permitted in any medium, without royalty, provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. -AU_ALIAS([AC_CXX_VERBOSE_TERMINATE_HANDLER], [AX_CXX_VERBOSE_TERMINATE_HANDLER]) AC_DEFUN([AX_CXX_VERBOSE_TERMINATE_HANDLER], -[AC_CACHE_CHECK(whether the compiler has __gnu_cxx::__verbose_terminate_handler, -ax_cv_verbose_terminate_handler, +[AC_CACHE_CHECK([whether the terminate function prints useful information], +[ax_cv_cxx_verbose_terminate_handler], [ - AC_REQUIRE([AX_CXX_EXCEPTIONS]) - AC_REQUIRE([AX_CXX_NAMESPACES]) - AC_LANG_SAVE - AC_LANG_CPLUSPLUS - AC_TRY_COMPILE( - [#include <exception>], [std::set_terminate(__gnu_cxx::__verbose_terminate_handler);], - ax_cv_verbose_terminate_handler=yes, ax_cv_verbose_terminate_handler=no - ) - AC_LANG_RESTORE + AC_LANG_PUSH([C++]) + AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [#include <stdexcept>], + [throw std::runtime_error("Test of unhandled exception AABBCCDDEE");])], + + dnl The test should never return 0, since it aborts + [ax_cv_cxx_verbose_terminate_handler=no], + + dnl If the compilation was successful, run it and capture the output + [AS_IF([test -x conftest$EXEEXT], + [_output="$(./conftest$EXEEXT 2>&1)"], + [_output=""]) + + dnl Check that the output contains the what() string + AS_CASE("$_output", + [*AABBCCDDEE*], + + dnl Check that the output also contains the exception type + [AS_CASE("$_output", + [*runtime_error*], + [ax_cv_cxx_verbose_terminate_handler=yes], + [ax_cv_cxx_verbose_terminate_handler=no])], + [ax_cv_cxx_verbose_terminate_handler=no]) + + ], + + dnl When cross-compiling, assume messages are not verbose + [ax_cv_cxx_verbose_terminate_handler=no]) + AC_LANG_POP([C++]) ]) -if test "$ax_cv_verbose_terminate_handler" = yes; then - AC_DEFINE(HAVE_VERBOSE_TERMINATE_HANDLER, , [define if the compiler has __gnu_cxx::__verbose_terminate_handler]) +if test "$ax_cv_cxx_verbose_terminate_handler" = yes; then + AC_DEFINE([HAVE_VERBOSE_TERMINATE_HANDLER], 1, + [define if the terminate function prints useful information]) fi ]) |