summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2013-04-08 11:23:53 +0300
committerTor Lillqvist <tml@iki.fi>2013-04-08 11:46:10 +0300
commitcdd1de0854c5fd55f7e99c5546ccf7a7245927f5 (patch)
treea7240435c1ab3543cf76a2ba9526e54ece860c42 /configure.ac
parent0a3fc0130166629209e98bea178905085098a8f2 (diff)
Check for the C++11 "final" specifier and introduce SAL_FINAL
I think it is useful to use SAL_FINAL mainly as a documentation aid, to make it clear to a code reader when a class is not expected to be derived from, and when a virtual function is not expected to be overridden in a derived class. Possibly there is also some class of bugs that using SAL_FINAL will help find? Change-Id: I45002f020dcb52e8a9f2962ff98780f2b80627af
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac75
1 files changed, 72 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index cdda016df724..90a2d891cd21 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5585,14 +5585,14 @@ struct A
AC_MSG_RESULT([no])
fi
else
- AC_MSG_RESULT([no (C++11 disabled)])
+ AC_MSG_RESULT([no])
fi
dnl ==================================
dnl Check for C++11 "override" support
dnl ==================================
-AC_MSG_CHECKING([whether $CXX supports C++11 override syntax])
+AC_MSG_CHECKING([whether $CXX supports C++11 "override" syntax])
if test "$HAVE_CXX0X" = "TRUE"; then
save_CXXFLAGS=$CXXFLAGS
CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
@@ -5618,7 +5618,76 @@ struct B : A
AC_MSG_RESULT([no])
fi
else
- AC_MSG_RESULT([no (C++11 disabled)])
+ AC_MSG_RESULT([no])
+fi
+
+dnl ==================================
+dnl Check for C++11 "final" support
+dnl ==================================
+
+AC_MSG_CHECKING([whether $CXX supports C++11 "final" syntax])
+if test "$HAVE_CXX0X" = "TRUE"; then
+ save_CXXFLAGS=$CXXFLAGS
+ CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
+ AC_LANG_PUSH([C++])
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+// First check that this correct program that uses "final" compiles
+struct A final
+{
+};
+
+struct B
+{
+ virtual void test();
+};
+
+struct C : B
+{
+ void test() final;
+};
+]])],[have_final=yes],[])
+
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+// Then check that the "final" works as expected,
+// that this program fails to compile
+struct A final
+{
+};
+
+struct B : A
+{
+};
+]])],[],[final_class_works=yes])
+
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+// Also this should fail to compile
+struct B
+{
+ virtual void test();
+};
+
+struct C : B
+{
+ void test() final;
+};
+
+struct D : C
+{
+ void test();
+};
+]])],[],[final_method_works=yes])
+ AC_LANG_POP([C++])
+
+ CXXFLAGS=$save_CXXFLAGS
+
+ if test "$have_final" = yes -a "$final_class_works" = yes -a "$final_method_works" = yes; then
+ AC_MSG_RESULT([yes])
+ AC_DEFINE([HAVE_CXX11_FINAL])
+ else
+ AC_MSG_RESULT([no])
+ fi
+else
+ AC_MSG_RESULT([no])
fi
dnl ===================================================================