cxx: Fix some warnings from -Wextra

Summary:
- As we don't have C++17's [[fallthrough]], rely on GCC'd detection
  of fallthrough comments.

  See https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7/

- Replaced some copy constructors with typecast operators.

  Previously, a constructor with remove_const/remove_cv were used
  to allow const iterators to be constructed from non-const iterators.
  This had the side effect of making these constructors actual copy
  constructors for non const lists. As we did not define other
  special constructors/operators, the rule of 5 were violated for these
  cases.

  This commit replaces these constructors with actual typecast operators
  that promote non const iterators to their const counterparts.

- Cast a Eina_Bool/bool narrowing conversion

- Add a missing break statement from D10050

Reviewers: zmike, brunobelo, felipealmeida

Reviewed By: brunobelo

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D9934
This commit is contained in:
Lauro Moura 2019-09-23 13:33:52 -03:00
parent 883ef612b7
commit 03da60997e
5 changed files with 12 additions and 9 deletions

View File

@ -101,11 +101,12 @@ struct _inlist_iterator
: _list(list), _node(node) {}
/**
* @brief Copy constructor. Creates a copy of the given iterator.
* @brief Create a const iterator from this one.
* @param other Other iterator.
*/
_inlist_iterator(_inlist_iterator<typename std::remove_const<T>::type> const& other)
: _list(other._list), _node(other._node) {}
operator _inlist_iterator<T const>() {
return _inlist_iterator<T const>{_list, _node};
}
/**
* @brief Move the iterator to the next position in the list.

View File

@ -46,9 +46,9 @@ struct _ptr_array_iterator
{
}
_ptr_array_iterator(_ptr_array_iterator<typename remove_cv<value_type>::type> const& other)
: _ptr(other._ptr)
operator _ptr_array_iterator<T const>()
{
return _ptr_array_iterator<T const>{_ptr};
}
_ptr_array_iterator<T>& operator++()
{

View File

@ -62,9 +62,9 @@ struct _ptr_list_iterator : _ptr_list_iterator_base
: _ptr_list_iterator_base(list, node)
{
}
_ptr_list_iterator(_ptr_list_iterator<value_type> const& other)
: _ptr_list_iterator_base(static_cast<_ptr_list_iterator_base const&>(other))
operator _ptr_list_iterator<T const>()
{
return _ptr_list_iterator<T const>{_list, _node};
}
_ptr_list_iterator<T>& operator++()

View File

@ -26,7 +26,8 @@ struct html_escaped_string_generator
case '\'': out.append("&apos;"); break;
case '<': out.append("&lt;"); break;
case '>': out.append("&gt;"); break;
case '\\': if (pos < input.size() - 1) pos++; // Deliberate fallthrough
case '\\': if (pos < input.size() - 1) pos++;
// fall through
default: out.append(&input[pos], 1); break;
}
}

View File

@ -495,7 +495,7 @@ inline void type_def::set(Eolian_Type const* eolian_type, Eolian_Unit const* uni
complex.subtypes.push_back({stp
, unit
, ::eolian_type_c_type_get(stp)
, eolian_type_is_move(stp)
, static_cast<bool>(eolian_type_is_move(stp))
, is_by::value});
stp = eolian_type_next_type_get(stp);
}
@ -532,6 +532,7 @@ inline void type_def::set(Eolian_Expression_Type eolian_exp_type)
break;
case EOLIAN_EXPR_STRING:
set("string", "const char *");
break;
case EOLIAN_EXPR_BOOL:
set("bool", "Eina_Bool");
break;