lauromoura pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=03da60997e76d1604b4554e60866283591b98e0d

commit 03da60997e76d1604b4554e60866283591b98e0d
Author: Lauro Moura <lauromo...@expertisesolutions.com.br>
Date:   Mon Sep 23 13:33:52 2019 -0300

    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
---
 src/bindings/cxx/eina_cxx/eina_inlist.hh           | 7 ++++---
 src/bindings/cxx/eina_cxx/eina_ptrarray.hh         | 4 ++--
 src/bindings/cxx/eina_cxx/eina_ptrlist.hh          | 4 ++--
 src/lib/eolian_cxx/grammar/html_escaped_string.hpp | 3 ++-
 src/lib/eolian_cxx/grammar/klass_def.hpp           | 3 ++-
 5 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/bindings/cxx/eina_cxx/eina_inlist.hh 
b/src/bindings/cxx/eina_cxx/eina_inlist.hh
index 0092989cb7..8804034d11 100644
--- a/src/bindings/cxx/eina_cxx/eina_inlist.hh
+++ b/src/bindings/cxx/eina_cxx/eina_inlist.hh
@@ -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.
diff --git a/src/bindings/cxx/eina_cxx/eina_ptrarray.hh 
b/src/bindings/cxx/eina_cxx/eina_ptrarray.hh
index b5de9d7290..b2f6ef515b 100644
--- a/src/bindings/cxx/eina_cxx/eina_ptrarray.hh
+++ b/src/bindings/cxx/eina_cxx/eina_ptrarray.hh
@@ -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++()
   {
diff --git a/src/bindings/cxx/eina_cxx/eina_ptrlist.hh 
b/src/bindings/cxx/eina_cxx/eina_ptrlist.hh
index 03b836ab6f..988658b2fa 100644
--- a/src/bindings/cxx/eina_cxx/eina_ptrlist.hh
+++ b/src/bindings/cxx/eina_cxx/eina_ptrlist.hh
@@ -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++()
diff --git a/src/lib/eolian_cxx/grammar/html_escaped_string.hpp 
b/src/lib/eolian_cxx/grammar/html_escaped_string.hpp
index 371afcda24..5bbad79c0f 100644
--- a/src/lib/eolian_cxx/grammar/html_escaped_string.hpp
+++ b/src/lib/eolian_cxx/grammar/html_escaped_string.hpp
@@ -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;
             }
         }
diff --git a/src/lib/eolian_cxx/grammar/klass_def.hpp 
b/src/lib/eolian_cxx/grammar/klass_def.hpp
index b1f6c383a3..a7a01cc243 100644
--- a/src/lib/eolian_cxx/grammar/klass_def.hpp
+++ b/src/lib/eolian_cxx/grammar/klass_def.hpp
@@ -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;

-- 


Reply via email to