Skip to content

Commit

Permalink
Fix compilation warnings/errors that only appear with Clang or when i…
Browse files Browse the repository at this point in the history
…n release mode.
  • Loading branch information
poletti-marco committed Nov 9, 2014
1 parent f928a00 commit b6e6c09
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 28 deletions.
4 changes: 3 additions & 1 deletion include/fruit/impl/data_structures/semistatic_graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ class SemistaticGraph {

InternalNodeId getOrAllocateInternalNodeId(NodeId nodeId);

// TODO: Remove.

#ifdef FRUIT_EXTRA_DEBUG
void printEdgesBegin(std::ostream& os, std::uintptr_t edgesBegin);
#endif

public:

Expand Down
4 changes: 0 additions & 4 deletions include/fruit/impl/metaprogramming/metaprogramming.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ namespace impl {
template <int...>
struct IntList {};

#ifdef FRUIT_EXTRA_DEBUG

template <typename T>
struct DebugTypeHelper {
static_assert(sizeof(T*)*0 != 0, "");
Expand All @@ -40,8 +38,6 @@ struct DebugTypeHelper {
template <typename T>
using DebugType = typename DebugTypeHelper<T>::type;

#endif

struct IsConstructibleWithList {
template <typename C, typename L>
struct apply;
Expand Down
27 changes: 15 additions & 12 deletions tests/data_structures/semistatic_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ struct SimpleNode {


void test_empty() {
vector<SimpleNode> values = {};
vector<SimpleNode> values{};
Graph graph(values.begin(), values.end());
assert(graph.find(0) == graph.end());
assert(graph.find(2) == graph.end());
assert(graph.find(5) == graph.end());
}

void test_1_node_no_edges() {
vector<SimpleNode> values = {{2, "foo", {}, false}};
vector<SimpleNode> values{{2, "foo", vector<size_t>{}, false}};
Graph graph(values.begin(), values.end());
assert(graph.find(0) == graph.end());
assert(!(graph.find(2) == graph.end()));
Expand All @@ -62,7 +62,7 @@ void test_1_node_no_edges() {
}

void test_1_node_no_edges_terminal() {
vector<SimpleNode> values = {{2, "foo", {}, true}};
vector<SimpleNode> values{{2, "foo", vector<size_t>{}, true}};
Graph graph(values.begin(), values.end());
assert(graph.find(0) == graph.end());
assert(!(graph.find(2) == graph.end()));
Expand All @@ -72,20 +72,21 @@ void test_1_node_no_edges_terminal() {
}

void test_1_node_self_edge() {
vector<SimpleNode> values = {{2, "foo", {2}, false}};
vector<SimpleNode> values{{2, "foo", {2}, false}};
Graph graph(values.begin(), values.end());
assert(graph.find(0) == graph.end());
assert(!(graph.find(2) == graph.end()));
assert(graph.at(2).getNode() == "foo");
assert(graph.at(2).isTerminal() == false);
edge_iterator itr = graph.at(2).neighborsBegin();
(void)itr;
assert(itr.getNodeIterator(graph).getNode() == "foo");
assert(itr.getNodeIterator(graph).isTerminal() == false);
assert(graph.find(5) == graph.end());
}

void test_2_nodes_one_edge() {
vector<SimpleNode> values = {{2, "foo", {}, false}, {3, "bar", {2}, false}};
vector<SimpleNode> values{{2, "foo", vector<size_t>{}, false}, {3, "bar", {2}, false}};
Graph graph(values.begin(), values.end());
assert(graph.find(0) == graph.end());
assert(!(graph.find(2) == graph.end()));
Expand All @@ -94,13 +95,14 @@ void test_2_nodes_one_edge() {
assert(graph.at(3).getNode() == "bar");
assert(graph.at(3).isTerminal() == false);
edge_iterator itr = graph.at(3).neighborsBegin();
(void)itr;
assert(itr.getNodeIterator(graph).getNode() == "foo");
assert(itr.getNodeIterator(graph).isTerminal() == false);
assert(graph.find(5) == graph.end());
}

void test_3_nodes_two_edges() {
vector<SimpleNode> values = {{2, "foo", {}, false}, {3, "bar", {2, 4}, false}, {4, "baz", {}, true}};
vector<SimpleNode> values{{2, "foo", vector<size_t>{}, false}, {3, "bar", {2, 4}, false}, {4, "baz", vector<size_t>{}, true}};
Graph graph(values.begin(), values.end());
assert(graph.find(0) == graph.end());
assert(!(graph.find(2) == graph.end()));
Expand All @@ -120,10 +122,9 @@ void test_3_nodes_two_edges() {
}

void test_add_node() {
vector<SimpleNode> old_values = {{2, "foo", {}, false}, {4, "baz", {}, true}};
vector<SimpleNode> old_values{{2, "foo", vector<size_t>{}, false}, {4, "baz", vector<size_t>{}, true}};
Graph old_graph(old_values.begin(), old_values.end());
vector<size_t> edges = {2, 4};
vector<SimpleNode> new_values = {{3, "bar", {2, 4}, false}};
vector<SimpleNode> new_values{{3, "bar", {2, 4}, false}};
Graph graph(old_graph, new_values.begin(), new_values.end());
assert(graph.find(0) == graph.end());
assert(!(graph.find(2) == graph.end()));
Expand All @@ -143,7 +144,7 @@ void test_add_node() {
}

void test_set_terminal() {
vector<SimpleNode> values = {{2, "foo", {}, false}, {3, "bar", {2, 4}, false}, {4, "baz", {}, true}};
vector<SimpleNode> values{{2, "foo", vector<size_t>{}, false}, {3, "bar", {2, 4}, false}, {4, "baz", vector<size_t>{}, true}};
Graph graph(values.begin(), values.end());
graph.changeNodeToTerminal(3);
assert(graph.find(0) == graph.end());
Expand All @@ -158,7 +159,7 @@ void test_set_terminal() {
}

void test_move_constructor() {
vector<SimpleNode> values = {{2, "foo", {}, false}, {3, "bar", {2}, false}};
vector<SimpleNode> values{{2, "foo", vector<size_t>{}, false}, {3, "bar", {2}, false}};
Graph graph1(values.begin(), values.end());
Graph graph = std::move(graph1);
assert(graph.find(0) == graph.end());
Expand All @@ -168,13 +169,14 @@ void test_move_constructor() {
assert(graph.at(3).getNode() == "bar");
assert(graph.at(3).isTerminal() == false);
edge_iterator itr = graph.at(3).neighborsBegin();
(void)itr;
assert(itr.getNodeIterator(graph).getNode() == "foo");
assert(itr.getNodeIterator(graph).isTerminal() == false);
assert(graph.find(5) == graph.end());
}

void test_move_assignment() {
vector<SimpleNode> values = {{2, "foo", {}, false}, {3, "bar", {2}, false}};
vector<SimpleNode> values{{2, "foo", vector<size_t>{}, false}, {3, "bar", {2}, false}};
Graph graph1(values.begin(), values.end());
Graph graph;
graph = std::move(graph1);
Expand All @@ -185,6 +187,7 @@ void test_move_assignment() {
assert(graph.at(3).getNode() == "bar");
assert(graph.at(3).isTerminal() == false);
edge_iterator itr = graph.at(3).neighborsBegin();
(void)itr;
assert(itr.getNodeIterator(graph).getNode() == "foo");
assert(itr.getNodeIterator(graph).isTerminal() == false);
assert(graph.find(5) == graph.end());
Expand Down
22 changes: 11 additions & 11 deletions tests/data_structures/semistatic_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ using namespace std;
using namespace fruit::impl;

void test_empty() {
vector<pair<int, std::string>> values = {};
vector<pair<int, std::string>> values{};
SemistaticMap<int, std::string> map(values.begin(), values.size());
assert(map.find(0) == nullptr);
assert(map.find(2) == nullptr);
assert(map.find(5) == nullptr);
}

void test_1_elem() {
vector<pair<int, std::string>> values = {{2, "foo"}};
vector<pair<int, std::string>> values{{2, "foo"}};
SemistaticMap<int, std::string> map(values.begin(), values.size());
assert(map.find(0) == nullptr);
assert(map.find(2) != nullptr);
Expand All @@ -43,9 +43,9 @@ void test_1_elem() {
}

void test_1_inserted_elem() {
vector<pair<int, std::string>> values = {};
vector<pair<int, std::string>> values{};
SemistaticMap<int, std::string> old_map(values.begin(), values.size());
vector<pair<int, std::string>> new_values = {{2, "bar"}};
vector<pair<int, std::string>> new_values{{2, "bar"}};
SemistaticMap<int, std::string> map(old_map, std::move(new_values));
assert(map.find(0) == nullptr);
assert(map.find(2) != nullptr);
Expand All @@ -54,7 +54,7 @@ void test_1_inserted_elem() {
}

void test_3_elem() {
vector<pair<int, std::string>> values = {{1, "foo"}, {3, "bar"}, {4, "baz"}};
vector<pair<int, std::string>> values{{1, "foo"}, {3, "bar"}, {4, "baz"}};
SemistaticMap<int, std::string> map(values.begin(), values.size());
assert(map.find(0) == nullptr);
assert(map.find(1) != nullptr);
Expand All @@ -68,9 +68,9 @@ void test_3_elem() {
}

void test_1_elem_2_inserted() {
vector<pair<int, std::string>> values = {{1, "foo"}};
vector<pair<int, std::string>> values{{1, "foo"}};
SemistaticMap<int, std::string> old_map(values.begin(), values.size());
vector<pair<int, std::string>> new_values = {{3, "bar"}, {4, "baz"}};
vector<pair<int, std::string>> new_values{{3, "bar"}, {4, "baz"}};
SemistaticMap<int, std::string> map(old_map, std::move(new_values));
assert(map.find(0) == nullptr);
assert(map.find(1) != nullptr);
Expand All @@ -84,9 +84,9 @@ void test_1_elem_2_inserted() {
}

void test_3_elem_3_inserted() {
vector<pair<int, std::string>> values = {{1, "1"}, {3, "3"}, {5, "5"}};
vector<pair<int, std::string>> values{{1, "1"}, {3, "3"}, {5, "5"}};
SemistaticMap<int, std::string> old_map(values.begin(), values.size());
vector<pair<int, std::string>> new_values = {{2, "2"}, {4, "4"}, {16, "16"}};
vector<pair<int, std::string>> new_values{{2, "2"}, {4, "4"}, {16, "16"}};
SemistaticMap<int, std::string> map(old_map, std::move(new_values));
assert(map.find(0) == nullptr);
assert(map.find(1) != nullptr);
Expand All @@ -105,7 +105,7 @@ void test_3_elem_3_inserted() {
}

void test_move_constructor() {
vector<pair<int, std::string>> values = {{1, "foo"}, {3, "bar"}, {4, "baz"}};
vector<pair<int, std::string>> values{{1, "foo"}, {3, "bar"}, {4, "baz"}};
SemistaticMap<int, std::string> map1(values.begin(), values.size());
SemistaticMap<int, std::string> map = std::move(map1);
assert(map.find(0) == nullptr);
Expand All @@ -120,7 +120,7 @@ void test_move_constructor() {
}

void test_move_assignment() {
vector<pair<int, std::string>> values = {{1, "foo"}, {3, "bar"}, {4, "baz"}};
vector<pair<int, std::string>> values{{1, "foo"}, {3, "bar"}, {4, "baz"}};
SemistaticMap<int, std::string> map1(values.begin(), values.size());
SemistaticMap<int, std::string> map;
map = std::move(map1);
Expand Down

0 comments on commit b6e6c09

Please sign in to comment.