Core: Integrate warning suppression macro helpers

This commit is contained in:
Thaddeus Crews 2025-03-31 10:56:33 -05:00
parent 1f56d96cf2
commit 207a2b6472
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC
25 changed files with 119 additions and 180 deletions

View file

@ -105,18 +105,16 @@ Error PacketPeerUDP::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
return ERR_UNAVAILABLE; return ERR_UNAVAILABLE;
} }
/* Bogus GCC warning here: /* Bogus GCC warning here:
* In member function 'int RingBuffer<T>::read(T*, int, bool) [with T = unsigned char]', * In member function 'int RingBuffer<T>::read(T*, int, bool) [with T = unsigned char]',
* inlined from 'virtual Error PacketPeerUDP::get_packet(const uint8_t**, int&)' at core/io/packet_peer_udp.cpp:112:9, * inlined from 'virtual Error PacketPeerUDP::get_packet(const uint8_t**, int&)' at core/io/packet_peer_udp.cpp:112:9,
* inlined from 'virtual Error PacketPeerUDP::get_packet(const uint8_t**, int&)' at core/io/packet_peer_udp.cpp:99:7: * inlined from 'virtual Error PacketPeerUDP::get_packet(const uint8_t**, int&)' at core/io/packet_peer_udp.cpp:99:7:
* Error: ./core/ring_buffer.h:68:46: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=] * Error: ./core/ring_buffer.h:68:46: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
* 68 | p_buf[dst++] = read[pos + i]; * 68 | p_buf[dst++] = read[pos + i];
* | ~~~~~~~~~~~~~^~~~~~~ * | ~~~~~~~~~~~~~^~~~~~~
*/ */
#if defined(__GNUC__) && !defined(__clang__) GODOT_GCC_WARNING_PUSH
#pragma GCC diagnostic push GODOT_GCC_PRAGMA(GCC diagnostic warning "-Wstringop-overflow=0") // Can't "ignore" this for some reason.
#pragma GCC diagnostic warning "-Wstringop-overflow=0"
#endif
uint32_t size = 0; uint32_t size = 0;
uint8_t ipv6[16] = {}; uint8_t ipv6[16] = {};
@ -129,9 +127,7 @@ Error PacketPeerUDP::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
*r_buffer = packet_buffer; *r_buffer = packet_buffer;
r_buffer_size = size; r_buffer_size = size;
#if defined(__GNUC__) && !defined(__clang__) GODOT_GCC_WARNING_POP
#pragma GCC diagnostic pop
#endif
return OK; return OK;
} }

View file

@ -167,11 +167,7 @@ public:
return p_segment_a + n * d; // Inside. return p_segment_a + n * d; // Inside.
} }
// Disable False Positives in MSVC compiler; we correctly check for 0 here to prevent a division by 0. GODOT_MSVC_WARNING_PUSH_AND_IGNORE(4723) // Potential divide by 0. False positive (see: GH-44274).
// See: https://github.com/godotengine/godot/pull/44274
#ifdef _MSC_VER
#pragma warning(disable : 4723)
#endif
static bool line_intersects_line(const Vector2 &p_from_a, const Vector2 &p_dir_a, const Vector2 &p_from_b, const Vector2 &p_dir_b, Vector2 &r_result) { static bool line_intersects_line(const Vector2 &p_from_a, const Vector2 &p_dir_a, const Vector2 &p_from_b, const Vector2 &p_dir_b, Vector2 &r_result) {
// See http://paulbourke.net/geometry/pointlineplane/ // See http://paulbourke.net/geometry/pointlineplane/
@ -187,10 +183,7 @@ public:
return true; return true;
} }
// Re-enable division by 0 warning GODOT_MSVC_WARNING_POP
#ifdef _MSC_VER
#pragma warning(default : 4723)
#endif
static bool segment_intersects_segment(const Vector2 &p_from_a, const Vector2 &p_to_a, const Vector2 &p_from_b, const Vector2 &p_to_b, Vector2 *r_result) { static bool segment_intersects_segment(const Vector2 &p_from_a, const Vector2 &p_to_a, const Vector2 &p_from_b, const Vector2 &p_to_b, Vector2 *r_result) {
Vector2 B = p_to_a - p_from_a; Vector2 B = p_to_a - p_from_a;

View file

@ -257,11 +257,8 @@ class MethodBindVarArgTR : public MethodBindVarArgBase<MethodBindVarArgTR<T, R>,
friend class MethodBindVarArgBase<MethodBindVarArgTR<T, R>, T, R, true>; friend class MethodBindVarArgBase<MethodBindVarArgTR<T, R>, T, R, true>;
public: public:
#if defined(SANITIZERS_ENABLED) && defined(__GNUC__) && !defined(__clang__) GODOT_GCC_WARNING_PUSH_AND_IGNORE("-Wmaybe-uninitialized") // Workaround GH-66343 raised only with UBSAN, seems to be a false positive.
// Workaround GH-66343 raised only with UBSAN, seems to be a false positive.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) const override { virtual Variant call(Object *p_object, const Variant **p_args, int p_arg_count, Callable::CallError &r_error) const override {
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
ERR_FAIL_COND_V_MSG(p_object && p_object->is_extension_placeholder() && p_object->get_class_name() == MethodBind::get_instance_class(), Variant(), vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name())); ERR_FAIL_COND_V_MSG(p_object && p_object->is_extension_placeholder() && p_object->get_class_name() == MethodBind::get_instance_class(), Variant(), vformat("Cannot call method bind '%s' on placeholder instance.", MethodBind::get_name()));
@ -269,9 +266,7 @@ public:
return (static_cast<T *>(p_object)->*MethodBindVarArgBase<MethodBindVarArgTR<T, R>, T, R, true>::method)(p_args, p_arg_count, r_error); return (static_cast<T *>(p_object)->*MethodBindVarArgBase<MethodBindVarArgTR<T, R>, T, R, true>::method)(p_args, p_arg_count, r_error);
} }
#if defined(SANITIZERS_ENABLED) && defined(__GNUC__) && !defined(__clang__) GODOT_GCC_WARNING_POP
#pragma GCC diagnostic pop
#endif
MethodBindVarArgTR( MethodBindVarArgTR(
R (T::*p_method)(const Variant **, int, Callable::CallError &), R (T::*p_method)(const Variant **, int, Callable::CallError &),

View file

@ -711,11 +711,7 @@ public:
GDExtensionScriptInstanceDataPtr instance = nullptr; GDExtensionScriptInstanceDataPtr instance = nullptr;
// There should not be warnings on explicit casts. GODOT_GCC_WARNING_PUSH_AND_IGNORE("-Wignored-qualifiers") // There should not be warnings on explicit casts.
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wignored-qualifiers"
#endif
virtual bool set(const StringName &p_name, const Variant &p_value) override { virtual bool set(const StringName &p_name, const Variant &p_value) override {
if (native_info->set_func) { if (native_info->set_func) {
@ -963,7 +959,5 @@ public:
#endif // DISABLE_DEPRECATED #endif // DISABLE_DEPRECATED
} }
#if defined(__GNUC__) && !defined(__clang__) GODOT_GCC_WARNING_POP
#pragma GCC diagnostic pop
#endif
}; };

View file

@ -36,10 +36,7 @@
#ifdef THREADS_ENABLED #ifdef THREADS_ENABLED
#ifdef __clang__ GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wundefined-var-template")
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundefined-var-template"
#endif
// A very special kind of mutex, used in scenarios where these // A very special kind of mutex, used in scenarios where these
// requirements hold at the same time: // requirements hold at the same time:
@ -119,9 +116,7 @@ public:
// TODO: Implement a `try_temp_relock` if needed (will also need a dummy method below). // TODO: Implement a `try_temp_relock` if needed (will also need a dummy method below).
}; };
#ifdef __clang__ GODOT_CLANG_WARNING_POP
#pragma clang diagnostic pop
#endif
#else // No threads. #else // No threads.

View file

@ -92,14 +92,9 @@ public:
}; };
#if defined(__cpp_lib_hardware_interference_size) && !defined(ANDROID_ENABLED) // This would be OK with NDK >= 26. #if defined(__cpp_lib_hardware_interference_size) && !defined(ANDROID_ENABLED) // This would be OK with NDK >= 26.
#if defined(__GNUC__) && !defined(__clang__) GODOT_GCC_WARNING_PUSH_AND_IGNORE("-Winterference-size")
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Winterference-size"
#endif
static constexpr size_t CACHE_LINE_BYTES = std::hardware_destructive_interference_size; static constexpr size_t CACHE_LINE_BYTES = std::hardware_destructive_interference_size;
#if defined(__GNUC__) && !defined(__clang__) GODOT_GCC_WARNING_POP
#pragma GCC diagnostic pop
#endif
#else #else
// At a negligible memory cost, we use a conservatively high value. // At a negligible memory cost, we use a conservatively high value.
static constexpr size_t CACHE_LINE_BYTES = 128; static constexpr size_t CACHE_LINE_BYTES = 128;

View file

@ -49,11 +49,7 @@ class VMap;
static_assert(std::is_trivially_destructible_v<std::atomic<uint64_t>>); static_assert(std::is_trivially_destructible_v<std::atomic<uint64_t>>);
// Silence a false positive warning (see GH-52119). GODOT_GCC_WARNING_PUSH_AND_IGNORE("-Wplacement-new") // Silence a false positive warning (see GH-52119).
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wplacement-new"
#endif
template <typename T> template <typename T>
class CowData { class CowData {
@ -460,9 +456,7 @@ CowData<T>::CowData(std::initializer_list<T> p_init) {
} }
} }
#if defined(__GNUC__) && !defined(__clang__) GODOT_GCC_WARNING_POP
#pragma GCC diagnostic pop
#endif
// Zero-constructing CowData initializes _ptr to nullptr (and thus empty). // Zero-constructing CowData initializes _ptr to nullptr (and thus empty).
template <typename T> template <typename T>

View file

@ -33,18 +33,6 @@
#include "hash_map.h" #include "hash_map.h"
#include "list.h" #include "list.h"
#if defined(__GNUC__) && !defined(__clang__)
#define ADDRESS_DIAGNOSTIC_WARNING_DISABLE \
_Pragma("GCC diagnostic push"); \
_Pragma("GCC diagnostic ignored \"-Waddress\"");
#define ADDRESS_DIAGNOSTIC_POP \
_Pragma("GCC diagnostic pop");
#else
#define ADDRESS_DIAGNOSTIC_WARNING_DISABLE
#define ADDRESS_DIAGNOSTIC_POP
#endif
template <typename TKey, typename TData, typename Hasher = HashMapHasherDefault, typename Comparator = HashMapComparatorDefault<TKey>, void (*BeforeEvict)(TKey &, TData &) = nullptr> template <typename TKey, typename TData, typename Hasher = HashMapHasherDefault, typename Comparator = HashMapComparatorDefault<TKey>, void (*BeforeEvict)(TKey &, TData &) = nullptr>
class LRUCache { class LRUCache {
public: public:
@ -72,11 +60,11 @@ public:
Element n = _list.push_front(Pair(p_key, p_value)); Element n = _list.push_front(Pair(p_key, p_value));
if (e) { if (e) {
ADDRESS_DIAGNOSTIC_WARNING_DISABLE; GODOT_GCC_WARNING_PUSH_AND_IGNORE("-Waddress")
if constexpr (BeforeEvict != nullptr) { if constexpr (BeforeEvict != nullptr) {
BeforeEvict((*e)->get().key, (*e)->get().data); BeforeEvict((*e)->get().key, (*e)->get().data);
} }
ADDRESS_DIAGNOSTIC_POP; GODOT_GCC_WARNING_POP
_list.erase(*e); _list.erase(*e);
_map.erase(p_key); _map.erase(p_key);
} }
@ -84,11 +72,11 @@ public:
while (_map.size() > capacity) { while (_map.size() > capacity) {
Element d = _list.back(); Element d = _list.back();
ADDRESS_DIAGNOSTIC_WARNING_DISABLE GODOT_GCC_WARNING_PUSH_AND_IGNORE("-Waddress")
if constexpr (BeforeEvict != nullptr) { if constexpr (BeforeEvict != nullptr) {
BeforeEvict(d->get().key, d->get().data); BeforeEvict(d->get().key, d->get().data);
} }
ADDRESS_DIAGNOSTIC_POP GODOT_GCC_WARNING_POP
_map.erase(d->get().key); _map.erase(d->get().key);
_list.pop_back(); _list.pop_back();
} }
@ -141,11 +129,11 @@ public:
capacity = p_capacity; capacity = p_capacity;
while (_map.size() > capacity) { while (_map.size() > capacity) {
Element d = _list.back(); Element d = _list.back();
ADDRESS_DIAGNOSTIC_WARNING_DISABLE; GODOT_GCC_WARNING_PUSH_AND_IGNORE("-Waddress")
if constexpr (BeforeEvict != nullptr) { if constexpr (BeforeEvict != nullptr) {
BeforeEvict(d->get().key, d->get().data); BeforeEvict(d->get().key, d->get().data);
} }
ADDRESS_DIAGNOSTIC_POP; GODOT_GCC_WARNING_POP
_map.erase(d->get().key); _map.erase(d->get().key);
_list.pop_back(); _list.pop_back();
} }
@ -160,6 +148,3 @@ public:
capacity = p_capacity; capacity = p_capacity;
} }
}; };
#undef ADDRESS_DIAGNOSTIC_WARNING_DISABLE
#undef ADDRESS_DIAGNOSTIC_POP

View file

@ -344,3 +344,46 @@ struct is_zero_constructible<const volatile T> : is_zero_constructible<T> {};
template <typename T> template <typename T>
inline constexpr bool is_zero_constructible_v = is_zero_constructible<T>::value; inline constexpr bool is_zero_constructible_v = is_zero_constructible<T>::value;
// Warning suppression helper macros.
#if defined(__clang__)
#define GODOT_CLANG_PRAGMA(m_content) _Pragma(#m_content)
#define GODOT_CLANG_WARNING_PUSH GODOT_CLANG_PRAGMA(clang diagnostic push)
#define GODOT_CLANG_WARNING_IGNORE(m_warning) GODOT_CLANG_PRAGMA(clang diagnostic ignored m_warning)
#define GODOT_CLANG_WARNING_POP GODOT_CLANG_PRAGMA(clang diagnostic pop)
#define GODOT_CLANG_WARNING_PUSH_AND_IGNORE(m_warning) GODOT_CLANG_WARNING_PUSH GODOT_CLANG_WARNING_IGNORE(m_warning)
#else
#define GODOT_CLANG_PRAGMA(m_content)
#define GODOT_CLANG_WARNING_PUSH
#define GODOT_CLANG_WARNING_IGNORE(m_warning)
#define GODOT_CLANG_WARNING_POP
#define GODOT_CLANG_WARNING_PUSH_AND_IGNORE(m_warning)
#endif
#if defined(__GNUC__) && !defined(__clang__)
#define GODOT_GCC_PRAGMA(m_content) _Pragma(#m_content)
#define GODOT_GCC_WARNING_PUSH GODOT_GCC_PRAGMA(GCC diagnostic push)
#define GODOT_GCC_WARNING_IGNORE(m_warning) GODOT_GCC_PRAGMA(GCC diagnostic ignored m_warning)
#define GODOT_GCC_WARNING_POP GODOT_GCC_PRAGMA(GCC diagnostic pop)
#define GODOT_GCC_WARNING_PUSH_AND_IGNORE(m_warning) GODOT_GCC_WARNING_PUSH GODOT_GCC_WARNING_IGNORE(m_warning)
#else
#define GODOT_GCC_PRAGMA(m_content)
#define GODOT_GCC_WARNING_PUSH
#define GODOT_GCC_WARNING_IGNORE(m_warning)
#define GODOT_GCC_WARNING_POP
#define GODOT_GCC_WARNING_PUSH_AND_IGNORE(m_warning)
#endif
#if defined(_MSC_VER) && !defined(__clang__)
#define GODOT_MSVC_PRAGMA(m_command) __pragma(m_command)
#define GODOT_MSVC_WARNING_PUSH GODOT_MSVC_PRAGMA(warning(push))
#define GODOT_MSVC_WARNING_IGNORE(m_warning) GODOT_MSVC_PRAGMA(warning(disable : m_warning))
#define GODOT_MSVC_WARNING_POP GODOT_MSVC_PRAGMA(warning(pop))
#define GODOT_MSVC_WARNING_PUSH_AND_IGNORE(m_warning) GODOT_MSVC_WARNING_PUSH GODOT_MSVC_WARNING_IGNORE(m_warning)
#else
#define GODOT_MSVC_PRAGMA(m_command)
#define GODOT_MSVC_WARNING_PUSH
#define GODOT_MSVC_WARNING_IGNORE(m_warning)
#define GODOT_MSVC_WARNING_POP
#define GODOT_MSVC_WARNING_PUSH_AND_IGNORE(m_warning)
#endif

View file

@ -689,10 +689,7 @@ void call_with_validated_object_instance_args_static_retc(T *base, R (*p_method)
// GCC raises "parameter 'p_args' set but not used" when P = {}, // GCC raises "parameter 'p_args' set but not used" when P = {},
// it's not clever enough to treat other P values as making this branch valid. // it's not clever enough to treat other P values as making this branch valid.
#if defined(__GNUC__) && !defined(__clang__) GODOT_GCC_WARNING_PUSH_AND_IGNORE("-Wunused-but-set-parameter")
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-but-set-parameter"
#endif
template <typename Q> template <typename Q>
void call_get_argument_type_helper(int p_arg, int &index, Variant::Type &type) { void call_get_argument_type_helper(int p_arg, int &index, Variant::Type &type) {
@ -1033,6 +1030,4 @@ void call_with_variant_args_static_dv(void (*p_method)(P...), const Variant **p_
call_with_variant_args_static(p_method, args, r_error, BuildIndexSequence<sizeof...(P)>{}); call_with_variant_args_static(p_method, args, r_error, BuildIndexSequence<sizeof...(P)>{});
} }
#if defined(__GNUC__) && !defined(__clang__) GODOT_GCC_WARNING_POP
#pragma GCC diagnostic pop
#endif

View file

@ -1336,14 +1336,9 @@ RDD::TextureID RenderingDeviceDriverD3D12::texture_create(const TextureFormat &p
} }
tex_info->states_ptr = &tex_info->owner_info.states; tex_info->states_ptr = &tex_info->owner_info.states;
tex_info->format = p_format.format; tex_info->format = p_format.format;
#if defined(__GNUC__) && !defined(__clang__) GODOT_GCC_WARNING_PUSH_AND_IGNORE("-Wstrict-aliasing")
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
#endif
tex_info->desc = *(CD3DX12_RESOURCE_DESC *)&resource_desc; tex_info->desc = *(CD3DX12_RESOURCE_DESC *)&resource_desc;
#if defined(__GNUC__) && !defined(__clang__) GODOT_GCC_WARNING_POP
#pragma GCC diagnostic pop
#endif
tex_info->base_layer = 0; tex_info->base_layer = 0;
tex_info->layers = resource_desc.ArraySize(); tex_info->layers = resource_desc.ArraySize();
tex_info->base_mip = 0; tex_info->base_mip = 0;

View file

@ -50,8 +50,9 @@
/* permissions and limitations under the License. */ /* permissions and limitations under the License. */
/**************************************************************************/ /**************************************************************************/
#pragma clang diagnostic push #include "core/typedefs.h"
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wdeprecated-declarations")
#import "inflection_map.h" #import "inflection_map.h"
#import "metal_device_properties.h" #import "metal_device_properties.h"
@ -407,4 +408,4 @@ protected:
TightLocalVector<MTLFormatDesc> _mtl_vertex_format_descs; TightLocalVector<MTLFormatDesc> _mtl_vertex_format_descs;
}; };
#pragma clang diagnostic pop GODOT_CLANG_WARNING_POP

View file

@ -450,8 +450,7 @@ void PixelFormats::initDataFormatCapabilities() {
addDataFormatDesc(X8_D24_UNORM_PACK32, Invalid, Depth24Unorm_Stencil8, Invalid, Invalid, 1, 1, 4, DepthStencil); addDataFormatDesc(X8_D24_UNORM_PACK32, Invalid, Depth24Unorm_Stencil8, Invalid, Invalid, 1, 1, 4, DepthStencil);
#pragma clang diagnostic push GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wunguarded-availability")
#pragma clang diagnostic ignored "-Wunguarded-availability"
addDataFormatDesc(BC1_RGB_UNORM_BLOCK, BC1_RGBA, Invalid, Invalid, Invalid, 4, 4, 8, Compressed); addDataFormatDesc(BC1_RGB_UNORM_BLOCK, BC1_RGBA, Invalid, Invalid, Invalid, 4, 4, 8, Compressed);
addDataFormatDesc(BC1_RGB_SRGB_BLOCK, BC1_RGBA_sRGB, Invalid, Invalid, Invalid, 4, 4, 8, Compressed); addDataFormatDesc(BC1_RGB_SRGB_BLOCK, BC1_RGBA_sRGB, Invalid, Invalid, Invalid, 4, 4, 8, Compressed);
@ -476,7 +475,7 @@ void PixelFormats::initDataFormatCapabilities() {
addDataFormatDesc(BC7_UNORM_BLOCK, BC7_RGBAUnorm, Invalid, Invalid, Invalid, 4, 4, 16, Compressed); addDataFormatDesc(BC7_UNORM_BLOCK, BC7_RGBAUnorm, Invalid, Invalid, Invalid, 4, 4, 16, Compressed);
addDataFormatDesc(BC7_SRGB_BLOCK, BC7_RGBAUnorm_sRGB, Invalid, Invalid, Invalid, 4, 4, 16, Compressed); addDataFormatDesc(BC7_SRGB_BLOCK, BC7_RGBAUnorm_sRGB, Invalid, Invalid, Invalid, 4, 4, 16, Compressed);
#pragma clang diagnostic pop GODOT_CLANG_WARNING_POP
addDataFormatDesc(ETC2_R8G8B8_UNORM_BLOCK, ETC2_RGB8, Invalid, Invalid, Invalid, 4, 4, 8, Compressed); addDataFormatDesc(ETC2_R8G8B8_UNORM_BLOCK, ETC2_RGB8, Invalid, Invalid, Invalid, 4, 4, 8, Compressed);
addDataFormatDesc(ETC2_R8G8B8_SRGB_BLOCK, ETC2_RGB8_sRGB, Invalid, Invalid, Invalid, 4, 4, 8, Compressed); addDataFormatDesc(ETC2_R8G8B8_SRGB_BLOCK, ETC2_RGB8_sRGB, Invalid, Invalid, Invalid, 4, 4, 8, Compressed);
@ -729,8 +728,7 @@ void PixelFormats::initMTLPixelFormatCapabilities() {
addMTLPixelFormatDescSRGB(ASTC_12x12_sRGB, ASTC_12x12, RF, ASTC_12x12_LDR); addMTLPixelFormatDescSRGB(ASTC_12x12_sRGB, ASTC_12x12, RF, ASTC_12x12_LDR);
addMTLPixelFormatDesc(ASTC_12x12_HDR, ASTC_12x12, RF); addMTLPixelFormatDesc(ASTC_12x12_HDR, ASTC_12x12, RF);
#pragma clang diagnostic push GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wunguarded-availability")
#pragma clang diagnostic ignored "-Wunguarded-availability"
addMTLPixelFormatDesc(BC1_RGBA, BC1_RGBA, RF); addMTLPixelFormatDesc(BC1_RGBA, BC1_RGBA, RF);
addMTLPixelFormatDescSRGB(BC1_RGBA_sRGB, BC1_RGBA, RF, BC1_RGBA); addMTLPixelFormatDescSRGB(BC1_RGBA_sRGB, BC1_RGBA, RF, BC1_RGBA);
@ -747,7 +745,7 @@ void PixelFormats::initMTLPixelFormatCapabilities() {
addMTLPixelFormatDesc(BC7_RGBAUnorm, BC7_RGBA, RF); addMTLPixelFormatDesc(BC7_RGBAUnorm, BC7_RGBA, RF);
addMTLPixelFormatDescSRGB(BC7_RGBAUnorm_sRGB, BC7_RGBA, RF, BC7_RGBAUnorm); addMTLPixelFormatDescSRGB(BC7_RGBAUnorm_sRGB, BC7_RGBA, RF, BC7_RGBAUnorm);
#pragma clang diagnostic pop GODOT_CLANG_WARNING_POP
// YUV pixel formats // YUV pixel formats
addMTLPixelFormatDesc(GBGR422, None, RF); addMTLPixelFormatDesc(GBGR422, None, RF);
@ -968,8 +966,7 @@ void PixelFormats::modifyMTLFormatCapabilities(const MetalFeatures &p_feat) {
setMTLPixFmtCapsIf(noHDR_ASTC, ASTC_12x10_HDR, None); setMTLPixFmtCapsIf(noHDR_ASTC, ASTC_12x10_HDR, None);
setMTLPixFmtCapsIf(noHDR_ASTC, ASTC_12x12_HDR, None); setMTLPixFmtCapsIf(noHDR_ASTC, ASTC_12x12_HDR, None);
#pragma clang diagnostic push GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wunguarded-availability")
#pragma clang diagnostic ignored "-Wunguarded-availability"
bool noBC = !p_feat.supportsBCTextureCompression; bool noBC = !p_feat.supportsBCTextureCompression;
setMTLPixFmtCapsIf(noBC, BC1_RGBA, None); setMTLPixFmtCapsIf(noBC, BC1_RGBA, None);
@ -987,7 +984,7 @@ void PixelFormats::modifyMTLFormatCapabilities(const MetalFeatures &p_feat) {
setMTLPixFmtCapsIf(noBC, BC7_RGBAUnorm, None); setMTLPixFmtCapsIf(noBC, BC7_RGBAUnorm, None);
setMTLPixFmtCapsIf(noBC, BC7_RGBAUnorm_sRGB, None); setMTLPixFmtCapsIf(noBC, BC7_RGBAUnorm_sRGB, None);
#pragma clang diagnostic pop GODOT_CLANG_WARNING_POP
setMTLPixFmtCapsIf(iosOnly2, BGRA10_XR, None); setMTLPixFmtCapsIf(iosOnly2, BGRA10_XR, None);
setMTLPixFmtCapsIf(iosOnly2, BGRA10_XR_sRGB, None); setMTLPixFmtCapsIf(iosOnly2, BGRA10_XR_sRGB, None);

View file

@ -135,10 +135,7 @@ NetSocketUnix::~NetSocketUnix() {
// Silence a warning reported in GH-27594. // Silence a warning reported in GH-27594.
// EAGAIN and EWOULDBLOCK have the same value on most platforms, but it's not guaranteed. // EAGAIN and EWOULDBLOCK have the same value on most platforms, but it's not guaranteed.
#if defined(__GNUC__) && !defined(__clang__) GODOT_GCC_WARNING_PUSH_AND_IGNORE("-Wlogical-op")
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wlogical-op"
#endif
NetSocketUnix::NetError NetSocketUnix::_get_socket_error() const { NetSocketUnix::NetError NetSocketUnix::_get_socket_error() const {
if (errno == EISCONN) { if (errno == EISCONN) {
@ -163,9 +160,7 @@ NetSocketUnix::NetError NetSocketUnix::_get_socket_error() const {
return ERR_NET_OTHER; return ERR_NET_OTHER;
} }
#if defined(__GNUC__) && !defined(__clang__) GODOT_GCC_WARNING_POP
#pragma GCC diagnostic pop
#endif
bool NetSocketUnix::_can_use_ip(const IPAddress &p_ip, const bool p_for_bind) const { bool NetSocketUnix::_can_use_ip(const IPAddress &p_ip, const bool p_for_bind) const {
if (p_for_bind && !(p_ip.is_valid() || p_ip.is_wildcard())) { if (p_for_bind && !(p_ip.is_valid() || p_ip.is_wildcard())) {

View file

@ -126,11 +126,7 @@ static bool default_input_device_changed = false;
static int output_reinit_countdown = 0; static int output_reinit_countdown = 0;
static int input_reinit_countdown = 0; static int input_reinit_countdown = 0;
// Silence warning due to a COM API weirdness (GH-35194). GODOT_GCC_WARNING_PUSH_AND_IGNORE("-Wnon-virtual-dtor") // Silence warning due to a COM API weirdness (GH-35194).
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
#endif
class CMMNotificationClient : public IMMNotificationClient { class CMMNotificationClient : public IMMNotificationClient {
LONG _cRef = 1; LONG _cRef = 1;
@ -196,9 +192,7 @@ public:
} }
}; };
#if defined(__GNUC__) && !defined(__clang__) GODOT_GCC_WARNING_POP
#pragma GCC diagnostic pop
#endif
static CMMNotificationClient notif_client; static CMMNotificationClient notif_client;

View file

@ -76,11 +76,10 @@ DisplayServerIOS::DisplayServerIOS(const String &p_rendering_driver, WindowMode
RenderingContextDriverVulkanIOS::WindowPlatformData vulkan; RenderingContextDriverVulkanIOS::WindowPlatformData vulkan;
#endif #endif
#ifdef METAL_ENABLED #ifdef METAL_ENABLED
#pragma clang diagnostic push GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wunguarded-availability")
#pragma clang diagnostic ignored "-Wunguarded-availability"
// Eliminate "RenderingContextDriverMetal is only available on iOS 14.0 or newer". // Eliminate "RenderingContextDriverMetal is only available on iOS 14.0 or newer".
RenderingContextDriverMetal::WindowPlatformData metal; RenderingContextDriverMetal::WindowPlatformData metal;
#pragma clang diagnostic pop GODOT_CLANG_WARNING_POP
#endif #endif
} wpd; } wpd;

View file

@ -82,10 +82,9 @@ static const float earth_gravity = 9.80665;
layer = [GodotMetalLayer layer]; layer = [GodotMetalLayer layer];
#endif #endif
} else if ([driverName isEqualToString:@"opengl3"]) { } else if ([driverName isEqualToString:@"opengl3"]) {
#pragma clang diagnostic push GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wdeprecated-declarations") // OpenGL is deprecated in iOS 12.0.
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // OpenGL is deprecated in iOS 12.0
layer = [GodotOpenGLLayer layer]; layer = [GodotOpenGLLayer layer];
#pragma clang diagnostic pop GODOT_CLANG_WARNING_POP
} else { } else {
return nil; return nil;
} }

View file

@ -40,8 +40,7 @@
#import <ApplicationServices/ApplicationServices.h> #import <ApplicationServices/ApplicationServices.h>
#import <CoreVideo/CoreVideo.h> #import <CoreVideo/CoreVideo.h>
#pragma clang diagnostic push GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wdeprecated-declarations") // OpenGL is deprecated in macOS 10.14.
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // OpenGL is deprecated in macOS 10.14
typedef CGLError (*CGLEnablePtr)(CGLContextObj ctx, CGLContextEnable pname); typedef CGLError (*CGLEnablePtr)(CGLContextObj ctx, CGLContextEnable pname);
typedef CGLError (*CGLSetParameterPtr)(CGLContextObj ctx, CGLContextParameter pname, const GLint *params); typedef CGLError (*CGLSetParameterPtr)(CGLContextObj ctx, CGLContextParameter pname, const GLint *params);
@ -89,6 +88,6 @@ public:
~GLManagerLegacy_MacOS(); ~GLManagerLegacy_MacOS();
}; };
#pragma clang diagnostic push GODOT_CLANG_WARNING_PUSH
#endif // MACOS_ENABLED && GLES3_ENABLED #endif // MACOS_ENABLED && GLES3_ENABLED

View file

@ -36,8 +36,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#pragma clang diagnostic push GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wdeprecated-declarations") // OpenGL is deprecated in macOS 10.14.
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // OpenGL is deprecated in macOS 10.14
Error GLManagerLegacy_MacOS::create_context(GLWindow &win) { Error GLManagerLegacy_MacOS::create_context(GLWindow &win) {
NSOpenGLPixelFormatAttribute attributes[] = { NSOpenGLPixelFormatAttribute attributes[] = {
@ -204,6 +203,6 @@ GLManagerLegacy_MacOS::~GLManagerLegacy_MacOS() {
release_current(); release_current();
} }
#pragma clang diagnostic pop GODOT_CLANG_WARNING_POP
#endif // MACOS_ENABLED && GLES3_ENABLED #endif // MACOS_ENABLED && GLES3_ENABLED

View file

@ -54,8 +54,7 @@
@end @end
#pragma clang diagnostic push GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wdeprecated-declarations") // OpenGL is deprecated in macOS 10.14.
#pragma clang diagnostic ignored "-Wdeprecated-declarations" // OpenGL is deprecated in macOS 10.14
@interface GodotContentView : RootView <NSTextInputClient> { @interface GodotContentView : RootView <NSTextInputClient> {
DisplayServer::WindowID window_id; DisplayServer::WindowID window_id;
@ -78,4 +77,4 @@
@end @end
#pragma clang diagnostic pop GODOT_CLANG_WARNING_POP

View file

@ -322,11 +322,7 @@ Error DisplayServerWindows::file_dialog_with_options_show(const String &p_title,
return _file_dialog_with_options_show(p_title, p_current_directory, p_root, p_filename, p_show_hidden, p_mode, p_filters, p_options, p_callback, true, p_window_id); return _file_dialog_with_options_show(p_title, p_current_directory, p_root, p_filename, p_show_hidden, p_mode, p_filters, p_options, p_callback, true, p_window_id);
} }
// Silence warning due to a COM API weirdness. GODOT_GCC_WARNING_PUSH_AND_IGNORE("-Wnon-virtual-dtor") // Silence warning due to a COM API weirdness.
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
#endif
class FileDialogEventHandler : public IFileDialogEvents, public IFileDialogControlEvents { class FileDialogEventHandler : public IFileDialogEvents, public IFileDialogControlEvents {
LONG ref_count = 1; LONG ref_count = 1;
@ -445,9 +441,7 @@ public:
virtual ~FileDialogEventHandler() {} virtual ~FileDialogEventHandler() {}
}; };
#if defined(__GNUC__) && !defined(__clang__) GODOT_GCC_WARNING_POP
#pragma GCC diagnostic pop
#endif
LRESULT CALLBACK WndProcFileDialog(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { LRESULT CALLBACK WndProcFileDialog(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
DisplayServerWindows *ds_win = static_cast<DisplayServerWindows *>(DisplayServer::get_singleton()); DisplayServerWindows *ds_win = static_cast<DisplayServerWindows *>(DisplayServer::get_singleton());

View file

@ -34,11 +34,7 @@
#include <shlobj.h> #include <shlobj.h>
// Silence warning due to a COM API weirdness. GODOT_GCC_WARNING_PUSH_AND_IGNORE("-Wnon-virtual-dtor") // Silence warning due to a COM API weirdness.
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
#endif
// https://learn.microsoft.com/en-us/windows/win32/api/ole2/nf-ole2-dodragdrop#remarks // https://learn.microsoft.com/en-us/windows/win32/api/ole2/nf-ole2-dodragdrop#remarks
class DropTargetWindows : public IDropTarget { class DropTargetWindows : public IDropTarget {
@ -69,6 +65,4 @@ public:
HRESULT STDMETHODCALLTYPE Drop(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect) override; HRESULT STDMETHODCALLTYPE Drop(IDataObject *pDataObj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect) override;
}; };
#if defined(__GNUC__) && !defined(__clang__) GODOT_GCC_WARNING_POP
#pragma GCC diagnostic pop
#endif

View file

@ -1654,10 +1654,7 @@ Vector<String> OS_Windows::get_system_fonts() const {
return ret; return ret;
} }
#if defined(__GNUC__) && !defined(__clang__) GODOT_GCC_WARNING_PUSH_AND_IGNORE("-Wnon-virtual-dtor") // Silence warning due to a COM API weirdness.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
#endif
class FallbackTextAnalysisSource : public IDWriteTextAnalysisSource { class FallbackTextAnalysisSource : public IDWriteTextAnalysisSource {
LONG _cRef = 1; LONG _cRef = 1;
@ -1741,9 +1738,7 @@ public:
virtual ~FallbackTextAnalysisSource() {} virtual ~FallbackTextAnalysisSource() {}
}; };
#if defined(__GNUC__) && !defined(__clang__) GODOT_GCC_WARNING_POP
#pragma GCC diagnostic pop
#endif
String OS_Windows::_get_default_fontname(const String &p_font_name) const { String OS_Windows::_get_default_fontname(const String &p_font_name) const {
String font_name = p_font_name; String font_name = p_font_name;

View file

@ -1370,11 +1370,10 @@ bool DisplayServer::is_rendering_device_supported() {
#endif #endif
#ifdef METAL_ENABLED #ifdef METAL_ENABLED
if (rcd == nullptr) { if (rcd == nullptr) {
#pragma clang diagnostic push GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wunguarded-availability")
#pragma clang diagnostic ignored "-Wunguarded-availability"
// Eliminate "RenderingContextDriverMetal is only available on iOS 14.0 or newer". // Eliminate "RenderingContextDriverMetal is only available on iOS 14.0 or newer".
rcd = memnew(RenderingContextDriverMetal); rcd = memnew(RenderingContextDriverMetal);
#pragma clang diagnostic pop GODOT_CLANG_WARNING_POP
} }
#endif #endif
@ -1453,11 +1452,10 @@ bool DisplayServer::can_create_rendering_device() {
#endif #endif
#ifdef METAL_ENABLED #ifdef METAL_ENABLED
if (rcd == nullptr) { if (rcd == nullptr) {
#pragma clang diagnostic push GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wunguarded-availability")
#pragma clang diagnostic ignored "-Wunguarded-availability"
// Eliminate "RenderingContextDriverMetal is only available on iOS 14.0 or newer". // Eliminate "RenderingContextDriverMetal is only available on iOS 14.0 or newer".
rcd = memnew(RenderingContextDriverMetal); rcd = memnew(RenderingContextDriverMetal);
#pragma clang diagnostic pop GODOT_CLANG_WARNING_POP
} }
#endif #endif

View file

@ -51,8 +51,7 @@ MFXSpatialEffect::~MFXSpatialEffect() {
} }
void MFXSpatialEffect::callback(RDD *p_driver, RDD::CommandBufferID p_command_buffer, CallbackArgs *p_userdata) { void MFXSpatialEffect::callback(RDD *p_driver, RDD::CommandBufferID p_command_buffer, CallbackArgs *p_userdata) {
#pragma clang diagnostic push GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wunguarded-availability")
#pragma clang diagnostic ignored "-Wunguarded-availability"
MDCommandBuffer *obj = (MDCommandBuffer *)(p_command_buffer.id); MDCommandBuffer *obj = (MDCommandBuffer *)(p_command_buffer.id);
obj->end(); obj->end();
@ -73,7 +72,7 @@ void MFXSpatialEffect::callback(RDD *p_driver, RDD::CommandBufferID p_command_bu
CallbackArgs::free(&p_userdata); CallbackArgs::free(&p_userdata);
#pragma clang diagnostic pop GODOT_CLANG_WARNING_POP
} }
void MFXSpatialEffect::ensure_context(Ref<RenderSceneBuffersRD> p_render_buffers) { void MFXSpatialEffect::ensure_context(Ref<RenderSceneBuffersRD> p_render_buffers) {
@ -99,8 +98,7 @@ void MFXSpatialEffect::process(Ref<RenderSceneBuffersRD> p_render_buffers, RID p
MFXSpatialContext *MFXSpatialEffect::create_context(CreateParams p_params) const { MFXSpatialContext *MFXSpatialEffect::create_context(CreateParams p_params) const {
DEV_ASSERT(RD::get_singleton()->has_feature(RD::SUPPORTS_METALFX_SPATIAL)); DEV_ASSERT(RD::get_singleton()->has_feature(RD::SUPPORTS_METALFX_SPATIAL));
#pragma clang diagnostic push GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wunguarded-availability")
#pragma clang diagnostic ignored "-Wunguarded-availability"
RenderingDeviceDriverMetal *rdd = (RenderingDeviceDriverMetal *)RD::get_singleton()->get_device_driver(); RenderingDeviceDriverMetal *rdd = (RenderingDeviceDriverMetal *)RD::get_singleton()->get_device_driver();
PixelFormats &pf = rdd->get_pixel_formats(); PixelFormats &pf = rdd->get_pixel_formats();
@ -120,7 +118,7 @@ MFXSpatialContext *MFXSpatialEffect::create_context(CreateParams p_params) const
MFXSpatialContext *context = memnew(MFXSpatialContext); MFXSpatialContext *context = memnew(MFXSpatialContext);
context->scaler = scaler; context->scaler = scaler;
#pragma clang diagnostic pop GODOT_CLANG_WARNING_POP
return context; return context;
} }
@ -135,8 +133,7 @@ MFXTemporalEffect::~MFXTemporalEffect() {}
MFXTemporalContext *MFXTemporalEffect::create_context(CreateParams p_params) const { MFXTemporalContext *MFXTemporalEffect::create_context(CreateParams p_params) const {
DEV_ASSERT(RD::get_singleton()->has_feature(RD::SUPPORTS_METALFX_TEMPORAL)); DEV_ASSERT(RD::get_singleton()->has_feature(RD::SUPPORTS_METALFX_TEMPORAL));
#pragma clang diagnostic push GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wunguarded-availability")
#pragma clang diagnostic ignored "-Wunguarded-availability"
RenderingDeviceDriverMetal *rdd = (RenderingDeviceDriverMetal *)RD::get_singleton()->get_device_driver(); RenderingDeviceDriverMetal *rdd = (RenderingDeviceDriverMetal *)RD::get_singleton()->get_device_driver();
PixelFormats &pf = rdd->get_pixel_formats(); PixelFormats &pf = rdd->get_pixel_formats();
@ -164,7 +161,7 @@ MFXTemporalContext *MFXTemporalEffect::create_context(CreateParams p_params) con
scaler.motionVectorScaleY = p_params.motion_vector_scale.y; scaler.motionVectorScaleY = p_params.motion_vector_scale.y;
scaler.depthReversed = true; // Godot uses reverse Z per https://github.com/godotengine/godot/pull/88328 scaler.depthReversed = true; // Godot uses reverse Z per https://github.com/godotengine/godot/pull/88328
#pragma clang diagnostic pop GODOT_CLANG_WARNING_POP
return context; return context;
} }
@ -189,8 +186,7 @@ void MFXTemporalEffect::process(RendererRD::MFXTemporalContext *p_ctx, RendererR
} }
void MFXTemporalEffect::callback(RDD *p_driver, RDD::CommandBufferID p_command_buffer, CallbackArgs *p_userdata) { void MFXTemporalEffect::callback(RDD *p_driver, RDD::CommandBufferID p_command_buffer, CallbackArgs *p_userdata) {
#pragma clang diagnostic push GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wunguarded-availability")
#pragma clang diagnostic ignored "-Wunguarded-availability"
MDCommandBuffer *obj = (MDCommandBuffer *)(p_command_buffer.id); MDCommandBuffer *obj = (MDCommandBuffer *)(p_command_buffer.id);
obj->end(); obj->end();
@ -221,5 +217,5 @@ void MFXTemporalEffect::callback(RDD *p_driver, RDD::CommandBufferID p_command_b
CallbackArgs::free(&p_userdata); CallbackArgs::free(&p_userdata);
#pragma clang diagnostic pop GODOT_CLANG_WARNING_POP
} }