From 49fec646cbf3afdf5e7d55589ab359a5ebcdb897 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Tue, 18 Feb 2020 14:57:11 +0100 Subject: Fix compilation warnings and re-enable werror=yes on Travis Fix -Wunused-variable, -Wunused-but-set-variable and -Wswitch warnings raised by GCC 8 and 9. Fix -Wunused-function, -Wunused-private-field and -Wtautological-constant-out-of-range-compare raised by Clang. Fix MSVC 2019 warning C4804 (unsafe use of type 'bool' in comparison operation). GCC -Wcpp warnings/Clang -W#warnings (`#warning`) are no longer raising errors and will thus not abort compilation with `werror=yes`. Treat glslang headers are system headers to avoid raising warnings. Re-enables us to build with `werror=yes` on Linux and macOS, thus catching warnings that would be introduced by new code. Fixes #36132. --- scene/resources/surface_tool.cpp | 48 ++-------------------------------------- 1 file changed, 2 insertions(+), 46 deletions(-) (limited to 'scene/resources') diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp index fc5c906bd4..fa177d03fb 100644 --- a/scene/resources/surface_tool.cpp +++ b/scene/resources/surface_tool.cpp @@ -537,58 +537,36 @@ Vector SurfaceTool::create_vertex_array_from_triangle_array Vector warr = p_arrays[VS::ARRAY_WEIGHTS]; int vc = varr.size(); - if (vc == 0) return ret; - int lformat = 0; - const Vector3 *rv; + int lformat = 0; if (varr.size()) { lformat |= VS::ARRAY_FORMAT_VERTEX; - rv = varr.ptr(); } - const Vector3 *rn; if (narr.size()) { lformat |= VS::ARRAY_FORMAT_NORMAL; - rn = narr.ptr(); } - const float *rt; if (tarr.size()) { lformat |= VS::ARRAY_FORMAT_TANGENT; - rt = tarr.ptr(); } - const Color *rc; if (carr.size()) { lformat |= VS::ARRAY_FORMAT_COLOR; - rc = carr.ptr(); } - - const Vector2 *ruv; if (uvarr.size()) { lformat |= VS::ARRAY_FORMAT_TEX_UV; - ruv = uvarr.ptr(); } - - const Vector2 *ruv2; if (uv2arr.size()) { lformat |= VS::ARRAY_FORMAT_TEX_UV2; - ruv2 = uv2arr.ptr(); } - - const int *rb; if (barr.size()) { lformat |= VS::ARRAY_FORMAT_BONES; - rb = barr.ptr(); } - - const float *rw; if (warr.size()) { lformat |= VS::ARRAY_FORMAT_WEIGHTS; - rw = warr.ptr(); } for (int i = 0; i < vc; i++) { - Vertex v; if (lformat & VS::ARRAY_FORMAT_VERTEX) v.vertex = varr[i]; @@ -642,58 +620,36 @@ void SurfaceTool::_create_list_from_arrays(Array arr, List *r_vertex, Li Vector warr = arr[VS::ARRAY_WEIGHTS]; int vc = varr.size(); - if (vc == 0) return; - lformat = 0; - const Vector3 *rv; + lformat = 0; if (varr.size()) { lformat |= VS::ARRAY_FORMAT_VERTEX; - rv = varr.ptr(); } - const Vector3 *rn; if (narr.size()) { lformat |= VS::ARRAY_FORMAT_NORMAL; - rn = narr.ptr(); } - const float *rt; if (tarr.size()) { lformat |= VS::ARRAY_FORMAT_TANGENT; - rt = tarr.ptr(); } - const Color *rc; if (carr.size()) { lformat |= VS::ARRAY_FORMAT_COLOR; - rc = carr.ptr(); } - - const Vector2 *ruv; if (uvarr.size()) { lformat |= VS::ARRAY_FORMAT_TEX_UV; - ruv = uvarr.ptr(); } - - const Vector2 *ruv2; if (uv2arr.size()) { lformat |= VS::ARRAY_FORMAT_TEX_UV2; - ruv2 = uv2arr.ptr(); } - - const int *rb; if (barr.size()) { lformat |= VS::ARRAY_FORMAT_BONES; - rb = barr.ptr(); } - - const float *rw; if (warr.size()) { lformat |= VS::ARRAY_FORMAT_WEIGHTS; - rw = warr.ptr(); } for (int i = 0; i < vc; i++) { - Vertex v; if (lformat & VS::ARRAY_FORMAT_VERTEX) v.vertex = varr[i]; -- cgit v1.2.3