summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-09-29 14:19:47 +0200
committerStephan Bergmann <sbergman@redhat.com>2015-09-30 11:06:14 +0000
commite26188145238572580b9af18fbde4b824b341046 (patch)
tree5ab9a20b9c87b5bd4afb1f5610f45c4f99e99837 /configure.ac
parent638b6d7e0b8740d53c88dcde0c2b743a2184ccfa (diff)
Avoid unhelpful -Wunused-variable
...at least from "g++ (GCC) 5.1.1 20150618 (Red Hat 5.1.1-4)" with --disable-debug, when a namespace-scope const variable with a "complex" initializer declared in an include file remains unused. Avoid that warning via SAL_CONSTEXPR, which in turn requires large parts of o3tl::is_typed_flags to be SAL_CONSTEXPR, which in turn requires a new HAVE_CXX14_CONSTEXPR to allow assert in constexpr functions, which in turn requires using -std=c++14 instead of -std=c++11 where available, which in turn (a) requires to /not/ use -std=c++14 if it would run into a bug between Clang and libstdc++ discussed at <https://llvm.org/bugs/show_bug.cgi?id=24115> "llvm-nm fails to build with gcc 5.1's libstdc++" (and which hits us in sfx2/source/control/thumbnailview.cxx), and (b) requires a new HAVE_CXX14_SIZED_DEALLOCATION to work around GCC 5.1 -Werror=sized-deallocation (where Clang >= 3.7 only supports C++14 sized deallocation when explictly enabled via -fsized-deallocation, btw). This effectively reverts ff6462e6307e6924dc6c8178043ae9032f4b4152 "avoid unused variable warning:" again. Change-Id: I424e3561452a3e6d8c8a9604d6c737cab49840c4 Reviewed-on: https://gerrit.libreoffice.org/18918 Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac56
1 files changed, 53 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index a84772b6932b..73855b01602e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6040,12 +6040,19 @@ if test "$COM" = MSC; then
# MSVC supports (a subset of) CXX11 without any switch
elif test "$GCC" = "yes"; then
HAVE_CXX11=
- AC_MSG_CHECKING([whether $CXX supports C++11])
- for flag in -std=gnu++11 -std=gnu++0x -std=c++11 -std=c++0x ; do
+ AC_MSG_CHECKING([whether $CXX supports C++14 or C++11])
+ for flag in -std=gnu++14 -std=gnu++1y -std=c++14 -std=c++1y -std=gnu++11 -std=gnu++0x -std=c++11 -std=c++0x ; do
save_CXXFLAGS=$CXXFLAGS
CXXFLAGS="$CXXFLAGS $flag -Werror"
AC_LANG_PUSH([C++])
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[void f() {}]])],[CXXFLAGS_CXX11=$flag])
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ #include <algorithm>
+ #include <functional>
+ #include <vector>
+ void f(std::vector<int> & v, std::function<bool(int, int)> fn) {
+ std::sort(v.begin(), v.end(), fn);
+ }
+ ]])],[CXXFLAGS_CXX11=$flag])
AC_LANG_POP([C++])
CXXFLAGS=$save_CXXFLAGS
if test -n "$CXXFLAGS_CXX11"; then
@@ -6319,6 +6326,49 @@ if test "$cxx11_constexpr" = yes; then
AC_DEFINE([HAVE_CXX11_CONSTEXPR])
fi
+AC_MSG_CHECKING([whether $CXX supports C++14 constexpr])
+save_CXXFLAGS=$CXXFLAGS
+CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
+AC_LANG_PUSH([C++])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ struct S {
+ int n_;
+ constexpr bool f() {
+ int n = n_;
+ int i = 0;
+ while (n > 0) { --n; ++i; }
+ return i == 0;
+ }
+ };
+ ]])], [cxx14_constexpr=yes], [cxx14_constexpr=no])
+AC_LANG_POP([C++])
+CXXFLAGS=$save_CXXFLAGS
+AC_MSG_RESULT([$cxx14_constexpr])
+if test "$cxx14_constexpr" = yes; then
+ AC_DEFINE([HAVE_CXX14_CONSTEXPR])
+fi
+
+AC_MSG_CHECKING([whether $CXX supports C++14 sized deallocation])
+save_CXXFLAGS=$CXXFLAGS
+CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
+AC_LANG_PUSH([C++])
+AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+ #include <cstddef>
+ #include <cstdlib>
+ void operator delete(void *) throw () { std::exit(1); }
+ void operator delete(void *, std::size_t) throw () { std::exit(0); }
+ struct S { S() { throw 0; } };
+ ]],[[
+ try { new S; } catch (...) {}
+ return 1;
+ ]])], [cxx14_sized_deallocation=yes], [cxx14_sized_deallocation=no])
+AC_LANG_POP([C++])
+CXXFLAGS=$save_CXXFLAGS
+AC_MSG_RESULT([$cxx14_sized_deallocation])
+if test "$cxx14_sized_deallocation" = yes; then
+ AC_DEFINE([HAVE_CXX14_SIZED_DEALLOCATION])
+fi
+
HAVE_GCC_PRAGMA_OPERATOR=
dnl _Pragma support (may require C++11)
if test "$GCC" = "yes"; then