summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousa@expertisesolutions.com.br>2019-07-12 09:07:27 -0400
committerMike Blumenkrantz <zmike@samsung.com>2019-07-12 09:07:27 -0400
commitb1e44484a5702c840d8ab8db1b09121c1d43b126 (patch)
treeb96209f4af51649953b2b1eb3824af0dba0e136a /src/lib
parentc001a8146bcc366780cd50fa51e8f91cfd2b1d5c (diff)
cxx: remove compilation warnings in C++ code, from both gcc and clang
Summary: Remove almost all the compilation warnings from C++ code. Only explicit warnings using the `#warning` preprocessor directive remain. Some warnings had to be suppressed with `#pragma` directives because the behavior they were warning about is intended in some specific places. Code comments were added in such situations. Added a generator that creates `#pragma` directives in order to suppress warnings in all generated C++ headers. Currently `-Wignored-qualifiers` is the only warning category being suppressed. The innocuous const qualifiers that it points are inoffensive and have no effect in compilation at all. They are also hard to track in generation since they can emerge from different types in many places. To ease the generation of the warning suppressors an utility constructor was added to `efl::eolian::grammar::attributes::unused_type`. Add constructors to `eolian_mono::class_context` to default initialize its internal string and avoid field initialization warnings. Test Plan: `meson test` Reviewers: lauromoura, felipealmeida, zmike, segfaultxavi Reviewed By: zmike Subscribers: cedric, #reviewers, #committers Tags: #efl_language_bindings Differential Revision: https://phab.enlightenment.org/D9275
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/eolian_cxx/grammar/attributes.hpp5
-rw-r--r--src/lib/eolian_cxx/grammar/class_implementation.hpp7
-rw-r--r--src/lib/eolian_cxx/grammar/generator.hpp2
-rw-r--r--src/lib/eolian_cxx/grammar/header.hpp3
-rw-r--r--src/lib/eolian_cxx/grammar/ignore_warning.hpp48
-rw-r--r--src/lib/eolian_cxx/grammar/type_impl.hpp2
-rw-r--r--src/lib/ephysics/ephysics_quaternion.cpp1
7 files changed, 64 insertions, 4 deletions
diff --git a/src/lib/eolian_cxx/grammar/attributes.hpp b/src/lib/eolian_cxx/grammar/attributes.hpp
index d33fcf2..b3efcce 100644
--- a/src/lib/eolian_cxx/grammar/attributes.hpp
+++ b/src/lib/eolian_cxx/grammar/attributes.hpp
@@ -9,7 +9,10 @@ namespace efl { namespace eolian { namespace grammar {
9 9
10namespace attributes { 10namespace attributes {
11 11
12struct unused_type {}; 12struct unused_type {
13 unused_type() = default;
14 unused_type(std::nullptr_t) {}
15};
13unused_type const unused = {}; 16unused_type const unused = {};
14 17
15template <int N, typename Tuple, typename Enable = void> 18template <int N, typename Tuple, typename Enable = void>
diff --git a/src/lib/eolian_cxx/grammar/class_implementation.hpp b/src/lib/eolian_cxx/grammar/class_implementation.hpp
index 615ee60..7428335 100644
--- a/src/lib/eolian_cxx/grammar/class_implementation.hpp
+++ b/src/lib/eolian_cxx/grammar/class_implementation.hpp
@@ -15,6 +15,7 @@
15#include "grammar/type_impl.hpp" 15#include "grammar/type_impl.hpp"
16#include "grammar/attribute_reorder.hpp" 16#include "grammar/attribute_reorder.hpp"
17#include "grammar/part_implementation.hpp" 17#include "grammar/part_implementation.hpp"
18#include "grammar/ignore_warning.hpp"
18 19
19namespace efl { namespace eolian { namespace grammar { 20namespace efl { namespace eolian { namespace grammar {
20 21
@@ -42,6 +43,9 @@ struct class_implementation_generator
42 .generate(sink, std::make_tuple(cls.namespaces, cls.cxx_name), add_lower_case_context(ctx))) 43 .generate(sink, std::make_tuple(cls.namespaces, cls.cxx_name), add_lower_case_context(ctx)))
43 return false; 44 return false;
44 45
46 if(!as_generator(ignore_warning_begin).generate(sink, nullptr, ctx))
47 return false;
48
45#ifndef USE_EOCXX_INHERIT_ONLY 49#ifndef USE_EOCXX_INHERIT_ONLY
46 if(!as_generator( 50 if(!as_generator(
47 (namespaces 51 (namespaces
@@ -71,6 +75,9 @@ struct class_implementation_generator
71 )).generate(sink, std::make_tuple(cls.namespaces, cls.functions, cpp_namespaces, cls.cxx_name, cls.parts), ctx)) 75 )).generate(sink, std::make_tuple(cls.namespaces, cls.functions, cpp_namespaces, cls.cxx_name, cls.parts), ctx))
72 return false; 76 return false;
73 77
78 if(!as_generator(ignore_warning_end).generate(sink, nullptr, ctx))
79 return false;
80
74 if(!as_generator("#endif\n").generate(sink, std::make_tuple(), ctx)) 81 if(!as_generator("#endif\n").generate(sink, std::make_tuple(), ctx))
75 return false; 82 return false;
76 83
diff --git a/src/lib/eolian_cxx/grammar/generator.hpp b/src/lib/eolian_cxx/grammar/generator.hpp
index 6d0be7e..25fff51 100644
--- a/src/lib/eolian_cxx/grammar/generator.hpp
+++ b/src/lib/eolian_cxx/grammar/generator.hpp
@@ -46,7 +46,7 @@ struct is_eager_generator<T volatile const&> : is_eager_generator<T> {};
46// struct is_generator<T> : is_eager_generator<T> {}; 46// struct is_generator<T> : is_eager_generator<T> {};
47 47
48template <typename G, typename Enable = typename std::enable_if<is_eager_generator<G>::value>::type> 48template <typename G, typename Enable = typename std::enable_if<is_eager_generator<G>::value>::type>
49G as_generator(G&& g) { return g; } 49G as_generator(G g) { return g; }
50 50
51 51
52} } } 52} } }
diff --git a/src/lib/eolian_cxx/grammar/header.hpp b/src/lib/eolian_cxx/grammar/header.hpp
index 2943540..f749584 100644
--- a/src/lib/eolian_cxx/grammar/header.hpp
+++ b/src/lib/eolian_cxx/grammar/header.hpp
@@ -11,6 +11,7 @@
11#include "class_definition.hpp" 11#include "class_definition.hpp"
12#include "class_declaration.hpp" 12#include "class_declaration.hpp"
13#include "implementation_include_directive.hpp" 13#include "implementation_include_directive.hpp"
14#include "ignore_warning.hpp"
14 15
15namespace efl { namespace eolian { namespace grammar { 16namespace efl { namespace eolian { namespace grammar {
16 17
@@ -27,11 +28,13 @@ auto class_header =
27 << *class_declaration // sequence<class> | class 28 << *class_declaration // sequence<class> | class
28 << *class_forward_declaration // sequence<class> | class 29 << *class_forward_declaration // sequence<class> | class
29 << string // extra header <string> 30 << string // extra header <string>
31 << ignore_warning_begin
30 << "\nnamespace eo_cxx {\n" 32 << "\nnamespace eo_cxx {\n"
31 << *base_class_definition // sequence<class> | class 33 << *base_class_definition // sequence<class> | class
32 << "}\n" 34 << "}\n"
33 << *class_definition // sequence<class> | class 35 << *class_definition // sequence<class> | class
34 // << *implementation_include_directive 36 // << *implementation_include_directive
37 << ignore_warning_end
35 ] 38 ]
36 ; 39 ;
37 40
diff --git a/src/lib/eolian_cxx/grammar/ignore_warning.hpp b/src/lib/eolian_cxx/grammar/ignore_warning.hpp
new file mode 100644
index 0000000..d3d2a6e
--- /dev/null
+++ b/src/lib/eolian_cxx/grammar/ignore_warning.hpp
@@ -0,0 +1,48 @@
1#ifndef EOLIAN_CXX_IGNORE_WARNING_HH
2#define EOLIAN_CXX_IGNORE_WARNING_HH
3
4#include "grammar/generator.hpp"
5
6namespace efl { namespace eolian { namespace grammar {
7
8struct ignore_warning_begin_generator
9{
10 template <typename OutputIterator, typename Context>
11 bool generate(OutputIterator sink, attributes::unused_type, Context const& context) const
12 {
13 return as_generator(
14 "\n"
15 "#pragma GCC diagnostic push\n"
16 "#pragma GCC diagnostic ignored \"-Wignored-qualifiers\"\n"
17 "\n"
18 ).generate(sink, nullptr, context);
19 }
20};
21
22struct ignore_warning_end_generator
23{
24 template <typename OutputIterator, typename Context>
25 bool generate(OutputIterator sink, attributes::unused_type, Context const& context) const
26 {
27 return as_generator(
28 "\n#pragma GCC diagnostic pop\n\n"
29 ).generate(sink, nullptr, context);
30 }
31};
32
33template <>
34struct is_eager_generator<ignore_warning_begin_generator> : std::true_type {};
35template <>
36struct is_generator<ignore_warning_begin_generator> : std::true_type {};
37
38template <>
39struct is_eager_generator<ignore_warning_end_generator> : std::true_type {};
40template <>
41struct is_generator<ignore_warning_end_generator> : std::true_type {};
42
43ignore_warning_begin_generator constexpr ignore_warning_begin = {};
44ignore_warning_end_generator constexpr ignore_warning_end = {};
45
46} } }
47
48#endif
diff --git a/src/lib/eolian_cxx/grammar/type_impl.hpp b/src/lib/eolian_cxx/grammar/type_impl.hpp
index ca73a14..c5bd4d8 100644
--- a/src/lib/eolian_cxx/grammar/type_impl.hpp
+++ b/src/lib/eolian_cxx/grammar/type_impl.hpp
@@ -348,7 +348,7 @@ struct visitor_generate
348 // pointers.swap(no_pointer_regular.pointers); 348 // pointers.swap(no_pointer_regular.pointers);
349 // if(is_out) 349 // if(is_out)
350 // pointers.push_back({{attributes::qualifier_info::is_none, {}}, true}); 350 // pointers.push_back({{attributes::qualifier_info::is_none, {}}, true});
351 return visitor_type{sink, context, c_type, false}(no_pointer_regular) 351 return visitor_type{sink, context, c_type, false, false}(no_pointer_regular)
352 && as_generator("<" << (type % ", ") << ">").generate(sink, complex.subtypes, *context) 352 && as_generator("<" << (type % ", ") << ">").generate(sink, complex.subtypes, *context)
353 ; 353 ;
354 // && detail::generate_pointers(sink, pointers, *context, false); 354 // && detail::generate_pointers(sink, pointers, *context, false);
diff --git a/src/lib/ephysics/ephysics_quaternion.cpp b/src/lib/ephysics/ephysics_quaternion.cpp
index 899204d..bf1b915 100644
--- a/src/lib/ephysics/ephysics_quaternion.cpp
+++ b/src/lib/ephysics/ephysics_quaternion.cpp
@@ -126,7 +126,6 @@ ephysics_quaternion_euler_set(EPhysics_Quaternion *quat, double yaw, double pitc
126 return; 126 return;
127 } 127 }
128 128
129 bt_quat = btQuaternion();
130 bt_quat.setEuler(yaw / RAD_TO_DEG, pitch / RAD_TO_DEG, roll / RAD_TO_DEG); 129 bt_quat.setEuler(yaw / RAD_TO_DEG, pitch / RAD_TO_DEG, roll / RAD_TO_DEG);
131 _ephysics_quaternion_update(quat, &bt_quat); 130 _ephysics_quaternion_update(quat, &bt_quat);
132} 131}