Skip to content
Snippets Groups Projects
Commit e90c9657 authored by Steffen Müthing's avatar Steffen Müthing
Browse files

Merge branch 'feature/add-constexpr-config-tests' into 'master'

[cmake] Add tests for some advanced constexpr features

See merge request !303
parents d455980a f212affd
No related branches found
No related tags found
No related merge requests found
......@@ -440,3 +440,44 @@ if(NOT STDTHREAD_WORKS)
"STDTHREAD_LINK_FLAGS. If you think this test is wrong, set the cache "
"variable STDTHREAD_WORKS.")
endif(NOT STDTHREAD_WORKS)
# Make sure we have working generalized constexpr - GCC 4.9 lacks this feature
check_cxx_source_compiles("
constexpr int foo(int bar)
{
int r = 1;
for (int i = 0 ; i < bar ; ++i)
r += r;
return r;
}
int main()
{
static_assert(foo(4) == 16, \"test failed\");
return 0;
}
" DUNE_HAVE_CXX_GENERALIZED_CONSTEXPR
)
# Check whether we can conditionally throw exceptions in constexpr context to
# signal errors both at compile time and at run time - this does not work in GCC 5
check_cxx_source_compiles("
constexpr int foo(int bar)
{
if (bar < 0)
throw bar;
int r = 1;
for (int i = 0 ; i < bar ; ++i)
r += r;
return r;
}
int main()
{
static_assert(foo(4) == 16, \"test failed\");
return 0;
}
" DUNE_SUPPORTS_CXX_THROW_IN_CONSTEXPR
)
......@@ -29,6 +29,12 @@
/* does the compiler support C++17's class template argument deduction? */
#cmakedefine DUNE_HAVE_CXX_CLASS_TEMPLATE_ARGUMENT_DEDUCTION 1
/* does the compiler support C++14's generalized constant expressions? */
#cmakedefine DUNE_HAVE_CXX_GENERALIZED_CONSTEXPR 1
/* does the compiler support conditionally throwing exceptions in constexpr context? */
#cmakedefine DUNE_SUPPORTS_CXX_THROW_IN_CONSTEXPR 1
/* Define if you have a BLAS library. */
#cmakedefine HAVE_BLAS 1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment