From d84482791a16c3c73ef0b193f38a96a66217ee5e Mon Sep 17 00:00:00 2001 From: Thaddeus Crews Date: Mon, 23 Dec 2024 20:08:12 -0600 Subject: [PATCH] Core: Bump C++ Standard to C++20 --- SConstruct | 78 ++++++------------- core/math/rect2.cpp | 7 ++ core/math/rect2.h | 3 + core/math/vector2.cpp | 19 +++++ core/math/vector2.h | 7 ++ core/math/vector3.cpp | 19 +++++ core/math/vector3.h | 7 ++ core/math/vector4.cpp | 19 +++++ core/math/vector4.h | 7 ++ core/object/ref_counted.h | 21 +++-- core/os/spin_lock.h | 2 +- core/typedefs.h | 4 +- core/variant/variant.h | 63 +++++++++++++++ drivers/metal/SCsub | 5 -- .../basis_universal/image_compress_basisu.cpp | 5 ++ modules/mono/mono_gc_handle.h | 8 +- thirdparty/README.md | 4 + .../patches/0001-anonymous-constructor.patch | 17 ++++ thirdparty/re-spirv/re-spirv.cpp | 6 +- .../0004-cpp20-explicit-namespace.patch | 24 ++++++ .../src/loaders/svg/tvgSvgSceneBuilder.cpp | 2 +- .../src/renderer/sw_engine/tvgSwFill.cpp | 4 +- thirdparty/thorvg/src/renderer/tvgPaint.cpp | 2 +- 23 files changed, 257 insertions(+), 76 deletions(-) create mode 100644 thirdparty/re-spirv/patches/0001-anonymous-constructor.patch create mode 100644 thirdparty/thorvg/patches/0004-cpp20-explicit-namespace.patch diff --git a/SConstruct b/SConstruct index f2934251030b..00dfd22155c5 100644 --- a/SConstruct +++ b/SConstruct @@ -709,16 +709,16 @@ cc_version_metadata1 = cc_version["metadata1"] if cc_version_major == -1: print_warning( - "Couldn't detect compiler version, skipping version checks. " - "Build may fail if the compiler doesn't support C++17 fully." + "Couldn't detect compiler version, skipping version checks. Build may " + "fail if the compiler doesn't support C++20 fully." ) elif methods.using_gcc(env): - if cc_version_major < 9: + if cc_version_major < 11: print_error( - "Detected GCC version older than 9, which does not fully support " - "C++17, or has bugs when compiling Godot. Supported versions are 9 " - "and later. Use a newer GCC version, or Clang 6 or later by passing " - '"use_llvm=yes" to the SCons command line.' + "Detected GCC version older than 11, which does not fully support " + "C++20. Supported versions are GCC 11 and later. Use a newer GCC " + 'version, or Clang 13 or later by passing "use_llvm=yes" to the ' + "SCons command line." ) Exit(255) elif cc_version_metadata1 == "win32": @@ -739,35 +739,24 @@ elif methods.using_clang(env): ) Exit(255) else: - if cc_version_major < 6: + if cc_version_major < 13: print_error( - "Detected Clang version older than 6, which does not fully support " - "C++17. Supported versions are Clang 6 and later." + "Detected Clang version older than 13, which does not fully support " + "C++20. Supported versions are Clang 13 and later." ) Exit(255) - elif env["debug_paths_relative"] and cc_version_major < 10: - print_warning("Clang < 10 doesn't support -ffile-prefix-map, disabling `debug_paths_relative` option.") - env["debug_paths_relative"] = False elif env.msvc: - # Ensure latest minor builds of Visual Studio 2017/2019. - # https://github.com/godotengine/godot/pull/94995#issuecomment-2336464574 - if cc_version_major == 16 and cc_version_minor < 11: - print_error( - "Detected Visual Studio 2019 version older than 16.11, which has bugs " - "when compiling Godot. Use a newer VS2019 version, or VS2022." - ) - Exit(255) - if cc_version_major == 15 and cc_version_minor < 9: + if cc_version_major < 16: print_error( - "Detected Visual Studio 2017 version older than 15.9, which has bugs " - "when compiling Godot. Use a newer VS2017 version, or VS2019/VS2022." + "Detected Visual Studio version older than 2019, which does not fully " + "support C++20. Supported versions are Visual Studio 2019 and later." ) Exit(255) - if cc_version_major < 15: + elif cc_version_major == 16 and cc_version_minor < 11: print_error( - "Detected Visual Studio 2015 or earlier, which is unsupported in Godot. " - "Supported versions are Visual Studio 2017 and later." + "Detected Visual Studio 2019 version older than 16.11, which does not " + "fully support C++20. Use a newer VS2019 version, or VS2022." ) Exit(255) @@ -885,22 +874,17 @@ if env["lto"] != "none": print("Using LTO: " + env["lto"]) # Set our C and C++ standard requirements. -# C++17 is required as we need guaranteed copy elision as per GH-36436. -# Prepending to make it possible to override. # This needs to come after `configure`, otherwise we don't have env.msvc. if not env.msvc: # Specifying GNU extensions support explicitly, which are supported by - # both GCC and Clang. Both currently default to gnu17 and gnu++17. + # both GCC and Clang. Both currently default to gnu17 and gnu++20. env.Prepend(CFLAGS=["-std=gnu17"]) - env.Prepend(CXXFLAGS=["-std=gnu++17"]) + env.Prepend(CXXFLAGS=["-std=gnu++20"]) else: # MSVC started offering C standard support with Visual Studio 2019 16.8, which covers all - # of our supported VS2019 & VS2022 versions; VS2017 will only pass the C++ standard. - env.Prepend(CXXFLAGS=["/std:c++17"]) - if cc_version_major < 16: - print_warning("Visual Studio 2017 cannot specify a C-Standard.") - else: - env.Prepend(CFLAGS=["/std:c17"]) + # of our supported VS2019 & VS2022 versions. + env.Prepend(CFLAGS=["/std:c17"]) + env.Prepend(CXXFLAGS=["/std:c++20"]) # MSVC is non-conforming with the C++ standard by default, so we enable more conformance. # Note that this is still not complete conformance, as certain Windows-related headers # don't compile under complete conformance. @@ -958,22 +942,15 @@ if env.msvc and not methods.using_clang(env): # MSVC else: # GCC, Clang common_warnings = [] if methods.using_gcc(env): - common_warnings += ["-Wshadow", "-Wno-misleading-indentation"] - 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"] + common_warnings += ["-Wshadow", "-Wno-misleading-indentation", "-Wenum-conversion"] if cc_version_major == 12: # Regression in GCC 12, false positives in our error macros, see GH-58747. common_warnings += ["-Wno-return-type"] - if cc_version_major >= 11: - common_warnings += ["-Wenum-conversion"] elif methods.using_clang(env) or methods.using_emcc(env): - common_warnings += ["-Wshadow-field-in-constructor", "-Wshadow-uncaptured-local"] + common_warnings += ["-Wshadow-field-in-constructor", "-Wshadow-uncaptured-local", "-Wenum-conversion"] # 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. common_warnings += ["-Wno-ordered-compare-function-pointers"] - common_warnings += ["-Wenum-conversion"] # clang-cl will interpret `-Wall` as `-Weverything`, workaround with compatibility cast. env["WARNLEVEL"] = "-Wall" if not env.msvc else "-W3" @@ -985,19 +962,14 @@ else: # GCC, Clang env.AppendUnique( CCFLAGS=[ "-Walloc-zero", + "-Wattribute-alias=2", "-Wduplicated-branches", "-Wduplicated-cond", + "-Wlogical-op", "-Wstringop-overflow=4", ] ) env.AppendUnique(CXXFLAGS=["-Wplacement-new=1", "-Wvirtual-inheritance"]) - # 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.AppendUnique(CCFLAGS=["-Wattribute-alias=2"]) - if cc_version_major >= 11: # Broke on MethodBind templates before GCC 11. - env.AppendUnique(CCFLAGS=["-Wlogical-op"]) elif methods.using_clang(env) or methods.using_emcc(env): env.AppendUnique(CCFLAGS=["-Wimplicit-fallthrough"]) elif env["warnings"] == "all": diff --git a/core/math/rect2.cpp b/core/math/rect2.cpp index 102a9e4b5410..0356136d5b02 100644 --- a/core/math/rect2.cpp +++ b/core/math/rect2.cpp @@ -293,3 +293,10 @@ Rect2::operator String() const { Rect2::operator Rect2i() const { return Rect2i(position, size); } + +bool Rect2::operator==(const Rect2i &p_rect2i) const { + return operator==(Rect2(p_rect2i)); +} +bool Rect2::operator!=(const Rect2i &p_rect2i) const { + return operator!=(Rect2(p_rect2i)); +} diff --git a/core/math/rect2.h b/core/math/rect2.h index 2ba59fde3529..a72036cb7be6 100644 --- a/core/math/rect2.h +++ b/core/math/rect2.h @@ -209,6 +209,9 @@ struct [[nodiscard]] Rect2 { constexpr bool operator==(const Rect2 &p_rect) const { return position == p_rect.position && size == p_rect.size; } constexpr bool operator!=(const Rect2 &p_rect) const { return position != p_rect.position || size != p_rect.size; } + bool operator==(const Rect2i &p_rect2i) const; + bool operator!=(const Rect2i &p_rect2i) const; + inline Rect2 grow(real_t p_amount) const { Rect2 g = *this; g.grow_by(p_amount); diff --git a/core/math/vector2.cpp b/core/math/vector2.cpp index 7a51c1394543..42a8dbb8b676 100644 --- a/core/math/vector2.cpp +++ b/core/math/vector2.cpp @@ -213,3 +213,22 @@ Vector2::operator String() const { Vector2::operator Vector2i() const { return Vector2i(x, y); } + +bool Vector2::operator==(const Vector2i &p_vector2i) const { + return operator==(Vector2(p_vector2i)); +} +bool Vector2::operator!=(const Vector2i &p_vector2i) const { + return operator!=(Vector2(p_vector2i)); +} +bool Vector2::operator<(const Vector2i &p_vector2i) const { + return operator<(Vector2(p_vector2i)); +} +bool Vector2::operator>(const Vector2i &p_vector2i) const { + return operator>(Vector2(p_vector2i)); +} +bool Vector2::operator<=(const Vector2i &p_vector2i) const { + return operator<=(Vector2(p_vector2i)); +} +bool Vector2::operator>=(const Vector2i &p_vector2i) const { + return operator>=(Vector2(p_vector2i)); +} diff --git a/core/math/vector2.h b/core/math/vector2.h index 98207474a3b0..ba6bf3b4fa6c 100644 --- a/core/math/vector2.h +++ b/core/math/vector2.h @@ -166,6 +166,13 @@ struct [[nodiscard]] Vector2 { constexpr bool operator<=(const Vector2 &p_vec2) const { return x == p_vec2.x ? (y <= p_vec2.y) : (x < p_vec2.x); } constexpr bool operator>=(const Vector2 &p_vec2) const { return x == p_vec2.x ? (y >= p_vec2.y) : (x > p_vec2.x); } + bool operator==(const Vector2i &p_vector2i) const; + bool operator!=(const Vector2i &p_vector2i) const; + bool operator<(const Vector2i &p_vector2i) const; + bool operator>(const Vector2i &p_vector2i) const; + bool operator<=(const Vector2i &p_vector2i) const; + bool operator>=(const Vector2i &p_vector2i) const; + real_t angle() const; static Vector2 from_angle(real_t p_angle); diff --git a/core/math/vector3.cpp b/core/math/vector3.cpp index 336cd9ba26e0..b205d216b105 100644 --- a/core/math/vector3.cpp +++ b/core/math/vector3.cpp @@ -161,3 +161,22 @@ Vector3::operator String() const { Vector3::operator Vector3i() const { return Vector3i(x, y, z); } + +bool Vector3::operator==(const Vector3i &p_vector3i) const { + return operator==(Vector3(p_vector3i)); +} +bool Vector3::operator!=(const Vector3i &p_vector3i) const { + return operator!=(Vector3(p_vector3i)); +} +bool Vector3::operator<(const Vector3i &p_vector3i) const { + return operator<(Vector3(p_vector3i)); +} +bool Vector3::operator>(const Vector3i &p_vector3i) const { + return operator>(Vector3(p_vector3i)); +} +bool Vector3::operator<=(const Vector3i &p_vector3i) const { + return operator<=(Vector3(p_vector3i)); +} +bool Vector3::operator>=(const Vector3i &p_vector3i) const { + return operator>=(Vector3(p_vector3i)); +} diff --git a/core/math/vector3.h b/core/math/vector3.h index b0f29e0d566d..140977c429c6 100644 --- a/core/math/vector3.h +++ b/core/math/vector3.h @@ -211,6 +211,13 @@ struct [[nodiscard]] Vector3 { constexpr bool operator>(const Vector3 &p_v) const; constexpr bool operator>=(const Vector3 &p_v) const; + bool operator==(const Vector3i &p_vector3i) const; + bool operator!=(const Vector3i &p_vector3i) const; + bool operator<(const Vector3i &p_vector3i) const; + bool operator>(const Vector3i &p_vector3i) const; + bool operator<=(const Vector3i &p_vector3i) const; + bool operator>=(const Vector3i &p_vector3i) const; + explicit operator String() const; operator Vector3i() const; diff --git a/core/math/vector4.cpp b/core/math/vector4.cpp index e4fa1769c018..26e374456023 100644 --- a/core/math/vector4.cpp +++ b/core/math/vector4.cpp @@ -225,3 +225,22 @@ static_assert(sizeof(Vector4) == 4 * sizeof(real_t)); Vector4::operator Vector4i() const { return Vector4i(x, y, z, w); } + +bool Vector4::operator==(const Vector4i &p_vector4i) const { + return operator==(Vector4(p_vector4i)); +} +bool Vector4::operator!=(const Vector4i &p_vector4i) const { + return operator!=(Vector4(p_vector4i)); +} +bool Vector4::operator<(const Vector4i &p_vector4i) const { + return operator<(Vector4(p_vector4i)); +} +bool Vector4::operator>(const Vector4i &p_vector4i) const { + return operator>(Vector4(p_vector4i)); +} +bool Vector4::operator<=(const Vector4i &p_vector4i) const { + return operator<=(Vector4(p_vector4i)); +} +bool Vector4::operator>=(const Vector4i &p_vector4i) const { + return operator>=(Vector4(p_vector4i)); +} diff --git a/core/math/vector4.h b/core/math/vector4.h index edfe28b07718..ae2bc08e9a59 100644 --- a/core/math/vector4.h +++ b/core/math/vector4.h @@ -144,6 +144,13 @@ struct [[nodiscard]] Vector4 { constexpr bool operator>=(const Vector4 &p_vec4) const; constexpr bool operator<=(const Vector4 &p_vec4) const; + bool operator==(const Vector4i &p_vector4i) const; + bool operator!=(const Vector4i &p_vector4i) const; + bool operator<(const Vector4i &p_vector4i) const; + bool operator>(const Vector4i &p_vector4i) const; + bool operator<=(const Vector4i &p_vector4i) const; + bool operator>=(const Vector4i &p_vector4i) const; + explicit operator String() const; operator Vector4i() const; diff --git a/core/object/ref_counted.h b/core/object/ref_counted.h index ea2eb49f3254..53a44836fa55 100644 --- a/core/object/ref_counted.h +++ b/core/object/ref_counted.h @@ -90,10 +90,12 @@ class Ref { return T::get_class_static(); } - _FORCE_INLINE_ bool operator==(const T *p_ptr) const { + template + _FORCE_INLINE_ bool operator==(const T_Other *p_ptr) const { return reference == p_ptr; } - _FORCE_INLINE_ bool operator!=(const T *p_ptr) const { + template + _FORCE_INLINE_ bool operator!=(const T_Other *p_ptr) const { return reference != p_ptr; } #ifdef STRICT_CHECKS @@ -102,14 +104,17 @@ class Ref { bool operator!=(std::nullptr_t) const = delete; #endif // STRICT_CHECKS - _FORCE_INLINE_ bool operator<(const Ref &p_r) const { - return reference < p_r.reference; + template + _FORCE_INLINE_ bool operator<(const Ref &p_ref) const { + return reference < p_ref.ptr(); } - _FORCE_INLINE_ bool operator==(const Ref &p_r) const { - return reference == p_r.reference; + template + _FORCE_INLINE_ bool operator==(const Ref &p_ref) const { + return reference == p_ref.ptr(); } - _FORCE_INLINE_ bool operator!=(const Ref &p_r) const { - return reference != p_r.reference; + template + _FORCE_INLINE_ bool operator!=(const Ref &p_ref) const { + return reference != p_ref.ptr(); } _FORCE_INLINE_ T *operator*() const { diff --git a/core/os/spin_lock.h b/core/os/spin_lock.h index 7a5051035373..f496429d7500 100644 --- a/core/os/spin_lock.h +++ b/core/os/spin_lock.h @@ -93,7 +93,7 @@ static_assert(std::atomic_bool::is_always_lock_free); class SpinLock { union { - mutable std::atomic locked = ATOMIC_VAR_INIT(false); + mutable std::atomic locked = false; char aligner[Thread::CACHE_LINE_BYTES]; }; diff --git a/core/typedefs.h b/core/typedefs.h index 39edec5a5cb5..0a709d2f16b2 100644 --- a/core/typedefs.h +++ b/core/typedefs.h @@ -36,9 +36,9 @@ // IWYU pragma: always_keep -// Ensure that C++ standard is at least C++17. +// Ensure that C++ standard is at least C++20. // If on MSVC, also ensures that the `Zc:__cplusplus` flag is present. -static_assert(__cplusplus >= 201703L, "Minimum of C++17 required."); +static_assert(__cplusplus >= 202002L, "Minimum of C++20 required."); // IWYU pragma: begin_exports diff --git a/core/variant/variant.h b/core/variant/variant.h index d20e2e685ff2..d878844e58e6 100644 --- a/core/variant/variant.h +++ b/core/variant/variant.h @@ -843,6 +843,69 @@ class Variant { uint32_t hash() const; uint32_t recursive_hash(int recursion_count) const; + // FIXME: Starting with C++20, the above comparison operators are no longer sufficient for comparison + // with non-Variant types. While this should eventually get a pass to make those ambiguous situations + // use explicit calls, these additional operators serve as a temporary workaround to restore the + // previous behavior. + _FORCE_INLINE_ bool operator==(bool p_bool) const { return operator==(Variant(p_bool)); } + _FORCE_INLINE_ bool operator==(int64_t p_int64) const { return operator==(Variant(p_int64)); } + _FORCE_INLINE_ bool operator==(int32_t p_int32) const { return operator==(Variant(p_int32)); } + _FORCE_INLINE_ bool operator==(int16_t p_int16) const { return operator==(Variant(p_int16)); } + _FORCE_INLINE_ bool operator==(int8_t p_int8) const { return operator==(Variant(p_int8)); } + _FORCE_INLINE_ bool operator==(uint64_t p_uint64) const { return operator==(Variant(p_uint64)); } + _FORCE_INLINE_ bool operator==(uint32_t p_uint32) const { return operator==(Variant(p_uint32)); } + _FORCE_INLINE_ bool operator==(uint16_t p_uint16) const { return operator==(Variant(p_uint16)); } + _FORCE_INLINE_ bool operator==(uint8_t p_uint8) const { return operator==(Variant(p_uint8)); } + _FORCE_INLINE_ bool operator==(double p_double) const { return operator==(Variant(p_double)); } + _FORCE_INLINE_ bool operator==(float p_float) const { return operator==(Variant(p_float)); } + _FORCE_INLINE_ bool operator==(const String &p_string) const { return operator==(Variant(p_string)); } + _FORCE_INLINE_ bool operator==(const char *p_cstring) const { return operator==(Variant(p_cstring)); } + _FORCE_INLINE_ bool operator==(char32_t p_char32) const { return operator==(Variant(p_char32)); } + _FORCE_INLINE_ bool operator==(const Vector2 &p_vector2) const { return operator==(Variant(p_vector2)); } + _FORCE_INLINE_ bool operator==(const Vector2i &p_vector2i) const { return operator==(Variant(p_vector2i)); } + _FORCE_INLINE_ bool operator==(const Rect2 &p_rect2) const { return operator==(Variant(p_rect2)); } + _FORCE_INLINE_ bool operator==(const Rect2i &p_rect2i) const { return operator==(Variant(p_rect2i)); } + _FORCE_INLINE_ bool operator==(const Vector3 &p_vector3) const { return operator==(Variant(p_vector3)); } + _FORCE_INLINE_ bool operator==(const Vector3i &p_vector3i) const { return operator==(Variant(p_vector3i)); } + _FORCE_INLINE_ bool operator==(const Transform2D &p_transform_2d) const { return operator==(Variant(p_transform_2d)); } + _FORCE_INLINE_ bool operator==(const Vector4 &p_vector4) const { return operator==(Variant(p_vector4)); } + _FORCE_INLINE_ bool operator==(const Vector4i &p_vector4i) const { return operator==(Variant(p_vector4i)); } + _FORCE_INLINE_ bool operator==(const Plane &p_plane) const { return operator==(Variant(p_plane)); } + _FORCE_INLINE_ bool operator==(const Quaternion &p_quaternion) const { return operator==(Variant(p_quaternion)); } + _FORCE_INLINE_ bool operator==(const ::AABB &p_aabb) const { return operator==(Variant(p_aabb)); } + _FORCE_INLINE_ bool operator==(const Basis &p_basis) const { return operator==(Variant(p_basis)); } + _FORCE_INLINE_ bool operator==(const Transform3D &p_transform_3d) const { return operator==(Variant(p_transform_3d)); } + _FORCE_INLINE_ bool operator==(const Projection &p_projection) const { return operator==(Variant(p_projection)); } + _FORCE_INLINE_ bool operator==(const Color &p_color) const { return operator==(Variant(p_color)); } + _FORCE_INLINE_ bool operator==(const StringName &p_string_name) const { return operator==(Variant(p_string_name)); } + _FORCE_INLINE_ bool operator==(const NodePath &p_node_path) const { return operator==(Variant(p_node_path)); } + _FORCE_INLINE_ bool operator==(const ::RID &p_rid) const { return operator==(Variant(p_rid)); } + template , int> = 0> + _FORCE_INLINE_ bool operator==(const T *p_object) const { return operator==(Variant(p_object)); } + template , int> = 0> + _FORCE_INLINE_ bool operator==(const Ref &p_ref) const { return operator==(Variant(p_ref)); } + _FORCE_INLINE_ bool operator==(const ObjectID &p_object_id) const { return operator==(Variant(p_object_id)); } + _FORCE_INLINE_ bool operator==(const Callable &p_callable) const { return operator==(Variant(p_callable)); } + _FORCE_INLINE_ bool operator==(const Signal &p_signal) const { return operator==(Variant(p_signal)); } + _FORCE_INLINE_ bool operator==(const Dictionary &p_dictionary) const { return operator==(Variant(p_dictionary)); } + _FORCE_INLINE_ bool operator==(const Array &p_array) const { return operator==(Variant(p_array)); } + _FORCE_INLINE_ bool operator==(const PackedByteArray &p_packed_byte_array) const { return operator==(Variant(p_packed_byte_array)); } + _FORCE_INLINE_ bool operator==(const PackedInt32Array &p_packed_int32_array) const { return operator==(Variant(p_packed_int32_array)); } + _FORCE_INLINE_ bool operator==(const PackedInt64Array &p_packed_int64_array) const { return operator==(Variant(p_packed_int64_array)); } + _FORCE_INLINE_ bool operator==(const PackedFloat32Array &p_packed_float32_array) const { return operator==(Variant(p_packed_float32_array)); } + _FORCE_INLINE_ bool operator==(const PackedFloat64Array &p_packed_float64_array) const { return operator==(Variant(p_packed_float64_array)); } + _FORCE_INLINE_ bool operator==(const PackedStringArray &p_packed_string_array) const { return operator==(Variant(p_packed_string_array)); } + _FORCE_INLINE_ bool operator==(const PackedVector2Array &p_packed_vector2_array) const { return operator==(Variant(p_packed_vector2_array)); } + _FORCE_INLINE_ bool operator==(const PackedVector3Array &p_packed_vector3_array) const { return operator==(Variant(p_packed_vector3_array)); } + _FORCE_INLINE_ bool operator==(const PackedColorArray &p_packed_color_array) const { return operator==(Variant(p_packed_color_array)); } + _FORCE_INLINE_ bool operator==(const PackedVector4Array &p_packed_vector4_array) const { return operator==(Variant(p_packed_vector4_array)); } + _FORCE_INLINE_ bool operator==(const Vector<::RID> &p_vector_rid) const { return operator==(Variant(p_vector_rid)); } + _FORCE_INLINE_ bool operator==(const Vector &p_vector_plane) const { return operator==(Variant(p_vector_plane)); } + _FORCE_INLINE_ bool operator==(const Vector &p_vector_face) const { return operator==(Variant(p_vector_face)); } + _FORCE_INLINE_ bool operator==(const Vector &p_vector_variant) const { return operator==(Variant(p_vector_variant)); } + _FORCE_INLINE_ bool operator==(const Vector &p_vector_string_name) const { return operator==(Variant(p_vector_string_name)); } + _FORCE_INLINE_ bool operator==(const IPAddress &p_ip_address) const { return operator==(Variant(p_ip_address)); } + // By default, performs a semantic comparison. Otherwise, numeric/binary comparison (if appropriate). bool hash_compare(const Variant &p_variant, int recursion_count = 0, bool semantic_comparison = true) const; bool identity_compare(const Variant &p_variant) const; diff --git a/drivers/metal/SCsub b/drivers/metal/SCsub index 8f85363072c6..52fbc0a77968 100644 --- a/drivers/metal/SCsub +++ b/drivers/metal/SCsub @@ -44,11 +44,6 @@ env_thirdparty.disable_warnings() env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources) env_metal.drivers_sources += thirdparty_obj -# Enable C++20 for the Objective-C++ Metal code, which uses C++20 concepts. -if "-std=gnu++17" in env_metal["CXXFLAGS"]: - env_metal["CXXFLAGS"].remove("-std=gnu++17") -env_metal.Append(CXXFLAGS=["-std=gnu++20"]) - # Enable module support env_metal.Append(CCFLAGS=["-fmodules", "-fcxx-modules"]) diff --git a/modules/basis_universal/image_compress_basisu.cpp b/modules/basis_universal/image_compress_basisu.cpp index 4ef0ab95761b..dd89debb0f95 100644 --- a/modules/basis_universal/image_compress_basisu.cpp +++ b/modules/basis_universal/image_compress_basisu.cpp @@ -37,9 +37,12 @@ #include "servers/rendering/rendering_server.h" GODOT_GCC_WARNING_PUSH +GODOT_GCC_WARNING_IGNORE("-Wdeprecated-enum-enum-conversion") GODOT_GCC_WARNING_IGNORE("-Wenum-conversion") GODOT_GCC_WARNING_IGNORE("-Wshadow") GODOT_GCC_WARNING_IGNORE("-Wunused-value") +GODOT_CLANG_WARNING_PUSH_AND_IGNORE("-Wdeprecated-anon-enum-enum-conversion") +GODOT_MSVC_WARNING_PUSH_AND_IGNORE(5054) // "operator '*': deprecated between enumerations of different types". #include #ifdef TOOLS_ENABLED @@ -50,6 +53,8 @@ static bool initialized = false; #endif GODOT_GCC_WARNING_POP +GODOT_CLANG_WARNING_POP +GODOT_MSVC_WARNING_POP void basis_universal_init() { basist::basisu_transcoder_init(); diff --git a/modules/mono/mono_gc_handle.h b/modules/mono/mono_gc_handle.h index 014b190e6cdf..f195a6f7cb2b 100644 --- a/modules/mono/mono_gc_handle.h +++ b/modules/mono/mono_gc_handle.h @@ -45,10 +45,14 @@ extern "C" { struct GCHandleIntPtr { void *value; - _FORCE_INLINE_ bool operator==(const GCHandleIntPtr &p_other) { return value == p_other.value; } - _FORCE_INLINE_ bool operator!=(const GCHandleIntPtr &p_other) { return value != p_other.value; } + _FORCE_INLINE_ bool operator==(const GCHandleIntPtr &p_other) const { return value == p_other.value; } + _FORCE_INLINE_ bool operator!=(const GCHandleIntPtr &p_other) const { return value != p_other.value; } + // FIXME: C++20 doesn't allow aggregate initializers to bypass deleted constructors. + // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1008r1.pdf +#if 0 GCHandleIntPtr() = delete; +#endif }; } diff --git a/thirdparty/README.md b/thirdparty/README.md index 03e267d0f8df..36a6215fc6d8 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -958,6 +958,9 @@ Files extracted from upstream source: - `re-spirv.h` - `LICENSE` +Patches: + +- `0001-anonymous-constructor.patch` ([GH-100749](https://github.com/godotengine/godot/pull/100749)) ## rvo2 @@ -1094,6 +1097,7 @@ Patches: - `0001-revert-tvglines-bezier-precision.patch` ([GH-96658](https://github.com/godotengine/godot/pull/96658)) - `0002-use-heap-alloc.patch` ([GH-109530](https://github.com/godotengine/godot/pull/109530)) - `0003-explicit-includes.patch` ([GH-111557](https://github.com/godotengine/godot/pull/111557)) +- `0004-cpp20-explicit-namespace.patch` ([GH-100749](https://github.com/godotengine/godot/pull/100749)) ## tinyexr diff --git a/thirdparty/re-spirv/patches/0001-anonymous-constructor.patch b/thirdparty/re-spirv/patches/0001-anonymous-constructor.patch new file mode 100644 index 000000000000..004ab9f1af49 --- /dev/null +++ b/thirdparty/re-spirv/patches/0001-anonymous-constructor.patch @@ -0,0 +1,17 @@ +diff --git a/thirdparty/re-spirv/re-spirv.cpp b/thirdparty/re-spirv/re-spirv.cpp +index fa613383b6..4dbf594bc3 100644 +--- a/thirdparty/re-spirv/re-spirv.cpp ++++ b/thirdparty/re-spirv/re-spirv.cpp +@@ -2141,7 +2141,11 @@ namespace respv { + std::vector &optimizedData; + Options options; + +- OptimizerContext() = delete; ++ OptimizerContext(const Shader &shader, std::vector &instructionAdjacentListIndices, std::vector &instructionInDegrees, std::vector &instructionOutDegrees, std::vector &listNodes, std::vector &resolutions, std::vector &optimizedData, Options options) : ++ shader(shader), instructionAdjacentListIndices(instructionAdjacentListIndices), instructionInDegrees(instructionInDegrees), instructionOutDegrees(instructionOutDegrees), listNodes(listNodes), resolutions(resolutions), optimizedData(optimizedData), options(options) ++ { ++ // Regular constructor. ++ } + }; + + static void optimizerEliminateInstruction(uint32_t pInstructionIndex, OptimizerContext &rContext) { diff --git a/thirdparty/re-spirv/re-spirv.cpp b/thirdparty/re-spirv/re-spirv.cpp index 2815e40866b2..fb6b4c7f61eb 100644 --- a/thirdparty/re-spirv/re-spirv.cpp +++ b/thirdparty/re-spirv/re-spirv.cpp @@ -2311,7 +2311,11 @@ namespace respv { std::vector &optimizedData; Options options; - OptimizerContext() = delete; + OptimizerContext(const Shader &shader, std::vector &instructionAdjacentListIndices, std::vector &instructionInDegrees, std::vector &instructionOutDegrees, std::vector &listNodes, std::vector &resolutions, std::vector &optimizedData, Options options) : + shader(shader), instructionAdjacentListIndices(instructionAdjacentListIndices), instructionInDegrees(instructionInDegrees), instructionOutDegrees(instructionOutDegrees), listNodes(listNodes), resolutions(resolutions), optimizedData(optimizedData), options(options) + { + // Regular constructor. + } }; static void optimizerEliminateInstruction(uint32_t pInstructionIndex, OptimizerContext &rContext) { diff --git a/thirdparty/thorvg/patches/0004-cpp20-explicit-namespace.patch b/thirdparty/thorvg/patches/0004-cpp20-explicit-namespace.patch new file mode 100644 index 000000000000..7ceb617bac44 --- /dev/null +++ b/thirdparty/thorvg/patches/0004-cpp20-explicit-namespace.patch @@ -0,0 +1,24 @@ +diff --git a/thirdparty/thorvg/src/loaders/svg/tvgSvgSceneBuilder.cpp b/thirdparty/thorvg/src/loaders/svg/tvgSvgSceneBuilder.cpp +index 175739250a..5c2b36d394 100644 +--- a/thirdparty/thorvg/src/loaders/svg/tvgSvgSceneBuilder.cpp ++++ b/thirdparty/thorvg/src/loaders/svg/tvgSvgSceneBuilder.cpp +@@ -218 +218 @@ static bool _appendClipUseNode(SvgLoaderData& loaderData, SvgNode* node, Shape* +- return _appendClipShape(loaderData, child, shape, vBox, svgPath, identity((const Matrix*)(&finalTransform)) ? nullptr : &finalTransform); ++ return _appendClipShape(loaderData, child, shape, vBox, svgPath, tvg::identity((const Matrix*)(&finalTransform)) ? nullptr : &finalTransform); +diff --git a/thirdparty/thorvg/src/renderer/sw_engine/tvgSwFill.cpp b/thirdparty/thorvg/src/renderer/sw_engine/tvgSwFill.cpp +index e012465b70..380e547dcf 100644 +--- a/thirdparty/thorvg/src/renderer/sw_engine/tvgSwFill.cpp ++++ b/thirdparty/thorvg/src/renderer/sw_engine/tvgSwFill.cpp +@@ -231 +231 @@ bool _prepareLinear(SwFill* fill, const LinearGradient* linear, const Matrix& tr +- bool isTransformation = !identity((const Matrix*)(&gradTransform)); ++ bool isTransformation = !tvg::identity((const Matrix*)(&gradTransform)); +@@ -298 +298 @@ bool _prepareRadial(SwFill* fill, const RadialGradient* radial, const Matrix& tr +- bool isTransformation = !identity((const Matrix*)(&gradTransform)); ++ bool isTransformation = !tvg::identity((const Matrix*)(&gradTransform)); +diff --git a/thirdparty/thorvg/src/renderer/tvgPaint.cpp b/thirdparty/thorvg/src/renderer/tvgPaint.cpp +index e00c2c1954..873e65527b 100644 +--- a/thirdparty/thorvg/src/renderer/tvgPaint.cpp ++++ b/thirdparty/thorvg/src/renderer/tvgPaint.cpp +@@ -316 +316 @@ bool Paint::Impl::bounds(float* x, float* y, float* w, float* h, bool transforme +- if (!transformed || identity(&m)) { ++ if (!transformed || tvg::identity(&m)) { diff --git a/thirdparty/thorvg/src/loaders/svg/tvgSvgSceneBuilder.cpp b/thirdparty/thorvg/src/loaders/svg/tvgSvgSceneBuilder.cpp index 668f7aa051bd..299efa714317 100644 --- a/thirdparty/thorvg/src/loaders/svg/tvgSvgSceneBuilder.cpp +++ b/thirdparty/thorvg/src/loaders/svg/tvgSvgSceneBuilder.cpp @@ -215,7 +215,7 @@ static bool _appendClipUseNode(SvgLoaderData& loaderData, SvgNode* node, Shape* } if (child->transform) finalTransform *= *child->transform; - return _appendClipShape(loaderData, child, shape, vBox, svgPath, identity((const Matrix*)(&finalTransform)) ? nullptr : &finalTransform); + return _appendClipShape(loaderData, child, shape, vBox, svgPath, tvg::identity((const Matrix*)(&finalTransform)) ? nullptr : &finalTransform); } diff --git a/thirdparty/thorvg/src/renderer/sw_engine/tvgSwFill.cpp b/thirdparty/thorvg/src/renderer/sw_engine/tvgSwFill.cpp index 25d76aa71028..c332406b3597 100644 --- a/thirdparty/thorvg/src/renderer/sw_engine/tvgSwFill.cpp +++ b/thirdparty/thorvg/src/renderer/sw_engine/tvgSwFill.cpp @@ -221,7 +221,7 @@ bool _prepareLinear(SwFill* fill, const LinearGradient* linear, const Matrix& tr fill->linear.offset = -fill->linear.dx * x1 - fill->linear.dy * y1; auto gradTransform = linear->transform(); - bool isTransformation = !identity((const Matrix*)(&gradTransform)); + bool isTransformation = !tvg::identity((const Matrix*)(&gradTransform)); if (isTransformation) { gradTransform = transform * gradTransform; @@ -290,7 +290,7 @@ bool _prepareRadial(SwFill* fill, const RadialGradient* radial, const Matrix& tr if (fill->radial.a > 0) fill->radial.invA = 1.0f / fill->radial.a; auto gradTransform = radial->transform(); - bool isTransformation = !identity((const Matrix*)(&gradTransform)); + bool isTransformation = !tvg::identity((const Matrix*)(&gradTransform)); if (isTransformation) gradTransform = transform * gradTransform; else { diff --git a/thirdparty/thorvg/src/renderer/tvgPaint.cpp b/thirdparty/thorvg/src/renderer/tvgPaint.cpp index ba7ea606b84a..e62b0b2c6d2a 100644 --- a/thirdparty/thorvg/src/renderer/tvgPaint.cpp +++ b/thirdparty/thorvg/src/renderer/tvgPaint.cpp @@ -310,7 +310,7 @@ bool Paint::Impl::bounds(float* x, float* y, float* w, float* h, bool transforme const auto& m = this->transform(origin); //Case: No transformed, quick return! - if (!transformed || identity(&m)) { + if (!transformed || tvg::identity(&m)) { PAINT_METHOD(ret, bounds(x, y, w, h, stroking)); return ret; }