summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2018-09-11 17:20:31 +0200
committerStephan Bergmann <sbergman@redhat.com>2018-09-11 22:39:16 +0200
commit2d6df9bc36b81ab63bb5b7fe2648f156d3ed74ae (patch)
tree17f5880064e0efa878ac015c795d96306b63fa36 /configure.ac
parent50921d122399d669a2c401b8d26d90a0c7e14d14 (diff)
Use [[fallthrough]] also with MSVC
Change-Id: I840de9460c164b86dcbd96b4c0f382e1a1b609a2 Reviewed-on: https://gerrit.libreoffice.org/60330 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac35
1 files changed, 35 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index d6560b1d4073..5c0d8a420c23 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6404,6 +6404,41 @@ if test "$GCC" = yes; then
fi
AC_SUBST([HAVE_GCC_FNO_SIZED_DEALLOCATION])
+AC_MSG_CHECKING([[whether $CXX supports [[fallthrough]]]])
+AC_LANG_PUSH([C++])
+save_CXXFLAGS=$CXXFLAGS
+CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
+dnl Unknown attributes must be ignored by compilers, but they do emit warnings about them:
+if test "$COM" = MSC; then
+ CXXFLAGS="$CXXFLAGS /we5030"
+else
+ CXXFLAGS="$CXXFLAGS -Werror"
+fi
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+ // There appears to be no feature-test macro for __has_cpp_attribute in C++2a, approximate
+ // by checking for __cplusplus:
+ #if __cplusplus > 201703L
+ #if !__has_cpp_attribute(fallthrough)
+ #error
+ #endif
+ #else
+ void f(int & x) {
+ switch (x) {
+ case 0:
+ ++x;
+ [[fallthrough]];
+ default:
+ ++x;
+ }
+ }
+ #endif
+ ]])], [
+ AC_DEFINE([HAVE_CPP_ATTRIBUTE_FALLTHROUGH],[1])
+ AC_MSG_RESULT([yes])
+ ], [AC_MSG_RESULT([no])])
+CXXFLAGS=$save_CXXFLAGS
+AC_LANG_POP([C++])
+
AC_MSG_CHECKING([[whether $CXX supports [[nodiscard]]]])
AC_LANG_PUSH([C++])
save_CXXFLAGS=$CXXFLAGS