Skip to content
Snippets Groups Projects
Commit b52cef8f authored by Ben Cumming's avatar Ben Cumming Committed by GitHub
Browse files

Merge pull request #25 from halfflat/feature/address-clang-warnings

Address clang compiler warnings
parents 4fdb313b 034b17bb
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,10 @@ enable_language(CXX)
set(SAVED_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
# compilation flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=c++11 -pthread -Wall")
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include("CompilerOptions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXXOPT_DEBUG} ${CXXOPT_CXX11} ${CXXOPT_PTHREAD} ${CXXOPT_WALL}")
# -g -std=c++11 -pthread -Wall")
# this generates a .json file with full compilation command for each file
set(CMAKE_EXPORT_COMPILE_COMMANDS "YES")
......
# Compiler-aware compiler options
set(CXXOPT_DEBUG "-g")
set(CXXOPT_PTHREAD "-pthread")
set(CXXOPT_CXX11 "-std=c++11")
set(CXXOPT_WALL "-Wall")
if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
# Disable 'missing-braces' warning: this will inappropriately
# flag initializations such as
# std::array<int,3> a={1,2,3};
set(CXXOPT_WALL "${CXXOPT_WALL} -Wno-missing-braces")
endif()
......@@ -107,7 +107,7 @@ namespace detail {
template <typename Y>
bool operator==(const optional<Y> &o) const {
return set && o.set && ref()==o.ref() || !set && !o.set;
return (set && o.set && ref()==o.ref()) || (!set && !o.set);
}
void reset() {
......
......@@ -5,6 +5,11 @@
#include "gtest.h"
#include "util/optional.hpp"
#if defined(__clang__)
// refer: https://llvm.org/bugs/show_bug.cgi?id=21629
//#pragma clang diagnostic ignored "-Wmissing-braces"
#endif
using namespace nest::mc::util;
TEST(optionalm,ctors) {
......@@ -61,7 +66,7 @@ TEST(optionalm,deref) {
TEST(optionalm,ctor_conv) {
optional<std::array<int,3>> x{{1,2,3}};
EXPECT_EQ(3,x->size());
EXPECT_EQ(3u,x->size());
}
TEST(optionalm,ctor_ref) {
......
......@@ -60,7 +60,7 @@ nlohmann::json
load_spike_data(const std::string& input_name)
{
nlohmann::json cell_data;
auto fid = std::ifstream(input_name);
std::ifstream fid(input_name);
if(!fid.is_open()) {
std::cerr << "error : unable to open file " << input_name
<< " : run the validation generation script first\n";
......
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