From f58769c8f177601fe73cdec2042a0a65801261b3 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 10 Feb 2015 15:46:44 +0100 Subject: [PATCH] Properly check for Clang with static initializer_list bug Change-Id: I98060f1adae0ba8ec03b2f0d6b0db6d5a1c0385c --- config_host/config_global.h.in | 1 + configure.ac | 28 ++++++++++++++++++++++++++++ oox/source/export/shapes.cxx | 7 +++++-- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/config_host/config_global.h.in b/config_host/config_global.h.in index a1b8ffa4fcff..807d599b8046 100644 --- a/config_host/config_global.h.in +++ b/config_host/config_global.h.in @@ -22,6 +22,7 @@ Any change in this header will cause a rebuild of almost everything. #define HAVE_GCC_PRAGMA_OPERATOR 0 #define HAVE_GCC_DEPRECATED_MESSAGE 0 #define HAVE_THREADSAFE_STATICS 0 +#define HAVE_BROKEN_STATIC_INITILIZER_LIST 0 #define HAVE_SYSLOG_H 0 /* Compiler supports __attribute__((warn_unused)). */ #define HAVE_GCC_ATTRIBUTE_WARN_UNUSED 0 diff --git a/configure.ac b/configure.ac index 0e27a30a04e8..8ad4f6ca6fef 100644 --- a/configure.ac +++ b/configure.ac @@ -6225,6 +6225,34 @@ if test "$GCC" = "yes"; then fi AC_SUBST(HAVE_GCC_PRAGMA_OPERATOR) +AC_MSG_CHECKING([whether $CXX has broken static initializer_list support]) +save_CXXFLAGS=$CXXFLAGS +CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11" +AC_LANG_PUSH([C++]) +AC_RUN_IFELSE([AC_LANG_PROGRAM([[ + // Exit with failure if the static initializer_list is stored on the stack + // (as done by Clang < 3.4): + #include + struct S {}; + bool g(void const * p1, void const * p2) { + int n; + return !((p1 > p2 && p2 > &n) || (p1 < p2 && p2 < &n)); + } + bool f(void const * p1) { + static std::initializer_list s { S() }; + return g(p1, s.begin()); + } + ]],[[ + int n; + return f(&n) ? 0 : 1; + ]])], [broken=no], [broken=yes]) +AC_LANG_POP([C++]) +CXXFLAGS=$save_CXXFLAGS +AC_MSG_RESULT([$broken]) +if test "$broken" = yes; then + AC_DEFINE([HAVE_BROKEN_STATIC_INITILIZER_LIST]) +fi + dnl =================================================================== dnl system stl sanity tests dnl =================================================================== diff --git a/oox/source/export/shapes.cxx b/oox/source/export/shapes.cxx index fba5b8d5fe1a..4ef0838f233f 100644 --- a/oox/source/export/shapes.cxx +++ b/oox/source/export/shapes.cxx @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include + +#include #include #include #include "oox/core/xmlfilterbase.hxx" @@ -283,7 +286,7 @@ ShapeExport& ShapeExport::WriteGroupShape(uno::Reference xShape static bool lcl_IsOnBlacklist(OUString& rShapeType) { -#if !defined __clang__ +#if !HAVE_BROKEN_STATIC_INITILIZER_LIST static #endif const std::initializer_list vBlacklist = { @@ -347,7 +350,7 @@ static bool lcl_IsOnBlacklist(OUString& rShapeType) static bool lcl_IsOnWhitelist(OUString& rShapeType) { -#if !defined __clang__ +#if !HAVE_BROKEN_STATIC_INITILIZER_LIST static #endif const std::initializer_list vWhitelist = {