mirror of
https://github.com/google/benchmark.git
synced 2024-11-28 15:34:33 +00:00
Fix #50 by using nullptr and adding stricter warning.
This commit is contained in:
parent
cfb34b5957
commit
e6107a781c
|
@ -40,6 +40,7 @@ add_cxx_compiler_flag(-Wall)
|
||||||
add_cxx_compiler_flag(-Wshadow)
|
add_cxx_compiler_flag(-Wshadow)
|
||||||
add_cxx_compiler_flag(-Werror)
|
add_cxx_compiler_flag(-Werror)
|
||||||
add_cxx_compiler_flag(-pedantic-errors)
|
add_cxx_compiler_flag(-pedantic-errors)
|
||||||
|
add_cxx_compiler_flag(-Wzero-as-null-pointer-constant)
|
||||||
|
|
||||||
# Release flags
|
# Release flags
|
||||||
add_cxx_compiler_flag(-fno-strict-aliasing RELEASE)
|
add_cxx_compiler_flag(-fno-strict-aliasing RELEASE)
|
||||||
|
|
|
@ -22,13 +22,18 @@ function(cxx_feature_check FILE)
|
||||||
string(TOUPPER ${FILE} VAR)
|
string(TOUPPER ${FILE} VAR)
|
||||||
string(TOUPPER "HAVE_${VAR}" FEATURE)
|
string(TOUPPER "HAVE_${VAR}" FEATURE)
|
||||||
message("-- Performing Test ${FEATURE}")
|
message("-- Performing Test ${FEATURE}")
|
||||||
try_run(RUN_${FEATURE} COMPILE_${FEATURE} ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${FILE}.cpp)
|
try_run(RUN_${FEATURE} COMPILE_${FEATURE}
|
||||||
|
${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${FILE}.cpp)
|
||||||
if(RUN_${FEATURE} EQUAL 0)
|
if(RUN_${FEATURE} EQUAL 0)
|
||||||
message("-- Performing Test ${FEATURE} -- Success")
|
message("-- Performing Test ${FEATURE} -- success")
|
||||||
set(HAVE_${VAR} 1 PARENT_SCOPE)
|
set(HAVE_${VAR} 1 PARENT_SCOPE)
|
||||||
add_definitions(-DHAVE_${VAR})
|
add_definitions(-DHAVE_${VAR})
|
||||||
else()
|
else()
|
||||||
message("-- Performing Test ${FEATURE} -- Failed")
|
if(NOT COMPILE_${FEATURE})
|
||||||
|
message("-- Performing Test ${FEATURE} -- failed to compile")
|
||||||
|
else()
|
||||||
|
message("-- Performing Test ${FEATURE} -- compiled but failed to run")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,6 @@ int main() {
|
||||||
if (ec != 0) {
|
if (ec != 0) {
|
||||||
return ec;
|
return ec;
|
||||||
}
|
}
|
||||||
return regexec(&re, str.c_str(), 0, NULL, 0) ? -1 : 0;
|
return regexec(&re, str.c_str(), 0, nullptr, 0) ? -1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,6 @@ int main() {
|
||||||
if (ec != 0) {
|
if (ec != 0) {
|
||||||
return ec;
|
return ec;
|
||||||
}
|
}
|
||||||
return regexec(&re, str.c_str(), 0, NULL, 0) ? -1 : 0;
|
return regexec(&re, str.c_str(), 0, nullptr, 0) ? -1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,9 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
int main() {
|
int main() {
|
||||||
const std::string str = "test0159";
|
const std::string str = "test0159";
|
||||||
const std::regex re("^[a-z]+[0-9]+$", std::regex_constants::extended | std::regex_constants::nosubs);
|
const std::regex re(
|
||||||
|
"^[a-z]+[0-9]+$",
|
||||||
|
std::regex_constants::extended | std::regex_constants::nosubs);
|
||||||
return std::regex_search(str, re) ? 0 : -1;
|
return std::regex_search(str, re) ? 0 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue