From 9458e4e665e14385042597c45ded27a6c7d4e8d2 Mon Sep 17 00:00:00 2001 From: Ingo Ruhnke Date: Sun, 31 Aug 2014 08:12:18 +0200 Subject: [PATCH] Fixed numerous issues that caused errors in clang --- CMakeLists.txt | 4 ++-- external/tinygettext/src/plural_forms.cpp | 4 ++-- src/addon/downloader.cpp | 4 ++-- src/badguy/kugelblitz.cpp | 1 - src/badguy/kugelblitz.hpp | 1 - src/badguy/treewillowisp.cpp | 1 - src/object/block.cpp | 1 - src/object/bullet.cpp | 1 - src/object/camera.cpp | 1 - src/object/infoblock.cpp | 7 ------- src/object/player.cpp | 3 --- src/supertux/savegame.cpp | 2 ++ src/util/utf8_iterator.cpp | 4 ++-- src/video/drawing_context.hpp | 2 +- src/video/gl/gl_painter.hpp | 2 +- src/video/gl/gl_texture.cpp | 2 ++ 16 files changed, 14 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f8bd259bb..f46bb2d80 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -273,8 +273,8 @@ IF(CMAKE_COMPILER_IS_GNUCC) # fails on MinGW: # -ansi # fails on clang: - # -Wlogical-op - SET(SUPERTUX2_EXTRA_WARNING_FLAGS "-fdiagnostics-show-option -pedantic -Wno-long-long -Wcast-align -Wdisabled-optimization -Winit-self -Winvalid-pch -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wredundant-decls -Wstack-protector -Wformat=2 -Weffc++ -Wctor-dtor-privacy -Wstrict-null-sentinel -Wno-unused-parameter -Wshadow -Wnon-virtual-dtor -Wcast-qual") + # -Wlogical-op -Wstrict-null-sentinel + SET(SUPERTUX2_EXTRA_WARNING_FLAGS "-fdiagnostics-show-option -pedantic -Wno-long-long -Wcast-align -Wdisabled-optimization -Winit-self -Winvalid-pch -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wredundant-decls -Wstack-protector -Wformat=2 -Weffc++ -Wctor-dtor-privacy -Wno-unused-parameter -Wshadow -Wnon-virtual-dtor -Wcast-qual") ENDIF(WARNINGS) ENDIF(CMAKE_COMPILER_IS_GNUCC) diff --git a/external/tinygettext/src/plural_forms.cpp b/external/tinygettext/src/plural_forms.cpp index 5a2fd5577..d9aa7f3e7 100644 --- a/external/tinygettext/src/plural_forms.cpp +++ b/external/tinygettext/src/plural_forms.cpp @@ -46,7 +46,7 @@ unsigned int plural4_ar(int n) { return static_cast( n==1 ? 0 : n= PluralForms PluralForms::from_string(const std::string& str) { - static std::unordered_map plural_forms; + static std::unordered_map plural_forms; if (plural_forms.empty()) { @@ -73,7 +73,7 @@ PluralForms::from_string(const std::string& str) if (!isspace(str[i])) space_less_str += str[i]; - std::unordered_map::const_iterator it= plural_forms.find(space_less_str); + std::unordered_map::const_iterator it= plural_forms.find(space_less_str); if (it != plural_forms.end()) { return it->second; diff --git a/src/addon/downloader.cpp b/src/addon/downloader.cpp index 574254f59..d94854166 100644 --- a/src/addon/downloader.cpp +++ b/src/addon/downloader.cpp @@ -82,8 +82,8 @@ public: m_id(id), m_url(url), m_handle(), - m_error_buffer({'\0'}), - m_status(new TransferStatus(downloader, id)), + m_error_buffer({{'\0'}}), + m_status(new TransferStatus(m_downloader, id)), m_fout(PHYSFS_openWrite(outfile.c_str()), PHYSFS_close) { if (!m_fout) diff --git a/src/badguy/kugelblitz.cpp b/src/badguy/kugelblitz.cpp index da2c6e024..cfc900fd2 100644 --- a/src/badguy/kugelblitz.cpp +++ b/src/badguy/kugelblitz.cpp @@ -40,7 +40,6 @@ Kugelblitz::Kugelblitz(const Reader& reader) : movement_timer(), lifetime(), direction(), - state(), light(0.0f,0.0f,0.0f), lightsprite(SpriteManager::current()->create("images/objects/lightmap_light/lightmap_light.sprite")) { diff --git a/src/badguy/kugelblitz.hpp b/src/badguy/kugelblitz.hpp index b235aec6f..6b6f61c9c 100644 --- a/src/badguy/kugelblitz.hpp +++ b/src/badguy/kugelblitz.hpp @@ -46,7 +46,6 @@ private: Timer movement_timer; Timer lifetime; int direction; - State state; Color light; SpritePtr lightsprite; }; diff --git a/src/badguy/treewillowisp.cpp b/src/badguy/treewillowisp.cpp index 3de20e03d..3dd74f1ae 100644 --- a/src/badguy/treewillowisp.cpp +++ b/src/badguy/treewillowisp.cpp @@ -26,7 +26,6 @@ #include static const std::string TREEWILLOSOUND = "sounds/willowisp.wav"; -static const float SUCKSPEED = 25; TreeWillOWisp::TreeWillOWisp(GhostTree* tree_, const Vector& pos, float radius_, float speed_) : diff --git a/src/object/block.cpp b/src/object/block.cpp index 1e242710f..c8d5338bf 100644 --- a/src/object/block.cpp +++ b/src/object/block.cpp @@ -29,7 +29,6 @@ static const float BOUNCY_BRICK_MAX_OFFSET = 8; static const float BOUNCY_BRICK_SPEED = 90; -static const float EPSILON = .0001f; static const float BUMP_ROTATION_ANGLE = 10; Block::Block(SpritePtr newsprite) : diff --git a/src/object/bullet.cpp b/src/object/bullet.cpp index 46c5260a5..b26bd35d8 100644 --- a/src/object/bullet.cpp +++ b/src/object/bullet.cpp @@ -24,7 +24,6 @@ namespace { const float BULLET_XM = 600; -const float BULLET_STARTING_YM = 0; } Bullet::Bullet(const Vector& pos, float xm, int dir, BonusType type_) : diff --git a/src/object/camera.cpp b/src/object/camera.cpp index abca4a7e6..28afe6b75 100644 --- a/src/object/camera.cpp +++ b/src/object/camera.cpp @@ -230,7 +230,6 @@ Camera::scroll_to(const Vector& goal, float scrolltime) } static const float CAMERA_EPSILON = .00001f; -static const float MAX_SPEED_Y = 140; void Camera::update(float elapsed_time) diff --git a/src/object/infoblock.cpp b/src/object/infoblock.cpp index 2bbb42f77..d927f4585 100644 --- a/src/object/infoblock.cpp +++ b/src/object/infoblock.cpp @@ -25,13 +25,6 @@ #include "video/drawing_context.hpp" #include "sprite/sprite.hpp" -namespace { -const float SCROLL_DELAY = 0.5; -const float SCROLL_DISTANCE = 16; -const float WIDTH = 400; -const float HEIGHT = 200; -} - InfoBlock::InfoBlock(const Reader& lisp) : Block(SpriteManager::current()->create("images/objects/bonus_block/infoblock.sprite")), message(), diff --git a/src/object/player.cpp b/src/object/player.cpp index ab375d7e0..efcc99e65 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -40,7 +40,6 @@ //#define SWIMMING namespace { -static const int TILES_FOR_BUTTJUMP = 3; static const float BUTTJUMP_MIN_VELOCITY_Y = 400.0f; static const float SHOOTING_TIME = .150f; @@ -88,8 +87,6 @@ static const float ICE_ACCELERATION_MULTIPLIER = 0.25f; /** time of the kick (kicking mriceblock) animation */ static const float KICK_TIME = .3f; -/** time of tux cheering (currently unused) */ -static const float CHEER_TIME = 1.0f; /** if Tux cannot unduck for this long, he will get hurt */ static const float UNDUCK_HURT_TIME = 0.25f; diff --git a/src/supertux/savegame.cpp b/src/supertux/savegame.cpp index df484ec59..b181901a3 100644 --- a/src/supertux/savegame.cpp +++ b/src/supertux/savegame.cpp @@ -17,6 +17,8 @@ #include "supertux/savegame.hpp" +#include + #include "lisp/lisp.hpp" #include "lisp/parser.hpp" #include "lisp/writer.hpp" diff --git a/src/util/utf8_iterator.cpp b/src/util/utf8_iterator.cpp index 01234d2b7..fa3b19898 100644 --- a/src/util/utf8_iterator.cpp +++ b/src/util/utf8_iterator.cpp @@ -94,7 +94,7 @@ UTF8Iterator::UTF8Iterator(const std::string& text_) : try { chr = decode_utf8(text, pos); } catch (std::exception) { - log_debug << "Malformed utf-8 sequence beginning with " << *((const uint32_t*)(text.c_str() + pos)) << " found " << std::endl; + log_debug << "Malformed utf-8 sequence beginning with " << *(reinterpret_cast(text.c_str() + pos)) << " found " << std::endl; chr = 0; } } @@ -110,7 +110,7 @@ UTF8Iterator::operator++() { try { chr = decode_utf8(text, pos); } catch (std::exception) { - log_debug << "Malformed utf-8 sequence beginning with " << *((const uint32_t*)(text.c_str() + pos)) << " found " << std::endl; + log_debug << "Malformed utf-8 sequence beginning with " << *(reinterpret_cast(text.c_str() + pos)) << " found " << std::endl; chr = 0; ++pos; } diff --git a/src/video/drawing_context.hpp b/src/video/drawing_context.hpp index ef55b8fa8..53e171aee 100644 --- a/src/video/drawing_context.hpp +++ b/src/video/drawing_context.hpp @@ -30,7 +30,7 @@ #include "video/font_ptr.hpp" #include "video/texture.hpp" -class DrawingRequest; +struct DrawingRequest; class Surface; class Texture; class VideoSystem; diff --git a/src/video/gl/gl_painter.hpp b/src/video/gl/gl_painter.hpp index 0345e15e0..bb3dd7593 100644 --- a/src/video/gl/gl_painter.hpp +++ b/src/video/gl/gl_painter.hpp @@ -26,7 +26,7 @@ using namespace gl; #include "SDL_opengl.h" #endif -class DrawingRequest; +struct DrawingRequest; class GLPainter { diff --git a/src/video/gl/gl_texture.cpp b/src/video/gl/gl_texture.cpp index 3a6d18f08..443fa0121 100644 --- a/src/video/gl/gl_texture.cpp +++ b/src/video/gl/gl_texture.cpp @@ -23,10 +23,12 @@ namespace { +#ifdef GL_VERSION_ES_CM_1_0 inline bool is_power_of_2(int v) { return (v & (v-1)) == 0; } +#endif inline int next_power_of_two(int val) { -- 2.11.0