Skip to content

Commit

Permalink
Merge pull request #58 from google/zero_null
Browse files Browse the repository at this point in the history
Fix #50 by using nullptr and adding stricter warning.
  • Loading branch information
ckennelly committed Oct 18, 2014
2 parents 5f31f0d + e6107a7 commit 8eac5dc
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ add_cxx_compiler_flag(-Wall)
add_cxx_compiler_flag(-Wshadow)
add_cxx_compiler_flag(-Werror)
add_cxx_compiler_flag(-pedantic-errors)
add_cxx_compiler_flag(-Wzero-as-null-pointer-constant)

# Release flags
add_cxx_compiler_flag(-fno-strict-aliasing RELEASE)
Expand Down
11 changes: 8 additions & 3 deletions cmake/CXXFeatureCheck.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@ function(cxx_feature_check FILE)
string(TOUPPER ${FILE} VAR)
string(TOUPPER "HAVE_${VAR}" 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)
message("-- Performing Test ${FEATURE} -- Success")
message("-- Performing Test ${FEATURE} -- success")
set(HAVE_${VAR} 1 PARENT_SCOPE)
add_definitions(-DHAVE_${VAR})
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()
endfunction()

2 changes: 1 addition & 1 deletion cmake/gnu_posix_regex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ int main() {
if (ec != 0) {
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 changes: 1 addition & 1 deletion cmake/posix_regex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ int main() {
if (ec != 0) {
return ec;
}
return regexec(&re, str.c_str(), 0, NULL, 0) ? -1 : 0;
return regexec(&re, str.c_str(), 0, nullptr, 0) ? -1 : 0;
}

4 changes: 3 additions & 1 deletion cmake/std_regex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
#include <string>
int main() {
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;
}

0 comments on commit 8eac5dc

Please sign in to comment.