Skip to content

Commit

Permalink
Configury: Check for C++11 rvalue references and template alias.
Browse files Browse the repository at this point in the history
  • Loading branch information
kohler committed Jul 19, 2012
1 parent 4efd5ad commit 9f65e55
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 2 deletions.
6 changes: 6 additions & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
66 changes: 65 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
Expand Down Expand Up @@ -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 <typename T> struct X { typedef T type; }; template <typename T> using Y = X<T>; int f(int x) { return x; }
int
main ()
{
return f(Y<int>::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 :
Expand Down Expand Up @@ -7394,7 +7458,7 @@ else

ac_cv_endian=0
cat > conftest.$ac_ext <<EOF
#line 7397 "configure"
#line 7461 "configure"
#include "confdefs.h"
#include <$endian_hdr>
#ifdef __BYTE_ORDER
Expand Down
16 changes: 15 additions & 1 deletion m4/click.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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; }]], [[]])],
Expand All @@ -122,13 +122,27 @@ 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])])
if test "$ac_cv_cxx_static_assert" = yes; then
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 <typename T> struct X { typedef T type; }; template <typename T> using Y = X<T>; int f(int x) { return x; }]], [[return f(Y<int>::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"
Expand Down

0 comments on commit 9f65e55

Please sign in to comment.