Merge pull request #67183 from akien-mga/gcc-warnings-cleanup

SCons: Cleanup GCC warnings configuration
This commit is contained in:
Rémi Verschelde 2022-10-10 17:42:36 +02:00
commit 28f642097a
26 changed files with 47 additions and 161 deletions

View file

@ -687,6 +687,14 @@ if selected_platform in platform_list:
if methods.using_gcc(env):
common_warnings += ["-Wshadow-local", "-Wno-misleading-indentation"]
if cc_version_major == 7: # Bogus warning fixed in 8+.
common_warnings += ["-Wno-strict-overflow"]
if cc_version_major < 11:
# Regression in GCC 9/10, spams so much in our variadic templates
# that we need to outright disable it.
common_warnings += ["-Wno-type-limits"]
if cc_version_major >= 12: # False positives in our error macros, see GH-58747.
common_warnings += ["-Wno-return-type"]
elif methods.using_clang(env) or methods.using_emcc(env):
# We often implement `operator<` for structs of pointers as a requirement
# for putting them in `Set` or `Map`. We don't mind about unreliable ordering.
@ -702,13 +710,16 @@ if selected_platform in platform_list:
"-Wduplicated-branches",
"-Wduplicated-cond",
"-Wstringop-overflow=4",
"-Wlogical-op",
]
)
# -Wnoexcept was removed temporarily due to GH-36325.
env.Append(CXXFLAGS=["-Wplacement-new=1"])
# Need to fix a warning with AudioServer lambdas before enabling.
# if cc_version_major != 9: # GCC 9 had a regression (GH-36325).
# env.Append(CXXFLAGS=["-Wnoexcept"])
if cc_version_major >= 9:
env.Append(CCFLAGS=["-Wattribute-alias=2"])
if cc_version_major >= 11: # Broke on MethodBind templates before GCC 11.
env.Append(CCFLAGS=["-Wlogical-op"])
elif methods.using_clang(env) or methods.using_emcc(env):
env.Append(CCFLAGS=["-Wimplicit-fallthrough"])
elif env["warnings"] == "all":
@ -720,15 +731,6 @@ if selected_platform in platform_list:
if env["werror"]:
env.Append(CCFLAGS=["-Werror"])
# FIXME: Temporary workaround after the Vulkan merge, remove once warnings are fixed.
if methods.using_gcc(env):
env.Append(CXXFLAGS=["-Wno-error=cpp"])
if cc_version_major == 7: # Bogus warning fixed in 8+.
env.Append(CCFLAGS=["-Wno-error=strict-overflow"])
if cc_version_major >= 12: # False positives in our error macros, see GH-58747.
env.Append(CCFLAGS=["-Wno-error=return-type"])
elif methods.using_clang(env) or methods.using_emcc(env):
env.Append(CXXFLAGS=["-Wno-error=#warnings"])
if hasattr(detect, "get_program_suffix"):
suffix = "." + detect.get_program_suffix()

View file

@ -292,11 +292,6 @@ class MethodBindT : public MethodBind {
void (MB_T::*method)(P...);
protected:
// GCC raises warnings in the case P = {} as the comparison is always false...
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wlogical-op"
#endif
virtual Variant::Type _gen_argument_type(int p_arg) const override {
if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {
return call_get_argument_type<P...>(p_arg);
@ -304,9 +299,6 @@ protected:
return Variant::NIL;
}
}
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
virtual PropertyInfo _gen_argument_type_info(int p_arg) const override {
PropertyInfo pi;
@ -367,11 +359,6 @@ class MethodBindTC : public MethodBind {
void (MB_T::*method)(P...) const;
protected:
// GCC raises warnings in the case P = {} as the comparison is always false...
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wlogical-op"
#endif
virtual Variant::Type _gen_argument_type(int p_arg) const override {
if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {
return call_get_argument_type<P...>(p_arg);
@ -379,9 +366,6 @@ protected:
return Variant::NIL;
}
}
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
virtual PropertyInfo _gen_argument_type_info(int p_arg) const override {
PropertyInfo pi;
@ -444,11 +428,6 @@ class MethodBindTR : public MethodBind {
(P...);
protected:
// GCC raises warnings in the case P = {} as the comparison is always false...
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wlogical-op"
#endif
virtual Variant::Type _gen_argument_type(int p_arg) const override {
if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {
return call_get_argument_type<P...>(p_arg);
@ -466,9 +445,6 @@ protected:
return GetTypeInfo<R>::get_class_info();
}
}
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
public:
#ifdef DEBUG_METHODS_ENABLED
@ -531,11 +507,6 @@ class MethodBindTRC : public MethodBind {
(P...) const;
protected:
// GCC raises warnings in the case P = {} as the comparison is always false...
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wlogical-op"
#endif
virtual Variant::Type _gen_argument_type(int p_arg) const override {
if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {
return call_get_argument_type<P...>(p_arg);
@ -553,9 +524,6 @@ protected:
return GetTypeInfo<R>::get_class_info();
}
}
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
public:
#ifdef DEBUG_METHODS_ENABLED
@ -615,11 +583,6 @@ class MethodBindTS : public MethodBind {
void (*function)(P...);
protected:
// GCC raises warnings in the case P = {} as the comparison is always false...
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wlogical-op"
#endif
virtual Variant::Type _gen_argument_type(int p_arg) const override {
if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {
return call_get_argument_type<P...>(p_arg);
@ -627,9 +590,6 @@ protected:
return Variant::NIL;
}
}
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
virtual PropertyInfo _gen_argument_type_info(int p_arg) const override {
PropertyInfo pi;
@ -678,11 +638,6 @@ class MethodBindTRS : public MethodBind {
(P...);
protected:
// GCC raises warnings in the case P = {} as the comparison is always false...
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wlogical-op"
#endif
virtual Variant::Type _gen_argument_type(int p_arg) const override {
if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {
return call_get_argument_type<P...>(p_arg);
@ -690,9 +645,6 @@ protected:
return GetTypeInfo<R>::VARIANT_TYPE;
}
}
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
virtual PropertyInfo _gen_argument_type_info(int p_arg) const override {
if (p_arg >= 0 && p_arg < (int)sizeof...(P)) {

View file

@ -82,9 +82,7 @@ public:
GDVIRTUAL_REQUIRED_CALL(_get_documentation, doc);
Vector<DocData::ClassDoc> class_doc;
#ifndef _MSC_VER
#warning missing conversion from documentation to ClassDoc
#endif
// TODO: Missing conversion from documentation to ClassDoc.
return class_doc;
}
#endif // TOOLS_ENABLED

View file

@ -179,8 +179,8 @@ NetSocketPosix::~NetSocketPosix() {
close();
}
// Silent a warning reported in #27594
// Silence a warning reported in GH-27594.
// EAGAIN and EWOULDBLOCK have the same value on most platforms, but it's not guaranteed.
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wlogical-op"

View file

@ -1655,9 +1655,7 @@ RID RenderingDeviceVulkan::texture_create(const TextureFormat &p_format, const T
image_create_info.pNext = nullptr;
image_create_info.flags = 0;
#ifndef _MSC_VER
#warning TODO check for support via RenderingDevice to enable on mobile when possible
#endif
// TODO: Check for support via RenderingDevice to enable on mobile when possible.
#ifndef ANDROID_ENABLED

View file

@ -752,9 +752,7 @@ CreateDialog::CreateDialog() {
favorites->connect("cell_selected", callable_mp(this, &CreateDialog::_favorite_selected));
favorites->connect("item_activated", callable_mp(this, &CreateDialog::_favorite_activated));
favorites->add_theme_constant_override("draw_guides", 1);
#ifndef _MSC_VER
#warning cannot forward drag data to a non control, must be fixed
#endif
// Cannot forward drag data to a non control, must be fixed.
//favorites->set_drag_forwarding(this);
fav_vb->add_margin_child(TTR("Favorites:"), favorites, true);

View file

@ -1015,9 +1015,7 @@ ProjectExportDialog::ProjectExportDialog() {
preset_vb->add_child(mc);
mc->set_v_size_flags(Control::SIZE_EXPAND_FILL);
presets = memnew(ItemList);
#ifndef _MSC_VER
#warning must reimplement drag forward
#endif
// TODO: Must reimplement drag forwarding.
//presets->set_drag_forwarding(this);
mc->add_child(presets);
presets->connect("item_selected", callable_mp(this, &ProjectExportDialog::_edit_preset));

View file

@ -4773,9 +4773,8 @@ Node3DEditorViewport::Node3DEditorViewport(Node3DEditor *p_spatial_editor, int p
view_menu->get_popup()->connect("id_pressed", callable_mp(this, &Node3DEditorViewport::_menu_option));
display_submenu->connect("id_pressed", callable_mp(this, &Node3DEditorViewport::_menu_option));
view_menu->set_disable_shortcuts(true);
#ifndef _MSC_VER
#warning this needs to be fixed
#endif
// TODO: Re-evaluate with new OpenGL3 renderer, and implement.
//if (OS::get_singleton()->get_current_video_driver() == OS::VIDEO_DRIVER_GLES2) {
if (false) {
// Alternate display modes only work when using the Vulkan renderer; make this explicit.

View file

@ -2590,10 +2590,7 @@ Error GLTFDocument::_parse_meshes(Ref<GLTFState> state) {
Mesh::PRIMITIVE_TRIANGLES, // 4 TRIANGLES
Mesh::PRIMITIVE_TRIANGLE_STRIP, // 5 TRIANGLE_STRIP
Mesh::PRIMITIVE_TRIANGLES, // 6 TRIANGLE_FAN fan not supported, should be converted
#ifndef _MSC_VER
#warning line loop and triangle fan are not supported and need to be converted to lines and triangles
#endif
// TODO: Line loop and triangle fan are not supported and need to be converted to lines and triangles.
};
primitive = primitives2[mode];

View file

@ -150,9 +150,8 @@ public:
env->DeleteLocalRef(arr);
} break;
#ifndef _MSC_VER
#warning This is missing 64 bits arrays, I have no idea how to do it in JNI
#endif
// TODO: This is missing 64 bits arrays, I have no idea how to do it in JNI.
case Variant::DICTIONARY: {
jobject obj = env->CallObjectMethodA(instance, E->get().method, v);
ret = _jobject_to_variant(env, obj);

View file

@ -167,9 +167,8 @@ jvalret _variant_to_jvalue(JNIEnv *env, Variant::Type p_type, const Variant *p_a
v.obj = arr;
} break;
#ifndef _MSC_VER
#warning This is missing 64 bits arrays, I have no idea how to do it in JNI
#endif
// TODO: This is missing 64 bits arrays, I have no idea how to do it in JNI.
default: {
v.val.i = 0;

View file

@ -1202,16 +1202,6 @@ float DisplayServerX11::screen_get_refresh_rate(int p_screen) const {
return SCREEN_REFRESH_RATE_FALLBACK;
}
bool DisplayServerX11::screen_is_touchscreen(int p_screen) const {
_THREAD_SAFE_METHOD_
#ifndef _MSC_VER
#warning Need to get from proper window
#endif
return DisplayServer::screen_is_touchscreen(p_screen);
}
#ifdef DBUS_ENABLED
void DisplayServerX11::screen_set_keep_on(bool p_enable) {
if (screen_is_kept_on() == p_enable) {

View file

@ -349,7 +349,6 @@ public:
virtual Rect2i screen_get_usable_rect(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
virtual float screen_get_refresh_rate(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
virtual bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
#if defined(DBUS_ENABLED)
virtual void screen_set_keep_on(bool p_enable) override;

View file

@ -561,20 +561,6 @@ float DisplayServerWindows::screen_get_refresh_rate(int p_screen) const {
return data.rate;
}
bool DisplayServerWindows::screen_is_touchscreen(int p_screen) const {
#ifndef _MSC_VER
#warning touchscreen not working
#endif
return DisplayServer::screen_is_touchscreen(p_screen);
}
void DisplayServerWindows::screen_set_orientation(ScreenOrientation p_orientation, int p_screen) {
}
DisplayServer::ScreenOrientation DisplayServerWindows::screen_get_orientation(int p_screen) const {
return SCREEN_LANDSCAPE;
}
void DisplayServerWindows::screen_set_keep_on(bool p_enable) {
if (keep_screen_on == p_enable) {
return;

View file

@ -516,10 +516,6 @@ public:
virtual Rect2i screen_get_usable_rect(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
virtual int screen_get_dpi(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
virtual float screen_get_refresh_rate(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
virtual bool screen_is_touchscreen(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
virtual void screen_set_orientation(ScreenOrientation p_orientation, int p_screen = SCREEN_OF_MAIN_WINDOW) override;
virtual ScreenOrientation screen_get_orientation(int p_screen = SCREEN_OF_MAIN_WINDOW) const override;
virtual void screen_set_keep_on(bool p_enable) override; //disable screensaver
virtual bool screen_is_kept_on() const override;

View file

@ -192,10 +192,8 @@ void Bone2D::_notification(int p_what) {
cache_transform = tmp_trans;
} break;
// Bone2D Editor gizmo drawing:
#ifndef _MSC_VER
#warning TODO Bone2D gizmo drawing needs to be moved to an editor plugin
#endif
// Bone2D Editor gizmo drawing.
// TODO: Bone2D gizmo drawing needs to be moved to an editor plugin.
case NOTIFICATION_DRAW: {
// Only draw the gizmo in the editor!
if (Engine::get_singleton()->is_editor_hint() == false) {

View file

@ -309,9 +309,7 @@ bool Sprite2D::is_pixel_opaque(const Point2 &p_point) const {
q.y = 1.0f - q.y;
}
q = q * src_rect.size + src_rect.position;
#ifndef _MSC_VER
#warning this need to be obtained from CanvasItem new repeat mode (but it needs to guess it from hierarchy, need to add a function for that)
#endif
// TODO: This need to be obtained from CanvasItem new repeat mode (but it needs to guess it from hierarchy, need to add a function for that).
bool is_repeat = false;
bool is_mirrored_repeat = false;
if (is_repeat) {

View file

@ -1403,9 +1403,7 @@ void ColorPicker::_screen_pick_pressed() {
screen->show();
}
screen->move_to_front();
#ifndef _MSC_VER
#warning show modal no longer works, needs to be converted to a popup
#endif
// TODO: show modal no longer works, needs to be converted to a popup.
//screen->show_modal();
}

View file

@ -5239,9 +5239,7 @@ bool Animation::_fetch_compressed(uint32_t p_compressed_track, double p_time, Ve
double page_base_time = compression.pages[page_index].time_offset;
const uint8_t *page_data = compression.pages[page_index].data.ptr();
#ifndef _MSC_VER
#warning Little endian assumed. No major big endian hardware exists any longer, but in case it does it will need to be supported
#endif
// Little endian assumed. No major big endian hardware exists any longer, but in case it does it will need to be supported.
const uint32_t *indices = (const uint32_t *)page_data;
const uint16_t *time_keys = (const uint16_t *)&page_data[indices[p_compressed_track * 3 + 0]];
uint32_t time_key_count = indices[p_compressed_track * 3 + 1];
@ -5384,9 +5382,7 @@ void Animation::_get_compressed_key_indices_in_range(uint32_t p_compressed_track
double page_base_time = compression.pages[page_index].time_offset;
const uint8_t *page_data = compression.pages[page_index].data.ptr();
#ifndef _MSC_VER
#warning Little endian assumed. No major big endian hardware exists any longer, but in case it does it will need to be supported
#endif
// Little endian assumed. No major big endian hardware exists any longer, but in case it does it will need to be supported.
const uint32_t *indices = (const uint32_t *)page_data;
const uint16_t *time_keys = (const uint16_t *)&page_data[indices[p_compressed_track * 3 + 0]];
uint32_t time_key_count = indices[p_compressed_track * 3 + 1];
@ -5456,9 +5452,7 @@ int Animation::_get_compressed_key_count(uint32_t p_compressed_track) const {
for (uint32_t i = 0; i < compression.pages.size(); i++) {
const uint8_t *page_data = compression.pages[i].data.ptr();
#ifndef _MSC_VER
#warning Little endian assumed. No major big endian hardware exists any longer, but in case it does it will need to be supported
#endif
// Little endian assumed. No major big endian hardware exists any longer, but in case it does it will need to be supported.
const uint32_t *indices = (const uint32_t *)page_data;
const uint16_t *time_keys = (const uint16_t *)&page_data[indices[p_compressed_track * 3 + 0]];
uint32_t time_key_count = indices[p_compressed_track * 3 + 1];
@ -5492,9 +5486,7 @@ bool Animation::_fetch_compressed_by_index(uint32_t p_compressed_track, int p_in
for (uint32_t i = 0; i < compression.pages.size(); i++) {
const uint8_t *page_data = compression.pages[i].data.ptr();
#ifndef _MSC_VER
#warning Little endian assumed. No major big endian hardware exists any longer, but in case it does it will need to be supported
#endif
// Little endian assumed. No major big endian hardware exists any longer, but in case it does it will need to be supported.
const uint32_t *indices = (const uint32_t *)page_data;
const uint16_t *time_keys = (const uint16_t *)&page_data[indices[p_compressed_track * 3 + 0]];
uint32_t time_key_count = indices[p_compressed_track * 3 + 1];

View file

@ -1576,9 +1576,8 @@ void ArrayMesh::_recompute_aabb() {
}
}
}
#ifndef _MSC_VER
#warning need to add binding to add_surface using future MeshSurfaceData object
#endif
// TODO: Need to add binding to add_surface using future MeshSurfaceData object.
void ArrayMesh::add_surface(uint32_t p_format, PrimitiveType p_primitive, const Vector<uint8_t> &p_array, const Vector<uint8_t> &p_attribute_array, const Vector<uint8_t> &p_skin_array, int p_vertex_count, const Vector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<uint8_t> &p_blend_shape_data, const Vector<AABB> &p_bone_aabbs, const Vector<RS::SurfaceData::LOD> &p_lods) {
_create_if_empty();

View file

@ -1509,11 +1509,10 @@ bool VisualShader::_get(const StringName &p_name, Variant &r_ret) const {
}
void VisualShader::reset_state() {
#ifndef _MSC_VER
#warning everything needs to be cleared here
#endif
// TODO: Everything needs to be cleared here.
emit_changed();
}
void VisualShader::_get_property_list(List<PropertyInfo> *p_list) const {
//mode
p_list->push_back(PropertyInfo(Variant::INT, PNAME("mode"), PROPERTY_HINT_ENUM, "Node3D,CanvasItem,Particles,Sky,Fog"));

View file

@ -29,6 +29,7 @@
/*************************************************************************/
#include "pipeline_cache_rd.h"
#include "core/os/memory.h"
RID PipelineCacheRD::_generate_version(RD::VertexFormatID p_vertex_format_id, RD::FramebufferFormatID p_framebuffer_format_id, bool p_wireframe, uint32_t p_render_pass, uint32_t p_bool_specializations) {
@ -70,9 +71,7 @@ RID PipelineCacheRD::_generate_version(RD::VertexFormatID p_vertex_format_id, RD
}
void PipelineCacheRD::_clear() {
#ifndef _MSC_VER
#warning Clear should probably recompile all the variants already compiled instead to avoid stalls? needs discussion
#endif
// TODO: Clear should probably recompile all the variants already compiled instead to avoid stalls? Needs discussion.
if (versions) {
for (uint32_t i = 0; i < version_count; i++) {
//shader may be gone, so this may not be valid

View file

@ -1075,10 +1075,7 @@ void RendererCanvasRenderRD::_render_items(RID p_to_render_target, int p_item_co
clear_colors.push_back(texture_storage->render_target_get_clear_request_color(p_to_render_target));
texture_storage->render_target_disable_clear_request(p_to_render_target);
}
#ifndef _MSC_VER
#warning TODO obtain from framebuffer format eventually when this is implemented
#endif
// TODO: Obtain from framebuffer format eventually when this is implemented.
fb_uniform_set = texture_storage->render_target_get_framebuffer_uniform_set(p_to_render_target);
}

View file

@ -102,10 +102,8 @@ void RendererCompositorRD::begin_frame(double frame_step) {
}
void RendererCompositorRD::end_frame(bool p_swap_buffers) {
#ifndef _MSC_VER
#warning TODO: likely pass a bool to swap buffers to avoid display?
#endif
RD::get_singleton()->swap_buffers(); //probably should pass some bool to avoid display?
// TODO: Likely pass a bool to swap buffers to avoid display?
RD::get_singleton()->swap_buffers();
}
void RendererCompositorRD::initialize() {

View file

@ -29,6 +29,7 @@
/*************************************************************************/
#include "particles_storage.h"
#include "servers/rendering/renderer_rd/renderer_compositor_rd.h"
#include "servers/rendering/rendering_server_globals.h"
#include "texture_storage.h"
@ -1334,10 +1335,7 @@ void ParticlesStorage::update_particles() {
}
}
#ifndef _MSC_VER
#warning Should use display refresh rate for all this
#endif
// TODO: Should use display refresh rate for all this.
float screen_hz = 60;
int fixed_fps = 0;

View file

@ -29,6 +29,7 @@
/*************************************************************************/
#include "texture_storage.h"
#include "../effects/copy_effects.h"
#include "../framebuffer_cache_rd.h"
#include "material_storage.h"
@ -1496,9 +1497,7 @@ Ref<Image> TextureStorage::_validate_texture_format(const Ref<Image> &p_image, T
} break;
case Image::FORMAT_RGBE9995: {
r_format.format = RD::DATA_FORMAT_E5B9G9R9_UFLOAT_PACK32;
#ifndef _MSC_VER
#warning TODO need to make a function in Image to swap bits for this
#endif
// TODO: Need to make a function in Image to swap bits for this.
r_format.swizzle_r = RD::TEXTURE_SWIZZLE_IDENTITY;
r_format.swizzle_g = RD::TEXTURE_SWIZZLE_IDENTITY;
r_format.swizzle_b = RD::TEXTURE_SWIZZLE_IDENTITY;