Commit bd3b03d4 authored by Praetorius, Simon's avatar Praetorius, Simon

Compiler-tests updated

parent 18f77e83
set(COMPILER_TEST_DIR ${CMAKE_BINARY_DIR}/CMakeFiles/compilerTest)
file(WRITE ${COMPILER_TEST_DIR}/CMakeLists.txt
"project(compilerTest)
cmake_minimum_required(VERSION 2.8)
add_definitions(-std=c++11)
# VARIADIC CLASS_TEMPLATES
add_executable(test_variadic_templ_class test_variadic_templ_class.cpp)
target_link_libraries(test_variadic_templ_class)
# VARIADIC FUNCTION TEMPLATES
add_executable(test_variadic_templ_fct test_variadic_templ_fct.cpp)
target_link_libraries(test_variadic_templ_fct)
# ALIAS TEMPLATES
add_executable(test_alias_templates test_alias_templates.cpp)
target_link_libraries(test_alias_templates)
# DECLTYPE
add_executable(test_decltype test_decltype.cpp)
target_link_libraries(test_decltype)
# AUTO SPECIFIER
add_executable(test_auto test_auto.cpp)
target_link_libraries(test_auto)
# CONSTEXPR
add_executable(test_constexpr test_constexpr.cpp)
target_link_libraries(test_constexpr)
# DELEGATING CONSTRUCTORS
add_executable(test_delegating_constructors test_delegating_constructors.cpp)
target_link_libraries(test_delegating_constructors)
# RANGE-BASED FOR LOOPS
add_executable(test_range_based_for test_range_based_for.cpp)
target_link_libraries(test_range_based_for)")
file(WRITE ${COMPILER_TEST_DIR}/test_variadic_templ_class.cpp
"template<class... Ts> struct A{}; int main(){A<int, double> a;}")
file(WRITE ${COMPILER_TEST_DIR}/test_variadic_templ_fct.cpp
"template<class... Ts> void foo(Ts... ts){}; int main(){foo(1, 2.0, 3.0f);}")
file(WRITE ${COMPILER_TEST_DIR}/test_alias_templates.cpp
"template<class T> struct A{}; template<class T> using B=A<T>; int main(){B<int> b;}")
file(WRITE ${COMPILER_TEST_DIR}/test_decltype.cpp
"int main(){decltype(1) a = 1;}")
file(WRITE ${COMPILER_TEST_DIR}/test_auto.cpp
"int main(){auto a = 1;}")
file(WRITE ${COMPILER_TEST_DIR}/test_constexpr.cpp
"constexpr int foo(){return 1;}; int main(){static constexpr int f = foo();}")
file(WRITE ${COMPILER_TEST_DIR}/test_delegating_constructors.cpp
"struct A{ A(){} A(int) : A(){} }; int main(){ A a(1);}")
file(WRITE ${COMPILER_TEST_DIR}/test_range_based_for.cpp
"int main(){ int vec[10]; for (int& elem : vec) { elem = 1; } }")
set(COMPILER_CXX11_FEATURES "")
try_compile(TEST_VARIADIC_TEMPL_CLASS ${COMPILER_TEST_DIR} ${COMPILER_TEST_DIR} compilerTest test_variadic_templ_class)
try_compile(TEST_VARIADIC_TEMPL_FCT ${COMPILER_TEST_DIR} ${COMPILER_TEST_DIR} compilerTest test_variadic_templ_fct)
if (TEST_VARIADIC_TEMPL_CLASS AND TEST_VARIADIC_TEMPL_FCT)
message("Compiler supports variadic class/ function templates")
list(APPEND COMPILER_CXX11_FEATURES "-DHAS_VARIADIC_TEMPLATES=1")
endif()
try_compile(TEST_ALIAS_TEMPLATES ${COMPILER_TEST_DIR} ${COMPILER_TEST_DIR} compilerTest test_alias_templates)
if (TEST_ALIAS_TEMPLATES)
message("Compiler supports alias-templates")
list(APPEND COMPILER_CXX11_FEATURES "-DHAS_ALIAS_TEMPLATES=1")
endif()
try_compile(TEST_DECLTYPE ${COMPILER_TEST_DIR} ${COMPILER_TEST_DIR} compilerTest test_decltype)
if (TEST_DECLTYPE)
message("Compiler supports decltype")
list(APPEND COMPILER_CXX11_FEATURES "-DHAS_DECLTYPE=1")
endif()
try_compile(TEST_AUTO_SPECIFIER ${COMPILER_TEST_DIR} ${COMPILER_TEST_DIR} compilerTest test_auto)
if (TEST_AUTO_SPECIFIER)
message("Compiler supports auto")
list(APPEND COMPILER_CXX11_FEATURES "-DHAS_AUTO=1")
endif()
try_compile(TEST_CONSTEXPR ${COMPILER_TEST_DIR} ${COMPILER_TEST_DIR} compilerTest test_constexpr)
if (TEST_CONSTEXPR)
message("Compiler supports constexpr")
list(APPEND COMPILER_CXX11_FEATURES "-DHAS_CONSTEXPR=1")
endif()
try_compile(TEST_DELEGATING_CONSTRUCTORS ${COMPILER_TEST_DIR} ${COMPILER_TEST_DIR} compilerTest test_delegating_constructors)
if (TEST_DELEGATING_CONSTRUCTORS)
message("Compiler supports delegating constructors")
list(APPEND COMPILER_CXX11_FEATURES "-DHAS_DELEGATING_CONSTRUCTORS=1")
endif()
try_compile(TEST_RANGED_BASED_FOR ${COMPILER_TEST_DIR} ${COMPILER_TEST_DIR} compilerTest test_range_based_for)
if (TEST_RANGED_BASED_FOR)
message("Compiler supports range-based for loops")
list(APPEND COMPILER_CXX11_FEATURES "-DHAS_RANGE_BASED_FOR=1")
endif()
\ No newline at end of file
......@@ -72,7 +72,7 @@ namespace AMDiS {
}
#if __cplusplus > 199711L
#if HAS_CXX11
// c++11 std::function of lambda-functions
void DirichletBC<_value_by_function>::fillBoundaryCondition(
DOFVectorBase<double>* vector,
......
......@@ -160,7 +160,7 @@ namespace AMDiS
};
#if __cplusplus > 199711L
#if HAS_CXX11
// specialization for std::function or lambdas as value container
template <>
class DirichletBC<_value_by_function> : public detail::DirichletBC
......
......@@ -1403,7 +1403,7 @@ namespace AMDiS {
}
#if __cplusplus > 199711L
#if HAS_CXX11
void ProblemStatSeq::addDirichletBC(BoundaryType type, int row, int col,
std::function<double(WorldVector<double>)> b)
{
......
......@@ -27,9 +27,7 @@
#include <vector>
#include <list>
#if __cplusplus > 199711L
#include <functional>
#endif
#include "AMDiS_fwd.h"
#include "ProblemStatBase.h"
#include "Initfile.h"
......@@ -193,7 +191,7 @@ namespace AMDiS {
AbstractFunction<double, WorldVector<double> > *b);
#if __cplusplus > 199711L
#if HAS_CXX11
/// Adds a Dirichlet boundary condition, where the rhs is given by an
/// lambda function or a std::function object
virtual void addDirichletBC(BoundaryType type, int row, int col,
......
......@@ -48,45 +48,46 @@ typedef size_t aligned_size_t __attribute__ ((aligned(CACHE_LINE)));
// C++11 features
// --------------
#if __cplusplus > 199711L
#define HAS_CXX11 1
// __has_feature(cxx_rvalue_references)
#if CLANG_VERSION >= 20900
#if CLANG_VERSION >= 20900 && !defined(HAS_VARIADIC_TEMPLATES)
#define HAS_VARIADIC_TEMPLATES 1
#endif
#if CLANG_VERSION >= 30000
#if CLANG_VERSION >= 30000 && !defined(HAS_ALIAS_TEMPLATES)
#define HAS_ALIAS_TEMPLATES 1
#endif
#if CLANG_VERSION >= 20900
#if CLANG_VERSION >= 20900 && !defined(HAS_DECLTYPE)
#define HAS_DECLTYPE 1
#endif
#if CLANG_VERSION >= 30100
#if CLANG_VERSION >= 30100 && !defined(HAS_CONSTEXPR)
#define HAS_CONSTEXPR 1
#endif
#if CLANG_VERSION >= 30000
#if CLANG_VERSION >= 30000 && !defined(HAS_DELEGATING_CONSTRUCTORS)
#define HAS_DELEGATING_CONSTRUCTORS 1
#endif
#if CLANG_VERSION >= 30000
#if CLANG_VERSION >= 30000 && !defined(HAS_RANGE_BASED_FOR)
#define HAS_RANGE_BASED_FOR 1
#endif
#if CLANG_VERSION >= 30100
#if CLANG_VERSION >= 30100 && !defined(HAS_INITIALIZER_LISTS)
#define HAS_INITIALIZER_LISTS 1
#endif
#if CLANG_VERSION >= 30000
#if CLANG_VERSION >= 30000 && !defined(HAS_OVERRIDE)
#define HAS_OVERRIDE 1
#endif
#if CLANG_VERSION >= 20900
#if CLANG_VERSION >= 20900 && !defined(HAS_TYPED_ENUMS)
#define HAS_TYPED_ENUMS 1
#endif
#if CLANG_VERSION >= 20900
#if CLANG_VERSION >= 20900 && !defined(HAS_RVALUE_REFERENCES)
#define HAS_RVALUE_REFERENCES 1
#endif
......
......@@ -63,6 +63,10 @@ typedef size_t aligned_size_t;
// C++11 features
// --------------
#ifndef HAS_CXX11
#define HAS_CXX11 0
#endif
#ifndef HAS_VARIADIC_TEMPLATES
#define HAS_VARIADIC_TEMPLATES 0
#endif
......
......@@ -48,44 +48,45 @@ typedef size_t aligned_size_t __attribute__ ((aligned(CACHE_LINE)));
// C++11 features
// --------------
#if __cplusplus > 199711L
#define HAS_CXX11 1
#if GCC_VERSION >= 40300
#if GCC_VERSION >= 40300 && !defined(HAS_VARIADIC_TEMPLATES)
#define HAS_VARIADIC_TEMPLATES 1
#endif
#if GCC_VERSION >= 40700
#if GCC_VERSION >= 40700 && !defined(HAS_ALIAS_TEMPLATES)
#define HAS_ALIAS_TEMPLATES 1
#endif
#if GCC_VERSION >= 40300
#if GCC_VERSION >= 40300 && !defined(HAS_DECLTYPE)
#define HAS_DECLTYPE 1
#endif
#if GCC_VERSION >= 40600
#if GCC_VERSION >= 40600 && !defined(HAS_CONSTEXPR)
#define HAS_CONSTEXPR 1
#endif
#if GCC_VERSION >= 40700
#if GCC_VERSION >= 40700 && !defined(HAS_DELEGATING_CONSTRUCTORS)
#define HAS_DELEGATING_CONSTRUCTORS 1
#endif
#if GCC_VERSION >= 40600
#if GCC_VERSION >= 40600 && !defined(HAS_RANGE_BASED_FOR)
#define HAS_RANGE_BASED_FOR 1
#endif
#if GCC_VERSION >= 40400
#if GCC_VERSION >= 40400 && !defined(HAS_INITIALIZER_LISTS)
#define HAS_INITIALIZER_LISTS 1
#endif
#if GCC_VERSION >= 40700
#if GCC_VERSION >= 40700 && !defined(HAS_OVERRIDE)
#define HAS_OVERRIDE 1
#endif
#if GCC_VERSION >= 40400
#if GCC_VERSION >= 40400 && !defined(HAS_TYPED_ENUMS)
#define HAS_TYPED_ENUMS 1
#endif
#if GCC_VERSION >= 40300
#if GCC_VERSION >= 40300 && !defined(HAS_RVALUE_REFERENCES)
#define HAS_RVALUE_REFERENCES 1
#endif
......
......@@ -51,45 +51,51 @@ typedef __declspec(align(CACHE_LINE)) size_t aligned_size_t;
// C++11 features
// --------------
#if __cplusplus > 199711L
// #if __cplusplus > 199711L
// workaround needed to test for -std=c++11 enabled, since __cplusplus gives wrong values
#include <vector>
#include <functional>
#if defined(_GLIBCXX_TUPLE) || defined(_GLIBCXX_TYPE_TRAITS) || defined(_GLIBCXX_ARRAY)
#if INTEL_VERSION >= 1201
#define HAS_CXX11 1
#if INTEL_VERSION >= 1201 && !defined(HAS_VARIADIC_TEMPLATES)
#define HAS_VARIADIC_TEMPLATES 1
#endif
#if INTEL_VERSION >= 1201
#if INTEL_VERSION >= 1201 && !defined(HAS_ALIAS_TEMPLATES)
#define HAS_ALIAS_TEMPLATES 1
#endif
#if INTEL_VERSION >= 1200
#if INTEL_VERSION >= 1200 && !defined(HAS_DECLTYPE)
#define HAS_DECLTYPE 1
#endif
#if INTEL_VERSION >= 1400
#if INTEL_VERSION >= 1400 && !defined(HAS_CONSTEXPR)
#define HAS_CONSTEXPR 1
#endif
#if INTEL_VERSION >= 1400
#if INTEL_VERSION >= 1400 && !defined(HAS_DELEGATING_CONSTRUCTORS)
#define HAS_DELEGATING_CONSTRUCTORS 1
#endif
#if INTEL_VERSION >= 1400
#if INTEL_VERSION >= 1400 && !defined(HAS_RANGE_BASED_FOR)
#define HAS_RANGE_BASED_FOR 1
#endif
#if INTEL_VERSION >= 1400
#if INTEL_VERSION >= 1400 && !defined(HAS_INITIALIZER_LISTS)
#define HAS_INITIALIZER_LISTS 1
#endif
#if INTEL_VERSION >= 1400
#if INTEL_VERSION >= 1400 && !defined(HAS_OVERRIDE)
#define HAS_OVERRIDE 1
#endif
#if INTEL_VERSION >= 1400
#if INTEL_VERSION >= 1400 && !defined(HAS_TYPED_ENUMS)
#define HAS_TYPED_ENUMS 1
#endif
#if INTEL_VERSION >= 1200
#if INTEL_VERSION >= 1200 && !defined(HAS_RVALUE_REFERENCES)
#define HAS_RVALUE_REFERENCES 1
#endif
......
......@@ -54,44 +54,46 @@ typedef __declspec(align(CACHE_LINE)) size_t aligned_size_t;
// C++11 features
// --------------
#if __cplusplus > 199711L
#define HAS_CXX11 1
#if MSC_VERSION >= 1800
#if MSC_VERSION >= 1800 && !defined(HAS_VARIADIC_TEMPLATES)
#define HAS_VARIADIC_TEMPLATES 1
#endif
#if MSC_VERSION >= 1800
#if MSC_VERSION >= 1800 && !defined(HAS_ALIAS_TEMPLATES)
#define HAS_ALIAS_TEMPLATES 1
#endif
#if MSC_VERSION >= 1600
#if MSC_VERSION >= 1600 && !defined(HAS_DECLTYPE)
#define HAS_DECLTYPE 1
#endif
// #if MSC_VERSION >= 2000 (?)
#if !defined(HAS_CONSTEXPR)
#define HAS_CONSTEXPR 0
// #endif
#endif
#if MSC_VERSION >= 1800
#if MSC_VERSION >= 1800 && !defined(HAS_DELEGATING_CONSTRUCTORS)
#define HAS_DELEGATING_CONSTRUCTORS 1
#endif
#if MSC_VERSION >= 1700
#if MSC_VERSION >= 1700 && !defined(HAS_RANGE_BASED_FOR)
#define HAS_RANGE_BASED_FOR 1
#endif
#if MSC_VERSION >= 1800
#if MSC_VERSION >= 1800 && !defined(HAS_INITIALIZER_LISTS)
#define HAS_INITIALIZER_LISTS 1
#endif
#if MSC_VERSION >= 1700
#if MSC_VERSION >= 1700 && !defined(HAS_OVERRIDE)
#define HAS_OVERRIDE 1
#endif
#if MSC_VERSION >= 1700
#if MSC_VERSION >= 1700 && !defined(HAS_TYPED_ENUMS)
#define HAS_TYPED_ENUMS 1
#endif
#if MSC_VERSION >= 1600
#if MSC_VERSION >= 1600 && !defined(HAS_RVALUE_REFERENCES)
#define HAS_RVALUE_REFERENCES 1
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment