diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2018-09-10 18:04:04 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2018-09-11 13:48:55 +0200 |
commit | 3b835b8d546ca16d7edcb06eda017e276383ea0f (patch) | |
tree | 4d691d7d4fb2756735da020cece19ee1171d9a85 /configure.ac | |
parent | 3d39dad6d93c979ac64244ecb9acfbd8a5fbd6c6 (diff) |
Use [[nodiscard]] in SAL_WARN_UNUSED_RESULT where available
...which required some lax placements of SAL_WARN_UNUSED_RESULT to be fixed.
Also, Clang unfortunately is rather picky about the relative order of
SAL_WARN_UNUSED_RESULT expanding to [[nodiscard]] and uses of the DLLPUBLIC
macros (expanding to __attribute__(...) resp. __declspec(..) for clang-cl).
Change-Id: Iae6ca36bef97f1864873aefdb5f05c7f5e045ad3
Reviewed-on: https://gerrit.libreoffice.org/60274
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac index 9861188660e2..56b798644f9f 100644 --- a/configure.ac +++ b/configure.ac @@ -6408,6 +6408,33 @@ if test "$GCC" = yes; then fi AC_SUBST([HAVE_GCC_FNO_SIZED_DEALLOCATION]) +AC_MSG_CHECKING([[whether $CXX supports [[nodiscard]]]]) +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 "$_os" = WINNT; then + CXXFLAGS="$CXXFLAGS /WX" +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(nodiscard) + #error + #endif + #else + [[nodiscard]] int f(); + #endif + ]])], [ + AC_DEFINE([HAVE_CPP_ATTRIBUTE_NODISCARD],[1]) + AC_MSG_RESULT([yes]) + ], [AC_MSG_RESULT([no])]) +CXXFLAGS=$save_CXXFLAGS +AC_LANG_POP([C++]) + AC_MSG_CHECKING([whether $CXX supports guaranteed copy elision]) AC_LANG_PUSH([C++]) save_CXXFLAGS=$CXXFLAGS |