Commit 53c3ca43 authored by Florian Oetke's avatar Florian Oetke
Browse files

vulkan upgrade to 1.1.70 and activated additional compiler warnings...

vulkan upgrade to 1.1.70 and activated additional compiler warnings (-Wunsafe-loop-optimizations -Wzero-as-null-pointer-constant -Wlogical-op)
parent d7d35a52
......@@ -134,14 +134,14 @@ namespace format {
}
_on_error(msg);
}
return c;
return static_cast<char>(c);
}
inline void Json_reader::_unget() {
_stream.unget();
auto c = _stream.peek();
_column--;
if(c=='\n') {
_column=-1;
_column = static_cast<std::uint32_t>(-1);
_row--;
}
}
......@@ -189,20 +189,20 @@ namespace format {
template<typename T>
T Json_reader::_read_decimal() {
T val = 0;
auto val = 0.0;
char c=_next();
for(double dec=10; c>='0' && c<='9'; c=_get(), dec*=10.f)
val+= (c-'0') / dec;
for(double dec=10; c>='0' && c<='9'; c=_get(), dec*=10.0)
val += (c-'0') / dec;
_unget();
return val;
return static_cast<T>(val);
}
template<typename T>
T Json_reader::_read_int() {
T val=0;
auto val = std::uint64_t(0);
bool negativ = false;
char c = _next();
......@@ -213,14 +213,27 @@ namespace format {
}
for(; c>='0' && c<='9'; c=_get())
val= (10*val)+ (c-'0');
val = (10u*val) + static_cast<std::uint64_t>((c-'0'));
_unget();
if( negativ )
val*=-1;
if constexpr(std::numeric_limits<T>::is_signed) {
if( negativ && val<=static_cast<std::uint64_t>(-std::numeric_limits<T>::min()))
return static_cast<T>( -static_cast<T>(val) );
else if(val<=std::numeric_limits<T>::max())
return static_cast<T>(val);
return val;
} else {
if(negativ) {
_on_error("Negative value -"+std::to_string(val)+" for signed type "+typeid(T).name());
return static_cast<T>(std::numeric_limits<T>::max() - static_cast<T>(val));
} else if(val<=std::numeric_limits<T>::max())
return static_cast<T>(val);
}
_on_error("Overflow! Value -"+std::to_string(val)+" doesn't fit in type "+typeid(T).name());
return static_cast<T>(val);
}
template<typename T>
......@@ -234,7 +247,7 @@ namespace format {
_rewind();
T val = _read_int<T>();
auto val = static_cast<T>(_read_int<std::uint64_t>());
char c = _get();
......@@ -246,7 +259,7 @@ namespace format {
if(c=='e' || c=='E') {
int64_t exp = _read_int<int64_t>();
val *= (T) std::pow(exp>0 ? 10.0 : 0.1, static_cast<double>(std::abs(exp)));
val *= static_cast<T>(std::pow(exp>0 ? 10.0 : 0.1, static_cast<double>(std::abs(exp))));
}else
_unget();
......
......@@ -15,7 +15,7 @@ endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(MIRRAGE_DEFAULT_COMPILER_ARGS -Wextra -Wall -pedantic -Werror -Wno-unused-parameter -Wno-unused-private-field -Wno-missing-braces)
set(MIRRAGE_DEFAULT_COMPILER_ARGS -Wextra -Wall -pedantic -Wunsafe-loop-optimizations -Wzero-as-null-pointer-constant -Wlogical-op -Werror -Wno-unused-parameter -Wno-unused-private-field -Wno-missing-braces)
elseif(MSVC)
set(MIRRAGE_DEFAULT_COMPILER_ARGS /Za)
endif()
......
......@@ -80,7 +80,7 @@ namespace mirrage::graphic {
auto surface = VkSurfaceKHR{};
SDL_Vulkan_CreateSurface(_window.get(), context.instance(), &surface);
_surface = vk::UniqueSurfaceKHR(surface, vk::SurfaceKHRDeleter{context.instance()});
_surface = vk::UniqueSurfaceKHR(surface, {context.instance()});
sdl_error_check();
}
......@@ -128,7 +128,7 @@ namespace mirrage::graphic {
target.h = height;
target.format = 0;
target.refresh_rate = 0;
target.driverdata = 0;
target.driverdata = nullptr;
if(fullscreen == Fullscreen::yes) { // check capabilities
if(!SDL_GetClosestDisplayMode(_display, &target, &closest)) {
......
......@@ -76,7 +76,7 @@ namespace mirrage::gui {
void post_input_events() override { nk_input_end(_ctx); }
bool handle_key(bool down, SDL_Keycode key) {
const auto state = SDL_GetKeyboardState(0);
const auto state = SDL_GetKeyboardState(nullptr);
const auto ctrl = state[SDL_SCANCODE_LCTRL] || state[SDL_SCANCODE_RCTRL];
switch(key) {
......@@ -202,7 +202,7 @@ namespace mirrage::gui {
nk_init_default(&ctx, nullptr);
ctx.clip.copy = nk_sdl_clipbard_copy;
ctx.clip.paste = nk_sdl_clipbard_paste;
ctx.clip.userdata = nk_handle_ptr(0);
ctx.clip.userdata = nk_handle_ptr(nullptr);
}
~Wnk_Context() { nk_free(&ctx); }
};
......
......@@ -325,14 +325,14 @@ namespace mirrage::util {
};
namespace details {
template <int...>
template <std::size_t...>
struct seq {};
template <int N, int... S>
struct gens : gens<N - 1, N - 1, S...> {};
template <std::size_t N, std::size_t... S>
struct gens : gens<N - 1u, N - 1u, S...> {};
template <int... S>
struct gens<0, S...> {
template <std::size_t... S>
struct gens<0u, S...> {
typedef seq<S...> type;
};
......
......@@ -13,7 +13,7 @@ namespace mirrage::util {
// format: YYYYMMDD_HHmmss
// Visit http://en.cppreference.com/w/cpp/chrono/c/strftime
std::string get_now_short() {
time_t now = time(0);
time_t now = time(nullptr);
struct tm tstruct;
char buf[80];
tstruct = *localtime(&now);
......@@ -22,7 +22,7 @@ namespace mirrage::util {
return buf;
}
std::string get_now() {
time_t now = time(0);
time_t now = time(nullptr);
struct tm tstruct;
char buf[80];
tstruct = *localtime(&now);
......
......@@ -10,7 +10,7 @@ namespace mirrage::util {
std::string demangle(const char* name) {
int status = -1;
std::unique_ptr<char, void (*)(void*)> res{abi::__cxa_demangle(name, NULL, NULL, &status),
std::unique_ptr<char, void (*)(void*)> res{abi::__cxa_demangle(name, nullptr, nullptr, &status),
&std::free};
return status == 0 ? res.get() : name;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment