configure.ac |   90 ++++++++++++++++++++++++++++++++---------------------------
 1 file changed, 50 insertions(+), 40 deletions(-)

New commits:
commit 7b26ac7e8eba298ba173c682bbd952f60a59c5f3
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Fri Nov 12 11:06:57 2021 +0100
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Fri Nov 12 13:04:09 2021 +0100

    Fix HAVE_CPP_CONSTEVAL check for MSVC
    
    For one, it always trivially failed with
    
    > LINK : fatal error LNK1104: cannot open file 'LIBCMT.lib'
    
    because of a missing LIB env var expected by cl.  (Rather using LDFLAGS with
    something like
    
    > LDFLAGS="$LDFLAGS -LIBPATH:$COMPATH/lib/$WIN_HOST_ARCH"
    
    instead of prepending LIB to $CXX via env wouldn't work, as AC_RUN_IFELSE 
puts
    LDFLAGS too early on the compiler command line, causing "cl : Command line
    warning D9002 : ignoring unknown option '-LIBPATH:...'".  And just using
    something like
    
    > CXX="env LIB=$COMPATH/lib/$WIN_HOST_ARCH $CXX"
    
    instead of the full $ILIB would cause "LINK : fatal error LNK1104: cannot 
open
    file 'kernel32.lib'".)  This means that the HAVE_CPP_CONSEVAL check had to 
be
    moved past setting up ILIB.
    
    But for another, detection of HAVE_CPP_CONSTEVAL under --with-latest-c++ 
would
    trigger MSVC bug <https://developercommunity.visualstudio.com/t/1581879> 
"Bogus
    error C7595 with consteval constructor in ternary expression 
(/std:c++latest)"
    at
    
    > sd/source/ui/unoidl/unoobj.cxx(742): error C7595: 'Color::Color': call to 
immediate function is not a constant expression
    
    (and see also f8a30a87a9d0c68dc16d5fa2ca63f687b1d90da1 "Fix (mis-)uses of
    temporary O[U]StringLiteral") so add a test for that bug to the checking 
code.
    
    Change-Id: Iedf793f388fc190555a71ed3ab63e87a77ad4828
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125093
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/configure.ac b/configure.ac
index 336c79925427..23c2beaceefd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -7347,46 +7347,6 @@ if test "$GCC" = yes; then
 fi
 AC_SUBST([HAVE_GCC_FNO_SIZED_DEALLOCATION])
 
-AC_MSG_CHECKING([whether $CXX_BASE supports a working C++20 consteval])
-dnl ...that does not suffer from 
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96994> "Missing code
-dnl from consteval constructor initializing const variable",
-dnl <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98752> "wrong 'error: ‘this’ 
is not a constant
-dnl expression' with consteval constructor", or 
<https://bugs.llvm.org/show_bug.cgi?id=50063> "code
-dnl using consteval: 'clang/lib/CodeGen/Address.h:38: llvm::Value*
-dnl clang::CodeGen::Address::getPointer() const: Assertion `isValid()' 
failed.'":
-AC_LANG_PUSH([C++])
-save_CXXFLAGS=$CXXFLAGS
-CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
-AC_RUN_IFELSE([AC_LANG_PROGRAM([
-        struct S {
-            consteval S() { i = 1; }
-            int i = 0;
-        };
-        S const s;
-
-        struct S1 { consteval S1(int) {} };
-        struct S2 {
-            S1 x;
-            S2(): x(0) {}
-        };
-
-        struct S3 {
-            consteval S3() {}
-            union {
-                int a;
-                unsigned b = 0;
-            };
-        };
-        void f() { S3(); }
-    ], [
-        return (s.i == 1) ? 0 : 1;
-    ])], [
-        AC_DEFINE([HAVE_CPP_CONSTEVAL],[1])
-        AC_MSG_RESULT([yes])
-    ], [AC_MSG_RESULT([no])], [AC_MSG_RESULT([assumed no (cross compiling)])])
-CXXFLAGS=$save_CXXFLAGS
-AC_LANG_POP([C++])
-
 AC_MSG_CHECKING([whether $CXX_BASE supports C++2a constinit sorted vectors])
 AC_LANG_PUSH([C++])
 save_CXXFLAGS=$CXXFLAGS
@@ -14177,6 +14137,56 @@ fi
 AC_SUBST(ILIB)
 AC_SUBST(ILIB_FOR_BUILD)
 
+AC_MSG_CHECKING([whether $CXX_BASE supports a working C++20 consteval])
+dnl ...that does not suffer from 
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96994> "Missing code
+dnl from consteval constructor initializing const variable",
+dnl <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98752> "wrong 'error: ‘this’ 
is not a constant
+dnl expression' with consteval constructor", 
<https://bugs.llvm.org/show_bug.cgi?id=50063> "code
+dnl using consteval: 'clang/lib/CodeGen/Address.h:38: llvm::Value*
+dnl clang::CodeGen::Address::getPointer() const: Assertion `isValid()' 
failed.'", or
+dnl <https://developercommunity.visualstudio.com/t/1581879> "Bogus error C7595 
with consteval
+dnl constructor in ternary expression (/std:c++latest)":
+AC_LANG_PUSH([C++])
+save_CXX=$CXX
+if test "$COM" = MSC && test "$COM_IS_CLANG" != TRUE; then
+    CXX="env LIB=$ILIB $CXX"
+fi
+save_CXXFLAGS=$CXXFLAGS
+CXXFLAGS="$CXXFLAGS $CXXFLAGS_CXX11"
+AC_RUN_IFELSE([AC_LANG_PROGRAM([
+        struct S {
+            consteval S() { i = 1; }
+            int i = 0;
+        };
+        S const s;
+
+        struct S1 { consteval S1(int) {} };
+        struct S2 {
+            S1 x;
+            S2(): x(0) {}
+        };
+
+        struct S3 {
+            consteval S3() {}
+            union {
+                int a;
+                unsigned b = 0;
+            };
+        };
+        void f() { S3(); }
+
+        struct S4 { consteval S4() = default; };
+        void f4(bool b) { b ? S4() : S4(); }
+    ], [
+        return (s.i == 1) ? 0 : 1;
+    ])], [
+        AC_DEFINE([HAVE_CPP_CONSTEVAL],[1])
+        AC_MSG_RESULT([yes])
+    ], [AC_MSG_RESULT([no])], [AC_MSG_RESULT([assumed no (cross compiling)])])
+CXX=$save_CXX
+CXXFLAGS=$save_CXXFLAGS
+AC_LANG_POP([C++])
+
 # ===================================================================
 # Creating bigger shared library to link against
 # ===================================================================

Reply via email to