From 9f65e559c41af9ff4f628cbe3a364edd47fbb80a Mon Sep 17 00:00:00 2001 From: Eddie Kohler Date: Thu, 19 Jul 2012 10:00:25 -0400 Subject: [PATCH] Configury: Check for C++11 rvalue references and template alias. --- config.h.in | 6 +++++ configure | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++- m4/click.m4 | 16 ++++++++++++- 3 files changed, 86 insertions(+), 2 deletions(-) diff --git a/config.h.in b/config.h.in index e64b23d921..05d94a4a85 100644 --- a/config.h.in +++ b/config.h.in @@ -73,9 +73,15 @@ /* Define if the C++ compiler understands #pragma interface. */ #undef HAVE_CXX_PRAGMA_INTERFACE +/* Define if the C++ compiler understands rvalue references. */ +#undef HAVE_CXX_RVALUE_REFERENCES + /* Define if the C++ compiler understands static_assert. */ #undef HAVE_CXX_STATIC_ASSERT +/* Define if the C++ compiler understands template alias. */ +#undef HAVE_CXX_TEMPLATE_ALIAS + /* Define if the machine is indifferent to alignment. */ #undef HAVE_INDIFFERENT_ALIGNMENT diff --git a/configure b/configure index 307c772d25..aabe586f37 100755 --- a/configure +++ b/configure @@ -5317,6 +5317,38 @@ $as_echo "#define HAVE_CXX_CONSTEXPR 1" >>confdefs.h fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler understands rvalue references" >&5 +$as_echo_n "checking whether the C++ compiler understands rvalue references... " >&6; } +if ${ac_cv_cxx_rvalue_references+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +int f(int &) { return 1; } int f(int &&) { return 0; } +int +main () +{ +return f(int()); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_cxx_rvalue_references=yes +else + ac_cv_cxx_rvalue_references=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_rvalue_references" >&5 +$as_echo "$ac_cv_cxx_rvalue_references" >&6; } + if test "$ac_cv_cxx_rvalue_references" = yes; then + +$as_echo "#define HAVE_CXX_RVALUE_REFERENCES 1" >>confdefs.h + + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler understands static_assert" >&5 $as_echo_n "checking whether the C++ compiler understands static_assert... " >&6; } if ${ac_cv_cxx_static_assert+:} false; then : @@ -5349,6 +5381,38 @@ $as_echo "#define HAVE_CXX_STATIC_ASSERT 1" >>confdefs.h fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler understands template alias" >&5 +$as_echo_n "checking whether the C++ compiler understands template alias... " >&6; } +if ${ac_cv_cxx_template_alias+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +template struct X { typedef T type; }; template using Y = X; int f(int x) { return x; } +int +main () +{ +return f(Y::type()); + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_compile "$LINENO"; then : + ac_cv_cxx_template_alias=yes +else + ac_cv_cxx_template_alias=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_template_alias" >&5 +$as_echo "$ac_cv_cxx_template_alias" >&6; } + if test "$ac_cv_cxx_template_alias" = yes; then + +$as_echo "#define HAVE_CXX_TEMPLATE_ALIAS 1" >>confdefs.h + + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler understands #pragma interface" >&5 $as_echo_n "checking whether the C++ compiler understands #pragma interface... " >&6; } if ${ac_cv_cxx_pragma_interface+:} false; then : @@ -7394,7 +7458,7 @@ else ac_cv_endian=0 cat > conftest.$ac_ext < #ifdef __BYTE_ORDER diff --git a/m4/click.m4 b/m4/click.m4 index aedc08be9e..780ccd7faf 100644 --- a/m4/click.m4 +++ b/m4/click.m4 @@ -113,7 +113,7 @@ and Linux header files are GCC-specific.) fi fi - dnl check for C++0x constexpr and static_assert + dnl check for C++11 features AC_CACHE_CHECK([whether the C++ compiler understands constexpr], [ac_cv_cxx_constexpr], [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[constexpr int f(int x) { return x + 1; }]], [[]])], @@ -122,6 +122,13 @@ and Linux header files are GCC-specific.) AC_DEFINE([HAVE_CXX_CONSTEXPR], [1], [Define if the C++ compiler understands constexpr.]) fi + AC_CACHE_CHECK([whether the C++ compiler understands rvalue references], [ac_cv_cxx_rvalue_references], [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int f(int &) { return 1; } int f(int &&) { return 0; }]], [[return f(int());]])], + [ac_cv_cxx_rvalue_references=yes], [ac_cv_cxx_rvalue_references=no])]) + if test "$ac_cv_cxx_rvalue_references" = yes; then + AC_DEFINE([HAVE_CXX_RVALUE_REFERENCES], [1], [Define if the C++ compiler understands rvalue references.]) + fi + AC_CACHE_CHECK([whether the C++ compiler understands static_assert], [ac_cv_cxx_static_assert], [ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[const int f = 2;]], [[static_assert(f == 2, "f should be 2");]])], [ac_cv_cxx_static_assert=yes], [ac_cv_cxx_static_assert=no])]) @@ -129,6 +136,13 @@ and Linux header files are GCC-specific.) AC_DEFINE([HAVE_CXX_STATIC_ASSERT], [1], [Define if the C++ compiler understands static_assert.]) fi + AC_CACHE_CHECK([whether the C++ compiler understands template alias], [ac_cv_cxx_template_alias], [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[template struct X { typedef T type; }; template using Y = X; int f(int x) { return x; }]], [[return f(Y::type());]])], + [ac_cv_cxx_template_alias=yes], [ac_cv_cxx_template_alias=no])]) + if test "$ac_cv_cxx_template_alias" = yes; then + AC_DEFINE([HAVE_CXX_TEMPLATE_ALIAS], [1], [Define if the C++ compiler understands template alias.]) + fi + AC_CACHE_CHECK([[whether the C++ compiler understands #pragma interface]], [ac_cv_cxx_pragma_interface], [ save_cxxflags="$CXXFLAGS"; CXXFLAGS="$CXXFLAGS -Werror -Wall -W" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#pragma interface "foo.c"