From 983d8f5f8ea6c8deac1f8f60389d4b1c8549e9c7 Mon Sep 17 00:00:00 2001 From: omar Date: Sat, 23 Dec 2017 15:15:27 +0100 Subject: [PATCH] Various zealous warning fixes (Clang). --- imgui.cpp | 5 +++-- imgui_demo.cpp | 3 ++- imgui_draw.cpp | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 147db31d..649d2e76 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3288,7 +3288,8 @@ void ImGui::RenderTriangle(ImVec2 p_min, ImGuiDir dir, float scale) b = ImVec2(-0.500f,+0.866f) * r; c = ImVec2(-0.500f,-0.866f) * r; break; - default: + case ImGuiDir_None: + case ImGuiDir_Count_: IM_ASSERT(0); break; } @@ -10255,7 +10256,7 @@ static void RenderArrow(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGui case ImGuiDir_Right: draw_list->AddTriangleFilled(ImVec2(pos.x - half_sz.x, pos.y + half_sz.y), ImVec2(pos.x - half_sz.x, pos.y - half_sz.y), pos, col); return; case ImGuiDir_Up: draw_list->AddTriangleFilled(ImVec2(pos.x + half_sz.x, pos.y + half_sz.y), ImVec2(pos.x - half_sz.x, pos.y + half_sz.y), pos, col); return; case ImGuiDir_Down: draw_list->AddTriangleFilled(ImVec2(pos.x - half_sz.x, pos.y - half_sz.y), ImVec2(pos.x + half_sz.x, pos.y - half_sz.y), pos, col); return; - default: break; // Fix warning for ImGuiDir_None + case ImGuiDir_None: case ImGuiDir_Count_: break; // Fix warnings } } diff --git a/imgui_demo.cpp b/imgui_demo.cpp index fb0cff59..0624bdd3 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -1304,7 +1304,8 @@ void ImGui::ShowTestWindow(bool* p_open) if (n > 0) ImGui::SameLine(); ImGui::PushID(n + line * 1000); char num_buf[16]; - const char* label = (!(n%15)) ? "FizzBuzz" : (!(n%3)) ? "Fizz" : (!(n%5)) ? "Buzz" : (sprintf(num_buf, "%d", n), num_buf); + sprintf(num_buf, "%d", n); + const char* label = (!(n%15)) ? "FizzBuzz" : (!(n%3)) ? "Fizz" : (!(n%5)) ? "Buzz" : num_buf; float hue = n*0.05f; ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)ImColor::HSV(hue, 0.6f, 0.6f)); ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)ImColor::HSV(hue, 0.7f, 0.7f)); diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 48500c7c..02cf42cc 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -42,6 +42,7 @@ #pragma clang diagnostic ignored "-Wfloat-equal" // warning : comparing floating point with == or != is unsafe // storing and comparing against same constants ok. #pragma clang diagnostic ignored "-Wglobal-constructors" // warning : declaration requires a global destructor // similar to above, not sure what the exact difference it. #pragma clang diagnostic ignored "-Wsign-conversion" // warning : implicit conversion changes signedness // +#pragma clang diagnostic ignored "-Wcomma" // warning : possible misuse of comma operator here // #if __has_warning("-Wreserved-id-macro") #pragma clang diagnostic ignored "-Wreserved-id-macro" // warning : macro name is a reserved identifier // #endif @@ -77,6 +78,7 @@ namespace IMGUI_STB_NAMESPACE #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunused-function" #pragma clang diagnostic ignored "-Wmissing-prototypes" +#pragma clang diagnostic ignored "-Wimplicit-fallthrough" #endif #ifdef __GNUC__