From 9dc5165a58706d6e719404ebfb635f8800dcf86c Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Wed, 5 Aug 2015 15:31:25 -0700 Subject: [PATCH] Fix compilation with GCC 4.9 --- results.cpp | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/results.cpp b/results.cpp index 367a3c46..3b3654d8 100644 --- a/results.cpp +++ b/results.cpp @@ -22,6 +22,18 @@ using namespace realm; +#ifdef __has_cpp_attribute +#define REALM_HAS_CCP_ATTRIBUTE(attr) __has_cpp_attribute(attr) +#else +#define REALM_HAS_CCP_ATTRIBUTE(attr) 0 +#endif + +#if REALM_HAS_CCP_ATTRIBUTE(clang::fallthrough) +#define REALM_FALLTHROUGH [[clang::fallthrough]] +#else +#define REALM_FALLTHROUGH +#endif + Results::Results(SharedRealm r, Query q, SortOrder s) : m_realm(std::move(r)) , m_query(std::move(q)) @@ -64,6 +76,7 @@ size_t Results::size() update_tableview(); return m_table_view.size(); } + REALM_UNREACHABLE(); } RowExpr Results::get(size_t row_ndx) @@ -96,10 +109,11 @@ util::Optional Results::first() return m_table->size() == 0 ? util::none : util::Optional(m_table->front()); case Mode::Query: update_tableview(); - [[clang::fallthrough]]; + REALM_FALLTHROUGH; case Mode::TableView: return m_table_view.size() == 0 ? util::none : util::Optional(m_table_view.front()); } + REALM_UNREACHABLE(); } util::Optional Results::last() @@ -112,10 +126,11 @@ util::Optional Results::last() return m_table->size() == 0 ? util::none : util::Optional(m_table->back()); case Mode::Query: update_tableview(); - [[clang::fallthrough]]; + REALM_FALLTHROUGH; case Mode::TableView: return m_table_view.size() == 0 ? util::none : util::Optional(m_table_view.back()); } + REALM_UNREACHABLE(); } void Results::update_tableview() @@ -161,12 +176,12 @@ size_t Results::index_of(size_t row_ndx) case Mode::Query: if (!m_sort) return m_query.count(row_ndx, row_ndx + 1) ? m_query.count(0, row_ndx) : not_found; - [[clang::fallthrough]]; + REALM_FALLTHROUGH; case Mode::TableView: update_tableview(); return m_table_view.find_by_source_ndx(row_ndx); } - + REALM_UNREACHABLE(); } template @@ -190,11 +205,12 @@ util::Optional Results::aggregate(size_t column, bool return_none_for_emp return util::Optional(getter(*m_table)); case Mode::Query: case Mode::TableView: - update_tableview(); + this->update_tableview(); if (return_none_for_empty && m_table_view.size() == 0) return none; return util::Optional(getter(m_table_view)); } + REALM_UNREACHABLE(); }; switch (m_table->get_column_type(column)) @@ -275,6 +291,7 @@ Query Results::get_query() const case Mode::Table: return m_table->where(); } + REALM_UNREACHABLE(); } TableView Results::get_tableview()