Adding new features to features.cpp compiler checks.

This commit is contained in:
Stefano Sanfilippo 2015-03-05 14:24:27 +01:00
parent 25153e8a85
commit 82b63189f4
2 changed files with 44 additions and 1 deletions

View File

@ -25,7 +25,8 @@ message("== Report build errors to https://github.com/esseks/monicelli/issues")
## 1. Compiler sanity check
try_compile(
try_run(
execution_results
supported_compiler
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/cmake/features.cpp
@ -44,6 +45,14 @@ if (NOT supported_compiler)
)
endif()
if (execution_results MATCHES FAILED_TO_RUN)
message(FATAL_ERROR
"Your compiler supports the set of C++11 features we need, "
"but something failed.\n"
"Run cmake with -Dcheckfeat=1 to see the exact cause."
)
endif()
## 2. Find Flex and Bison
find_package(BISON REQUIRED)

View File

@ -28,6 +28,24 @@
#include <vector>
#include <string>
#include <cassert>
const int global_i = 0;
struct TestingReferenceBinding {
TestingReferenceBinding(int const& ii) {
assert(&ii == &global_i);
}
void operator=(int const& ii) {
assert(&ii == &global_i);
}
void operator=(int&&) {
assert(false);
}
};
enum class Dummy {
FOO, BAR, BAZ
@ -37,6 +55,12 @@ class Banana {
int yep() const noexcept {
return 0;
}
virtual void something() {}
};
class Phone: public Banana {
virtual void something() override {}
};
int main() {
@ -49,4 +73,14 @@ int main() {
Banana a;
Banana b = std::move(a);
long c = std::stol("100");
// Boost::Optional sanity check for old compilers
int const& iref = global_i;
assert(&iref == &global_i);
TestingReferenceBinding ttt = global_i;
ttt = global_i;
TestingReferenceBinding ttt2 = iref;
ttt2 = iref;
}