Merge lp:~widelands-dev/widelands/compiler_warnings_20170619 into lp:widelands
- compiler_warnings_20170619
- Merge into trunk
Status: | Merged | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Merged at revision: | 8383 | ||||||||||||
Proposed branch: | lp:~widelands-dev/widelands/compiler_warnings_20170619 | ||||||||||||
Merge into: | lp:widelands | ||||||||||||
Diff against target: |
813 lines (+146/-53) 34 files modified
CMakeLists.txt (+6/-0) src/base/macros.h (+15/-0) src/base/wexception.h (+5/-5) src/economy/economy.cc (+2/-0) src/economy/test/CMakeLists.txt (+1/-0) src/economy/test/test_road.cc (+3/-0) src/economy/test/test_routing.cc (+4/-0) src/economy/ware_instance.cc (+2/-0) src/editor/ui_menus/main_menu_random_map.cc (+0/-2) src/graphic/animation.cc (+1/-1) src/graphic/text/bidi.cc (+4/-0) src/io/filesystem/filesystem_exceptions.h (+10/-6) src/io/filesystem/test/CMakeLists.txt (+1/-0) src/io/filesystem/test/test_filesystem.cc (+4/-0) src/io/streamread.h (+2/-1) src/logic/map_objects/bob.cc (+8/-1) src/logic/map_objects/immovable.cc (+4/-0) src/logic/map_objects/tribes/building.cc (+4/-0) src/logic/map_objects/tribes/soldier.cc (+1/-2) src/logic/map_objects/tribes/worker.cc (+10/-0) src/network/gamehost.cc (+1/-2) src/network/netclient.cc (+5/-0) src/network/nethost.cc (+6/-0) src/notifications/test/CMakeLists.txt (+1/-0) src/notifications/test/notifications_test.cc (+4/-0) src/scripting/lua_errors.cc (+1/-0) src/scripting/lua_game.cc (+0/-2) src/scripting/lua_map.cc (+6/-6) src/scripting/test/CMakeLists.txt (+1/-0) src/scripting/test/test_luna.cc (+29/-19) src/ui_basic/progressbar.cc (+1/-1) src/ui_fsmenu/launch_spg.h (+1/-1) src/wui/game_message_menu.cc (+3/-2) src/wui/shipwindow.cc (+0/-2) |
||||||||||||
To merge this branch: | bzr merge lp:~widelands-dev/widelands/compiler_warnings_20170619 | ||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Klaus Halfmann | Needs Resubmitting | ||
GunChleoc | Pending | ||
Review via email: mp+325952@code.launchpad.net |
Commit message
Fixed diverse compiler warnings:
- Fixed floor/double warnings
- Removed assertion in Battle::opponent that would always evaluate to true
- Switched off "disabled-
- Switched off "format" warning around printf statements with %p
- Added a missing override
- Added a virtual dtor to lua_errors, to avoid inline virtual methods. Turned some exception structs into classes.
- Fix warnings with unused variables in netclient/host
- Made some functions in lua_map.cc inline to address -Wmissing-
- Added "-Wno-switch-enum" to compiler flags for clang
Description of the change
This is the alternative for compiler_
Lets check if this branch will make it to git and finally to travis.
Gun and I will update this description once travis is working again.
bunnybot (widelandsofficial) wrote : | # |
GunChleoc (gunchleoc) wrote : | # |
Thanks for setting this up.
I have copied over the information from the commit messages.
From the Travis logs, I noticed that GCC uses "-Wformat" and Clang uses "-Wformat-
GunChleoc (gunchleoc) wrote : | # |
I am still working on the format macros - older versions of Clang don't recognize the -pedantic version.
In the meantime, are you still getting any warnings except for the "-Wundefined-
Klaus Halfmann (klaus-halfmann) wrote : | # |
Comipling this again (after pulling from _this_ bracnh :-)
still get warning like:
compiler_
'
available [-Wundefined-
and similar warnings, in total 10
get this
compiler_
[
BOOST_AUTO_
compiler_
[
BOOST_FIXTURE_
for a total of 16 warnings generated.
otherwise this looks much bettter lines of compilere messages without any warning.
You even fixed those ugly switch/all cases/default: warnings, hey!.
GunChleoc (gunchleoc) wrote : | # |
This:
compiler_
'
available [-Wundefined-
Is what I meant in my post above - I don't know what's causing them, so somebody who has access to Clang needs to figure them out.
For the BOOST_AUTO_
Maybe you can refine that so that the warnings disappear? Travis doesn't show them, so I can't fix them. I'd rather limit them to suppressing warnings from third-party code only and keep the warnings active for our own code.
Over to you now :)
Klaus Halfmann (klaus-halfmann) wrote : | # |
The later warnings come from the testcode only (I think travis does not comile this).
Ill try to get rid of them like you did with the other ones.
The first one is a problem with template instantiation.
The compiler must instantiate them whenver he needs to, resulting
in some duplicate code to be removed by the linker, later.
This is e.g. discussed here:
https:/
This will need an explicit _declaration_ and _instantiation_,
but the code is to complex. So I have no idea how to do this.
(Give me a week alone with the compiler or such and I may still
have no idea ... :-) I hoped SirVer could tell us.
GunChleoc (gunchleoc) wrote : | # |
Yep, those map region templates are complex. Let's open a bug and leave them for another branch.
Travis does compile the test code, because its running the tests too. It does not generate the warnings though.
You can't rewrite those testing macros, because that's code written by Boost. All you can do is try to switch off the warnings. One of the 4 files has a #pragma directive in it to switch off another warning, maybe that strategy will work better than CLANG_DIAG_OFF?
Klaus Halfmann (klaus-halfmann) wrote : | # |
Supressed the warning locally,
created [1699852] for the MapTriangleReg.
So when bunnybot is happy this should go in.
GunChleoc (gunchleoc) wrote : | # |
Excellent :)
@bunnybot merge
Preview Diff
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2017-06-15 15:45:01 +0000 |
3 | +++ CMakeLists.txt 2017-06-22 16:50:44 +0000 |
4 | @@ -128,8 +128,14 @@ |
5 | wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wno-sign-conversion") |
6 | wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wno-missing-noreturn") |
7 | |
8 | + # It is impossible to write code that both GCC and Clang will like, |
9 | + # so we have to switch off the warning for one of them. |
10 | + # http://clang-developers.42468.n3.nabble.com/Question-on-Wswitch-enum-td4025927.html |
11 | + wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wno-switch-enum") |
12 | + |
13 | # TODO(sirver): weak-vtables should be enabled, but leads to lot of errors right now. |
14 | wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wno-weak-vtables") |
15 | + |
16 | wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wno-unreachable-code") |
17 | wl_add_flag(WL_COMPILE_DIAGNOSTICS "-Wno-documentation") |
18 | |
19 | |
20 | === modified file 'src/base/macros.h' |
21 | --- src/base/macros.h 2017-06-15 22:00:08 +0000 |
22 | +++ src/base/macros.h 2017-06-22 16:50:44 +0000 |
23 | @@ -77,6 +77,21 @@ |
24 | #define FALLS_THROUGH /* Falls through */ |
25 | #endif |
26 | |
27 | +// Compilers can't handle polymorphy with printf %p, expecting void* only. |
28 | +// Surround ONLY printf statements that contain %p with these macros. |
29 | +#ifdef __clang__ |
30 | +#if __has_warning("-Wformat-pedantic") // Older Clang versions don't have -Wformat-pedantic |
31 | +#define FORMAT_WARNINGS_OFF CLANG_DIAG_OFF("-Wformat") CLANG_DIAG_OFF("-Wformat-pedantic") |
32 | +#define FORMAT_WARNINGS_ON CLANG_DIAG_ON("-Wformat") CLANG_DIAG_ON("-Wformat-pedantic") |
33 | +#else |
34 | +#define FORMAT_WARNINGS_OFF CLANG_DIAG_OFF("-Wformat") |
35 | +#define FORMAT_WARNINGS_ON CLANG_DIAG_ON("-Wformat") |
36 | +#endif |
37 | +#else |
38 | +#define FORMAT_WARNINGS_OFF GCC_DIAG_OFF("-Wformat") |
39 | +#define FORMAT_WARNINGS_ON GCC_DIAG_ON("-Wformat") |
40 | +#endif |
41 | + |
42 | // disallow copying or assigning a class |
43 | #define DISALLOW_COPY_AND_ASSIGN(TypeName) \ |
44 | TypeName(const TypeName&) = delete; \ |
45 | |
46 | === modified file 'src/base/wexception.h' |
47 | --- src/base/wexception.h 2017-01-25 18:55:59 +0000 |
48 | +++ src/base/wexception.h 2017-06-22 16:50:44 +0000 |
49 | @@ -36,12 +36,12 @@ |
50 | #endif |
51 | #endif |
52 | |
53 | -/** class wexception |
54 | +/** Stupid, simple exception class. |
55 | * |
56 | - * Stupid, simple exception class. It has the nice bonus that you can give it |
57 | - * sprintf()-style format strings |
58 | + * It has the nice bonus that you can give it sprintf()-style format strings. |
59 | */ |
60 | -struct WException : public std::exception { |
61 | +class WException : public std::exception { |
62 | + public: |
63 | explicit WException(char const* const file, uint32_t const line, char const* const fmt, ...) |
64 | PRINTF_FORMAT(4, 5); |
65 | |
66 | @@ -51,7 +51,7 @@ |
67 | */ |
68 | const char* what() const noexcept override; |
69 | |
70 | -protected: |
71 | + protected: |
72 | WException() { |
73 | } |
74 | std::string what_; |
75 | |
76 | === modified file 'src/economy/economy.cc' |
77 | --- src/economy/economy.cc 2017-02-12 09:10:57 +0000 |
78 | +++ src/economy/economy.cc 2017-06-22 16:50:44 +0000 |
79 | @@ -431,7 +431,9 @@ |
80 | RequestList::iterator const it = std::find(requests_.begin(), requests_.end(), &req); |
81 | |
82 | if (it == requests_.end()) { |
83 | + FORMAT_WARNINGS_OFF; |
84 | log("WARNING: remove_request(%p) not in list\n", &req); |
85 | + FORMAT_WARNINGS_ON; |
86 | return; |
87 | } |
88 | |
89 | |
90 | === modified file 'src/economy/test/CMakeLists.txt' |
91 | --- src/economy/test/CMakeLists.txt 2014-11-28 16:40:55 +0000 |
92 | +++ src/economy/test/CMakeLists.txt 2017-06-22 16:50:44 +0000 |
93 | @@ -4,6 +4,7 @@ |
94 | test_road.cc |
95 | test_routing.cc |
96 | DEPENDS |
97 | + base_macros |
98 | economy |
99 | io_filesystem |
100 | logic |
101 | |
102 | === modified file 'src/economy/test/test_road.cc' |
103 | --- src/economy/test/test_road.cc 2017-01-25 18:55:59 +0000 |
104 | +++ src/economy/test/test_road.cc 2017-06-22 16:50:44 +0000 |
105 | @@ -28,6 +28,9 @@ |
106 | #include "logic/map_objects/map_object.h" |
107 | #include "logic/player.h" |
108 | |
109 | +// Triggered by BOOST_AUTO_TEST_CASE |
110 | +CLANG_DIAG_OFF("-Wdisabled-macro-expansion") |
111 | + |
112 | namespace Widelands { |
113 | class World; |
114 | } // namespace Widelands |
115 | |
116 | === modified file 'src/economy/test/test_routing.cc' |
117 | --- src/economy/test/test_routing.cc 2017-01-25 18:55:59 +0000 |
118 | +++ src/economy/test/test_routing.cc 2017-06-22 16:50:44 +0000 |
119 | @@ -22,6 +22,7 @@ |
120 | #include <boost/bind.hpp> |
121 | #include <boost/test/unit_test.hpp> |
122 | |
123 | +#include "base/macros.h" |
124 | #include "economy/flag.h" |
125 | #include "economy/iroute.h" |
126 | #include "economy/itransport_cost_calculator.h" |
127 | @@ -30,6 +31,9 @@ |
128 | #include "logic/map_objects/tribes/wareworker.h" |
129 | #include "logic/widelands_geometry.h" |
130 | |
131 | +// Triggered by BOOST_AUTO_TEST_CASE |
132 | +CLANG_DIAG_OFF("-Wdisabled-macro-expansion") |
133 | + |
134 | using namespace Widelands; |
135 | |
136 | /******************/ |
137 | |
138 | === modified file 'src/economy/ware_instance.cc' |
139 | --- src/economy/ware_instance.cc 2017-04-23 12:11:19 +0000 |
140 | +++ src/economy/ware_instance.cc 2017-06-22 16:50:44 +0000 |
141 | @@ -187,7 +187,9 @@ |
142 | |
143 | WareInstance::~WareInstance() { |
144 | if (supply_) { |
145 | + FORMAT_WARNINGS_OFF; |
146 | molog("Ware %u still has supply %p\n", descr_index_, supply_); |
147 | + FORMAT_WARNINGS_ON; |
148 | delete supply_; |
149 | } |
150 | } |
151 | |
152 | === modified file 'src/editor/ui_menus/main_menu_random_map.cc' |
153 | --- src/editor/ui_menus/main_menu_random_map.cc 2017-05-14 04:38:39 +0000 |
154 | +++ src/editor/ui_menus/main_menu_random_map.cc 2017-06-22 16:50:44 +0000 |
155 | @@ -551,8 +551,6 @@ |
156 | case UniqueRandomMapInfo::ResourceAmount::raHigh: |
157 | log("Resources: high\n"); |
158 | break; |
159 | - default: |
160 | - NEVER_HERE(); |
161 | } |
162 | log("Land: %0.2f Water: %0.2f Wasteland: %0.2f\n", map_info.landRatio, map_info.waterRatio, |
163 | map_info.wastelandRatio); |
164 | |
165 | === modified file 'src/graphic/animation.cc' |
166 | --- src/graphic/animation.cc 2017-05-31 21:27:07 +0000 |
167 | +++ src/graphic/animation.cc 2017-06-22 16:50:44 +0000 |
168 | @@ -152,7 +152,7 @@ |
169 | if (scale_ <= 0.0f) { |
170 | throw wexception("Animation scale needs to be > 0.0f, but it is %f. The first image of " |
171 | "this animation is %s", |
172 | - scale_, image_files_[0].c_str()); |
173 | + static_cast<double>(scale_), image_files_[0].c_str()); |
174 | } |
175 | } |
176 | |
177 | |
178 | === modified file 'src/graphic/text/bidi.cc' |
179 | --- src/graphic/text/bidi.cc 2017-02-18 14:03:02 +0000 |
180 | +++ src/graphic/text/bidi.cc 2017-06-22 16:50:44 +0000 |
181 | @@ -492,7 +492,9 @@ |
182 | |
183 | // True if the character is in one of the script's code blocks |
184 | bool is_script_character(UChar32 c, UI::FontSets::Selector script) { |
185 | + CLANG_DIAG_OFF("-Wdisabled-macro-expansion") |
186 | UBlockCode code = ublock_getCode(c); |
187 | + CLANG_DIAG_ON("-Wdisabled-macro-expansion") |
188 | if (kRTLCodeBlocks.count(script) == 1 && kRTLCodeBlocks.at(script).count(code) == 1) { |
189 | return true; |
190 | } |
191 | @@ -503,7 +505,9 @@ |
192 | } |
193 | |
194 | bool is_rtl_character(UChar32 c) { |
195 | + CLANG_DIAG_OFF("-Wdisabled-macro-expansion") |
196 | UBlockCode code = ublock_getCode(c); |
197 | + CLANG_DIAG_ON("-Wdisabled-macro-expansion") |
198 | for (UI::FontSets::Selector script : kRTLScripts) { |
199 | assert(kRTLCodeBlocks.count(script) == 1); |
200 | if ((kRTLCodeBlocks.at(script).count(code) == 1)) { |
201 | |
202 | === modified file 'src/io/filesystem/filesystem_exceptions.h' |
203 | --- src/io/filesystem/filesystem_exceptions.h 2017-01-25 18:55:59 +0000 |
204 | +++ src/io/filesystem/filesystem_exceptions.h 2017-06-22 16:50:44 +0000 |
205 | @@ -26,7 +26,8 @@ |
206 | /** |
207 | * Generic problem when dealing with a file or directory |
208 | */ |
209 | -struct FileError : public std::runtime_error { |
210 | +class FileError : public std::runtime_error { |
211 | + public: |
212 | explicit FileError(const std::string& thrower, |
213 | const std::string& filename, |
214 | const std::string& message = "problem with file/directory") |
215 | @@ -39,7 +40,8 @@ |
216 | * A file/directory could not be found. Either it really does not exist or there |
217 | * are problems with the path, e.g. loops or nonexistent path components |
218 | */ |
219 | -struct FileNotFoundError : public FileError { |
220 | +class FileNotFoundError : public FileError { |
221 | + public: |
222 | explicit FileNotFoundError(const std::string& thrower, |
223 | const std::string& filename, |
224 | const std::string& message = "could not find file or directory") |
225 | @@ -51,7 +53,8 @@ |
226 | /** |
227 | * The file/directory is of an unexpected type. Reasons can be given via message |
228 | */ |
229 | -struct FileTypeError : public FileError { |
230 | +class FileTypeError : public FileError { |
231 | + public: |
232 | explicit FileTypeError(const std::string& thrower, |
233 | const std::string& filename, |
234 | const std::string& message = "file or directory has wrong type") |
235 | @@ -63,7 +66,8 @@ |
236 | /** |
237 | * The operating system denied access to the file/directory in question |
238 | */ |
239 | -struct FileAccessDeniedError : public FileError { |
240 | +class FileAccessDeniedError : public FileError { |
241 | + public: |
242 | explicit FileAccessDeniedError(const std::string& thrower, |
243 | const std::string& filename, |
244 | const std::string& message = "access denied on file or directory") |
245 | @@ -75,8 +79,8 @@ |
246 | /** |
247 | * The directory cannot be created |
248 | */ |
249 | - |
250 | -struct DirectoryCannotCreateError : public FileError { |
251 | +class DirectoryCannotCreateError : public FileError { |
252 | + public: |
253 | explicit DirectoryCannotCreateError(const std::string& thrower, |
254 | const std::string& dirname, |
255 | const std::string& message = "cannot create directory") |
256 | |
257 | === modified file 'src/io/filesystem/test/CMakeLists.txt' |
258 | --- src/io/filesystem/test/CMakeLists.txt 2014-06-08 19:45:49 +0000 |
259 | +++ src/io/filesystem/test/CMakeLists.txt 2017-06-22 16:50:44 +0000 |
260 | @@ -3,5 +3,6 @@ |
261 | ./filesystem_test_main.cc |
262 | ./test_filesystem.cc |
263 | DEPENDS |
264 | + base_macros |
265 | io_filesystem |
266 | ) |
267 | |
268 | === modified file 'src/io/filesystem/test/test_filesystem.cc' |
269 | --- src/io/filesystem/test/test_filesystem.cc 2017-01-25 18:55:59 +0000 |
270 | +++ src/io/filesystem/test/test_filesystem.cc 2017-06-22 16:50:44 +0000 |
271 | @@ -24,6 +24,7 @@ |
272 | |
273 | #include <boost/test/unit_test.hpp> |
274 | |
275 | +#include "base/macros.h" |
276 | #include "io/filesystem/disk_filesystem.h" |
277 | |
278 | #ifdef _WIN32 |
279 | @@ -46,6 +47,9 @@ |
280 | #pragma GCC diagnostic ignored "-Wold-style-cast" |
281 | #endif |
282 | |
283 | +// Triggered by BOOST_AUTO_TEST_CASE |
284 | +CLANG_DIAG_OFF("-Wdisabled-macro-expansion") |
285 | + |
286 | BOOST_AUTO_TEST_SUITE(FileSystemTests) |
287 | #ifndef _WIN32 |
288 | #define TEST_CANONICALIZE_NAME(root, path, expected) \ |
289 | |
290 | === modified file 'src/io/streamread.h' |
291 | --- src/io/streamread.h 2017-01-25 18:55:59 +0000 |
292 | +++ src/io/streamread.h 2017-06-22 16:50:44 +0000 |
293 | @@ -75,7 +75,8 @@ |
294 | |
295 | /// Base of all exceptions that are caused by errors in the data that is |
296 | /// read. |
297 | - struct DataError : public WException { |
298 | + class DataError : public WException { |
299 | + public: |
300 | DataError(char const* const fmt, ...) PRINTF_FORMAT(2, 3); |
301 | }; |
302 | #define data_error(...) DataError(__VA_ARGS__) |
303 | |
304 | === modified file 'src/logic/map_objects/bob.cc' |
305 | --- src/logic/map_objects/bob.cc 2017-04-23 12:11:19 +0000 |
306 | +++ src/logic/map_objects/bob.cc 2017-06-22 16:50:44 +0000 |
307 | @@ -901,7 +901,9 @@ |
308 | |
309 | /// Give debug information. |
310 | void Bob::log_general_info(const EditorGameBase& egbase) { |
311 | + FORMAT_WARNINGS_OFF; |
312 | molog("Owner: %p\n", owner_); |
313 | + FORMAT_WARNINGS_ON; |
314 | molog("Postition: (%i, %i)\n", position_.x, position_.y); |
315 | molog("ActID: %i\n", actid_); |
316 | molog("ActScheduled: %s\n", actscheduled_ ? "true" : "false"); |
317 | @@ -926,7 +928,9 @@ |
318 | molog("* ivar2: %i\n", stack_[i].ivar2); |
319 | molog("* ivar3: %i\n", stack_[i].ivar3); |
320 | |
321 | + FORMAT_WARNINGS_OFF; |
322 | molog("* object pointer: %p\n", stack_[i].objvar1.get(egbase)); |
323 | + FORMAT_WARNINGS_ON; |
324 | molog("* svar1: %s\n", stack_[i].svar1.c_str()); |
325 | |
326 | molog("* coords: (%i, %i)\n", stack_[i].coords.x, stack_[i].coords.y); |
327 | @@ -934,7 +938,9 @@ |
328 | for (Direction dir = FIRST_DIRECTION; dir <= LAST_DIRECTION; ++dir) { |
329 | molog(" %d", stack_[i].diranims.get_animation(dir)); |
330 | } |
331 | + FORMAT_WARNINGS_OFF; |
332 | molog("\n* path: %p\n", stack_[i].path); |
333 | + FORMAT_WARNINGS_ON; |
334 | if (stack_[i].path) { |
335 | const Path& path = *stack_[i].path; |
336 | Path::StepVector::size_type nr_steps = path.get_nsteps(); |
337 | @@ -947,9 +953,10 @@ |
338 | molog("* (%i, %i)\n", coords.x, coords.y); |
339 | } |
340 | } |
341 | + FORMAT_WARNINGS_OFF; |
342 | molog("* route: %p\n", stack_[i].route); |
343 | - |
344 | molog("* program: %p\n", stack_[i].route); |
345 | + FORMAT_WARNINGS_ON; |
346 | } |
347 | } |
348 | |
349 | |
350 | === modified file 'src/logic/map_objects/immovable.cc' |
351 | --- src/logic/map_objects/immovable.cc 2017-06-15 22:00:08 +0000 |
352 | +++ src/logic/map_objects/immovable.cc 2017-06-22 16:50:44 +0000 |
353 | @@ -1329,10 +1329,14 @@ |
354 | void PlayerImmovable::log_general_info(const EditorGameBase& egbase) { |
355 | BaseImmovable::log_general_info(egbase); |
356 | |
357 | + FORMAT_WARNINGS_OFF; |
358 | molog("this: %p\n", this); |
359 | molog("owner_: %p\n", owner_); |
360 | + FORMAT_WARNINGS_ON; |
361 | molog("player_number: %i\n", owner_->player_number()); |
362 | + FORMAT_WARNINGS_OFF; |
363 | molog("economy_: %p\n", economy_); |
364 | + FORMAT_WARNINGS_ON; |
365 | } |
366 | |
367 | constexpr uint8_t kCurrentPacketVersionPlayerImmovable = 1; |
368 | |
369 | === modified file 'src/logic/map_objects/tribes/building.cc' |
370 | --- src/logic/map_objects/tribes/building.cc 2017-05-25 13:00:12 +0000 |
371 | +++ src/logic/map_objects/tribes/building.cc 2017-06-22 16:50:44 +0000 |
372 | @@ -672,7 +672,9 @@ |
373 | PlayerImmovable::log_general_info(egbase); |
374 | |
375 | molog("position: (%i, %i)\n", position_.x, position_.y); |
376 | + FORMAT_WARNINGS_OFF; |
377 | molog("flag: %p\n", flag_); |
378 | + FORMAT_WARNINGS_ON; |
379 | molog("* position: (%i, %i)\n", flag_->get_position().x, flag_->get_position().y); |
380 | |
381 | molog("anim: %s\n", descr().get_animation_name(anim_).c_str()); |
382 | @@ -681,7 +683,9 @@ |
383 | molog("leave_time: %i\n", leave_time_); |
384 | |
385 | molog("leave_queue.size(): %lu\n", static_cast<long unsigned int>(leave_queue_.size())); |
386 | + FORMAT_WARNINGS_OFF; |
387 | molog("leave_allow.get(): %p\n", leave_allow_.get(egbase)); |
388 | + FORMAT_WARNINGS_ON; |
389 | } |
390 | |
391 | void Building::add_worker(Worker& worker) { |
392 | |
393 | === modified file 'src/logic/map_objects/tribes/soldier.cc' |
394 | --- src/logic/map_objects/tribes/soldier.cc 2017-05-21 22:18:02 +0000 |
395 | +++ src/logic/map_objects/tribes/soldier.cc 2017-06-22 16:50:44 +0000 |
396 | @@ -332,9 +332,8 @@ |
397 | return evade_level_; |
398 | case TrainingAttribute::kTotal: |
399 | return health_level_ + attack_level_ + defense_level_ + evade_level_; |
400 | - default: |
401 | - return Worker::get_training_attribute(attr); |
402 | } |
403 | + return Worker::get_training_attribute(attr); |
404 | } |
405 | |
406 | uint32_t Soldier::get_max_health() const { |
407 | |
408 | === modified file 'src/logic/map_objects/tribes/worker.cc' |
409 | --- src/logic/map_objects/tribes/worker.cc 2017-05-03 07:24:06 +0000 |
410 | +++ src/logic/map_objects/tribes/worker.cc 2017-06-22 16:50:44 +0000 |
411 | @@ -977,24 +977,34 @@ |
412 | Bob::log_general_info(egbase); |
413 | |
414 | if (upcast(PlayerImmovable, loc, location_.get(egbase))) { |
415 | + FORMAT_WARNINGS_OFF; |
416 | molog("* Owner: (%p)\n", &loc->owner()); |
417 | + FORMAT_WARNINGS_ON; |
418 | molog("** Owner (plrnr): %i\n", loc->owner().player_number()); |
419 | + FORMAT_WARNINGS_OFF; |
420 | molog("* Economy: %p\n", loc->get_economy()); |
421 | + FORMAT_WARNINGS_ON; |
422 | } |
423 | |
424 | PlayerImmovable* imm = location_.get(egbase); |
425 | molog("location: %u\n", imm ? imm->serial() : 0); |
426 | + FORMAT_WARNINGS_OFF; |
427 | molog("Economy: %p\n", economy_); |
428 | molog("transfer: %p\n", transfer_); |
429 | + FORMAT_WARNINGS_ON; |
430 | |
431 | if (upcast(WareInstance, ware, carried_ware_.get(egbase))) { |
432 | molog("* carried_ware->get_ware() (id): %i\n", ware->descr_index()); |
433 | + FORMAT_WARNINGS_OFF; |
434 | molog("* carried_ware->get_economy() (): %p\n", ware->get_economy()); |
435 | + FORMAT_WARNINGS_ON; |
436 | } |
437 | |
438 | molog("current_exp: %i / %i\n", current_exp_, descr().get_needed_experience()); |
439 | |
440 | + FORMAT_WARNINGS_OFF; |
441 | molog("supply: %p\n", supply_); |
442 | + FORMAT_WARNINGS_ON; |
443 | } |
444 | |
445 | /** |
446 | |
447 | === modified file 'src/network/gamehost.cc' |
448 | --- src/network/gamehost.cc 2017-06-15 22:00:08 +0000 |
449 | +++ src/network/gamehost.cc 2017-06-22 16:50:44 +0000 |
450 | @@ -65,7 +65,7 @@ |
451 | |
452 | struct HostGameSettingsProvider : public GameSettingsProvider { |
453 | HostGameSettingsProvider(GameHost* const init_host) |
454 | - : host_(init_host), current_wincondition_(0) { |
455 | + : host_(init_host) { |
456 | } |
457 | ~HostGameSettingsProvider() { |
458 | } |
459 | @@ -275,7 +275,6 @@ |
460 | |
461 | private: |
462 | GameHost* host_; |
463 | - int16_t current_wincondition_; |
464 | std::vector<std::string> wincondition_scripts_; |
465 | }; |
466 | |
467 | |
468 | === modified file 'src/network/netclient.cc' |
469 | --- src/network/netclient.cc 2017-06-10 16:36:29 +0000 |
470 | +++ src/network/netclient.cc 2017-06-22 16:50:44 +0000 |
471 | @@ -68,8 +68,13 @@ |
472 | return; |
473 | |
474 | boost::system::error_code ec; |
475 | +#ifdef NDEBUG |
476 | + boost::asio::write(socket_, boost::asio::buffer(packet.get_data(), packet.get_size()), ec); |
477 | +#else |
478 | size_t written = |
479 | boost::asio::write(socket_, boost::asio::buffer(packet.get_data(), packet.get_size()), ec); |
480 | +#endif |
481 | + |
482 | // TODO(Notabilis): This one is an assertion of mine, I am not sure if it will hold |
483 | // If it doesn't, set the socket to blocking before writing |
484 | // If it does, remove this comment after build 20 |
485 | |
486 | === modified file 'src/network/nethost.cc' |
487 | --- src/network/nethost.cc 2017-06-10 16:36:29 +0000 |
488 | +++ src/network/nethost.cc 2017-06-22 16:50:44 +0000 |
489 | @@ -170,8 +170,14 @@ |
490 | void NetHost::send(const ConnectionId id, const SendPacket& packet) { |
491 | boost::system::error_code ec; |
492 | if (is_connected(id)) { |
493 | +#ifdef NDEBUG |
494 | + boost::asio::write( |
495 | + clients_.at(id).socket, boost::asio::buffer(packet.get_data(), packet.get_size()), ec); |
496 | +#else |
497 | size_t written = boost::asio::write( |
498 | clients_.at(id).socket, boost::asio::buffer(packet.get_data(), packet.get_size()), ec); |
499 | +#endif |
500 | + |
501 | // TODO(Notabilis): This one is an assertion of mine, I am not sure if it will hold |
502 | // If it doesn't, set the socket to blocking before writing |
503 | // If it does, remove this comment after build 20 |
504 | |
505 | === modified file 'src/notifications/test/CMakeLists.txt' |
506 | --- src/notifications/test/CMakeLists.txt 2014-07-12 22:34:26 +0000 |
507 | +++ src/notifications/test/CMakeLists.txt 2017-06-22 16:50:44 +0000 |
508 | @@ -2,5 +2,6 @@ |
509 | SRCS |
510 | notifications_test.cc |
511 | DEPENDS |
512 | + base_macros |
513 | notifications |
514 | ) |
515 | |
516 | === modified file 'src/notifications/test/notifications_test.cc' |
517 | --- src/notifications/test/notifications_test.cc 2017-01-25 18:55:59 +0000 |
518 | +++ src/notifications/test/notifications_test.cc 2017-06-22 16:50:44 +0000 |
519 | @@ -23,8 +23,12 @@ |
520 | #define BOOST_TEST_MODULE Notifications |
521 | #include <boost/test/unit_test.hpp> |
522 | |
523 | +#include "base/macros.h" |
524 | #include "notifications/notifications.h" |
525 | |
526 | +// Triggered by BOOST_AUTO_TEST_CASE |
527 | +CLANG_DIAG_OFF("-Wdisabled-macro-expansion") |
528 | + |
529 | struct SimpleNote { |
530 | CAN_BE_SENT_AS_NOTE(100) |
531 | |
532 | |
533 | === modified file 'src/scripting/lua_errors.cc' |
534 | --- src/scripting/lua_errors.cc 2017-01-25 18:55:59 +0000 |
535 | +++ src/scripting/lua_errors.cc 2017-06-22 16:50:44 +0000 |
536 | @@ -25,3 +25,4 @@ |
537 | LuaScriptNotExistingError::LuaScriptNotExistingError(const std::string& name) |
538 | : LuaError("The script '" + name + "' was not found!") { |
539 | } |
540 | + |
541 | |
542 | === modified file 'src/scripting/lua_game.cc' |
543 | --- src/scripting/lua_game.cc 2017-06-05 07:33:18 +0000 |
544 | +++ src/scripting/lua_game.cc 2017-06-22 16:50:44 +0000 |
545 | @@ -1237,8 +1237,6 @@ |
546 | case Message::Status::kArchived: |
547 | lua_pushstring(L, "archived"); |
548 | break; |
549 | - default: |
550 | - NEVER_HERE(); |
551 | } |
552 | return 1; |
553 | } |
554 | |
555 | === modified file 'src/scripting/lua_map.cc' |
556 | --- src/scripting/lua_map.cc 2017-04-05 14:19:14 +0000 |
557 | +++ src/scripting/lua_map.cc 2017-06-22 16:50:44 +0000 |
558 | @@ -4458,7 +4458,7 @@ |
559 | report_error(L, "<%s> is no valid warehouse policy!", str.c_str()); |
560 | } |
561 | |
562 | -bool do_set_ware_policy(Warehouse* wh, const DescriptionIndex idx, const Warehouse::StockPolicy p) { |
563 | +inline bool do_set_ware_policy(Warehouse* wh, const DescriptionIndex idx, const Warehouse::StockPolicy p) { |
564 | wh->set_ware_policy(idx, p); |
565 | return true; |
566 | } |
567 | @@ -4467,7 +4467,7 @@ |
568 | * Sets the given policy for the given ware in the given warehouse and return true. |
569 | * If the no ware with the given name exists for the tribe of the warehouse, return false. |
570 | */ |
571 | -bool do_set_ware_policy(Warehouse* wh, const std::string& name, const Warehouse::StockPolicy p) { |
572 | +inline bool do_set_ware_policy(Warehouse* wh, const std::string& name, const Warehouse::StockPolicy p) { |
573 | const TribeDescr& tribe = wh->owner().tribe(); |
574 | DescriptionIndex idx = tribe.ware_index(name); |
575 | if (!tribe.has_ware(idx)) { |
576 | @@ -4476,7 +4476,7 @@ |
577 | return do_set_ware_policy(wh, idx, p); |
578 | } |
579 | |
580 | -bool do_set_worker_policy(Warehouse* wh, |
581 | +inline bool do_set_worker_policy(Warehouse* wh, |
582 | const DescriptionIndex idx, |
583 | const Warehouse::StockPolicy p) { |
584 | const TribeDescr& tribe = wh->owner().tribe(); |
585 | @@ -4496,7 +4496,7 @@ |
586 | * policy. |
587 | * If no worker with the given name exists for the tribe of the warehouse, return false. |
588 | */ |
589 | -bool do_set_worker_policy(Warehouse* wh, const std::string& name, const Warehouse::StockPolicy p) { |
590 | +inline bool do_set_worker_policy(Warehouse* wh, const std::string& name, const Warehouse::StockPolicy p) { |
591 | const TribeDescr& tribe = wh->owner().tribe(); |
592 | DescriptionIndex idx = tribe.worker_index(name); |
593 | if (!tribe.has_worker(idx)) { |
594 | @@ -4566,11 +4566,11 @@ |
595 | |
596 | // Gets the warehouse policy by ware/worker-name or id |
597 | #define WH_GET_POLICY(type) \ |
598 | - void do_get_##type##_policy(lua_State* L, Warehouse* wh, const DescriptionIndex idx) { \ |
599 | + inline void do_get_##type##_policy(lua_State* L, Warehouse* wh, const DescriptionIndex idx) { \ |
600 | wh_policy_to_string(L, wh->get_##type##_policy(idx)); \ |
601 | } \ |
602 | \ |
603 | - bool do_get_##type##_policy(lua_State* L, Warehouse* wh, const std::string& name) { \ |
604 | + inline bool do_get_##type##_policy(lua_State* L, Warehouse* wh, const std::string& name) { \ |
605 | const TribeDescr& tribe = wh->owner().tribe(); \ |
606 | DescriptionIndex idx = tribe.type##_index(name); \ |
607 | if (!tribe.has_##type(idx)) { \ |
608 | |
609 | === modified file 'src/scripting/test/CMakeLists.txt' |
610 | --- src/scripting/test/CMakeLists.txt 2015-01-31 16:03:59 +0000 |
611 | +++ src/scripting/test/CMakeLists.txt 2017-06-22 16:50:44 +0000 |
612 | @@ -3,6 +3,7 @@ |
613 | scripting_test_main.cc |
614 | test_luna.cc |
615 | DEPENDS |
616 | + base_macros |
617 | scripting_base |
618 | scripting_luna |
619 | ) |
620 | |
621 | === modified file 'src/scripting/test/test_luna.cc' |
622 | --- src/scripting/test/test_luna.cc 2017-01-25 18:55:59 +0000 |
623 | +++ src/scripting/test/test_luna.cc 2017-06-22 16:50:44 +0000 |
624 | @@ -23,10 +23,14 @@ |
625 | |
626 | #include <boost/test/unit_test.hpp> |
627 | |
628 | +#include "base/macros.h" |
629 | #include "scripting/lua.h" |
630 | #include "scripting/luna.h" |
631 | #include "scripting/luna_impl.h" |
632 | |
633 | +// Triggered by BOOST_AUTO_TEST_CASE |
634 | +CLANG_DIAG_OFF("-Wdisabled-macro-expansion") |
635 | + |
636 | #ifndef BEGIN_LUNA_PROPERTIES |
637 | #define BEGIN_LUNA_PROPERTIES(klass) const PropertyType<klass> klass::Properties[] = { |
638 | |
639 | @@ -53,8 +57,7 @@ |
640 | } |
641 | LuaClass() : x(123), prop(246) { |
642 | } |
643 | - virtual ~LuaClass() { |
644 | - } |
645 | + virtual ~LuaClass(); |
646 | LuaClass(lua_State* /* L */) : x(124), prop(248) { |
647 | } |
648 | virtual int test(lua_State* L) { |
649 | @@ -78,6 +81,7 @@ |
650 | void __unpersist(lua_State* /* L */) override { |
651 | } |
652 | }; |
653 | +LuaClass::~LuaClass() { } |
654 | const char LuaClass::className[] = "Class"; |
655 | const MethodType<LuaClass> LuaClass::Methods[] = { |
656 | METHOD(LuaClass, test), {nullptr, nullptr}, |
657 | @@ -86,7 +90,7 @@ |
658 | PROP_RO(LuaClass, propr) |
659 | , PROP_RW(LuaClass, prop1), END_LUNA_PROPERTIES() |
660 | |
661 | - class LuaSubClass : public LuaClass { |
662 | +class LuaSubClass : public LuaClass { |
663 | int y; |
664 | |
665 | public: |
666 | @@ -95,10 +99,7 @@ |
667 | } |
668 | LuaSubClass(lua_State* L) : LuaClass(L), y(1240) { |
669 | } |
670 | - virtual int subtest(lua_State* L) { |
671 | - lua_pushuint32(L, y); |
672 | - return 1; |
673 | - } |
674 | + virtual int subtest(lua_State* L); |
675 | void __persist(lua_State* /* L */) override { |
676 | } |
677 | void __unpersist(lua_State* /* L */) override { |
678 | @@ -111,6 +112,11 @@ |
679 | BEGIN_LUNA_PROPERTIES(LuaSubClass) |
680 | END_LUNA_PROPERTIES() |
681 | |
682 | +int LuaSubClass::subtest(lua_State* L) { |
683 | + lua_pushuint32(L, y); |
684 | + return 1; |
685 | +} |
686 | + |
687 | class LuaVirtualClass : public LuaClass { |
688 | int z; |
689 | |
690 | @@ -120,10 +126,7 @@ |
691 | } |
692 | LuaVirtualClass(lua_State* L) : LuaClass(L), z(12400) { |
693 | } |
694 | - virtual int virtualtest(lua_State* L) { |
695 | - lua_pushuint32(L, z); |
696 | - return 1; |
697 | - } |
698 | + virtual int virtualtest(lua_State* L); |
699 | void __persist(lua_State* /* L */) override { |
700 | } |
701 | void __unpersist(lua_State* /* L */) override { |
702 | @@ -136,21 +139,26 @@ |
703 | BEGIN_LUNA_PROPERTIES(LuaVirtualClass) |
704 | END_LUNA_PROPERTIES() |
705 | |
706 | +int LuaVirtualClass::virtualtest(lua_State* L) { |
707 | + lua_pushuint32(L, z); |
708 | + return 1; |
709 | +} |
710 | + |
711 | class LuaSecond { |
712 | public: |
713 | int get_second(lua_State* L) { |
714 | lua_pushint32(L, 2001); |
715 | return 1; |
716 | } |
717 | - virtual ~LuaSecond() { |
718 | - } |
719 | - |
720 | + virtual ~LuaSecond(); |
721 | virtual int multitest(lua_State* L) { |
722 | lua_pushint32(L, 2002); |
723 | return 1; |
724 | } |
725 | }; |
726 | |
727 | +LuaSecond::~LuaSecond() { } |
728 | + |
729 | class LuaMultiClass : public LuaClass, public LuaSecond { |
730 | int z; |
731 | |
732 | @@ -160,10 +168,7 @@ |
733 | } |
734 | LuaMultiClass(lua_State* L) : LuaClass(L), z(12400) { |
735 | } |
736 | - virtual int virtualtest(lua_State* L) { |
737 | - lua_pushuint32(L, z); |
738 | - return 1; |
739 | - } |
740 | + virtual int virtualtest(lua_State* L); |
741 | void __persist(lua_State* /* L */) override { |
742 | } |
743 | void __unpersist(lua_State* /* L */) override { |
744 | @@ -177,7 +182,12 @@ |
745 | PROP_RO(LuaMultiClass, second) |
746 | , END_LUNA_PROPERTIES() |
747 | |
748 | - const static struct luaL_Reg wltest[] = {{nullptr, nullptr}}; |
749 | +int LuaMultiClass::virtualtest(lua_State* L) { |
750 | + lua_pushuint32(L, z); |
751 | + return 1; |
752 | +} |
753 | + |
754 | +const static struct luaL_Reg wltest[] = {{nullptr, nullptr}}; |
755 | const static struct luaL_Reg wl[] = {{nullptr, nullptr}}; |
756 | |
757 | static int test_check_int(lua_State* L) { |
758 | |
759 | === modified file 'src/ui_basic/progressbar.cc' |
760 | --- src/ui_basic/progressbar.cc 2017-05-25 12:30:40 +0000 |
761 | +++ src/ui_basic/progressbar.cc 2017-06-22 16:50:44 +0000 |
762 | @@ -86,7 +86,7 @@ |
763 | |
764 | // Print the state in percent without decimal points. |
765 | const std::string progress_text = (boost::format("<font color=%s>%u%%</font>") % |
766 | - UI_FONT_CLR_BRIGHT.hex_value() % floor(fraction * 100.f)) |
767 | + UI_FONT_CLR_BRIGHT.hex_value() % floorf(fraction * 100.f)) |
768 | .str(); |
769 | std::shared_ptr<const UI::RenderedText> rendered_text = |
770 | UI::g_fh1->render(as_uifont(progress_text)); |
771 | |
772 | === modified file 'src/ui_fsmenu/launch_spg.h' |
773 | --- src/ui_fsmenu/launch_spg.h 2017-02-10 14:12:36 +0000 |
774 | +++ src/ui_fsmenu/launch_spg.h 2017-06-22 16:50:44 +0000 |
775 | @@ -52,7 +52,7 @@ |
776 | FullscreenMenuLaunchSPG(GameSettingsProvider*, GameController* = nullptr); |
777 | ~FullscreenMenuLaunchSPG(); |
778 | |
779 | - void start(); |
780 | + void start() override; |
781 | void refresh() override; |
782 | |
783 | protected: |
784 | |
785 | === modified file 'src/wui/game_message_menu.cc' |
786 | --- src/wui/game_message_menu.cc 2017-05-03 07:24:06 +0000 |
787 | +++ src/wui/game_message_menu.cc 2017-06-22 16:50:44 +0000 |
788 | @@ -405,9 +405,10 @@ |
789 | return true; |
790 | case SDL_SCANCODE_KP_PERIOD: |
791 | case SDLK_KP_PERIOD: |
792 | - if (code.mod & KMOD_NUM) |
793 | + if (code.mod & KMOD_NUM) { |
794 | break; |
795 | - /* no break */ |
796 | + } |
797 | + FALLS_THROUGH; |
798 | default: |
799 | break; // not handled |
800 | } |
801 | |
802 | === modified file 'src/wui/shipwindow.cc' |
803 | --- src/wui/shipwindow.cc 2017-04-25 08:05:09 +0000 |
804 | +++ src/wui/shipwindow.cc 2017-06-22 16:50:44 +0000 |
805 | @@ -82,8 +82,6 @@ |
806 | set_thinks(false); |
807 | die(); |
808 | break; |
809 | - default: |
810 | - break; |
811 | } |
812 | } |
813 | }); |
Continuous integration builds have changed state:
Travis build 2325. State: passed. Details: https:/ /travis- ci.org/ widelands/ widelands/ builds/ 244653007. /ci.appveyor. com/project/ widelands- dev/widelands/ build/_ widelands_ dev_widelands_ compiler_ warnings_ 20170619- 2153.
Appveyor build 2153. State: success. Details: https:/