]> https://gitweb.dealii.org/ - dealii.git/commitdiff
clang 4 constexpr detection
authorTimo Heister <timo.heister@gmail.com>
Tue, 17 Mar 2020 15:06:02 +0000 (11:06 -0400)
committerTimo Heister <timo.heister@gmail.com>
Tue, 17 Mar 2020 16:31:03 +0000 (12:31 -0400)
At least clang 4.0.1 complains about the use of non-const constexpr
functions. Fix this by setting
DEAL_II_HAVE_CXX14_CONSTEXPR_CAN_CALL_NONCONSTEXPR only if we actually
have CXX14 support.

cmake/checks/check_01_cxx_features.cmake

index a80d781c101e9e1ce65f2f8f1a61a7c38dda9a77..a723c66d37f4969f1cb8a1a68dc7ae92ea848593 100644 (file)
@@ -729,13 +729,17 @@ CHECK_CXX_SOURCE_COMPILES(
 # As long as there exists an argument value such that an invocation of the
 # function or constructor could be an evaluated subexpression of a core constant
 # expression, C++14 allows to call non-constexpr functions from constexpr
-# functions. Unfortunately, not all compilers obey the standard in this regard.
+# functions.
 #
-# In some cases, MSVC 2019 crashes with an internal compiler error when we
+# Only run this check if we have CXX14 support, otherwise the use of constexpr
+# is limited (non-const constexp functions for example).
+#
+# Unfortunately, not all compilers obey the standard in this regard. In some
+# cases, MSVC 2019 crashes with an internal compiler error when we
 # declare the respective functions as 'constexpr' even though the test below
 # passes, see #9080.
 #
-IF(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
+IF(DEAL_II_WITH_CXX14 AND NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
   CHECK_CXX_SOURCE_COMPILES(
     "
     #define Assert(x,y) if (!(x)) throw y;

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.