summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/core_bind.cpp1
-rw-r--r--core/io/resource_loader.cpp2
-rw-r--r--core/math/aabb.h2
-rw-r--r--core/math/basis.h2
-rw-r--r--core/math/color.h2
-rw-r--r--core/math/face3.h2
-rw-r--r--core/math/plane.h2
-rw-r--r--core/math/quaternion.h2
-rw-r--r--core/math/rect2.h4
-rw-r--r--core/math/transform_2d.h2
-rw-r--r--core/math/transform_3d.h2
-rw-r--r--core/math/vector2.h4
-rw-r--r--core/math/vector3.h2
-rw-r--r--core/math/vector3i.h2
-rw-r--r--core/string/translation.cpp4
-rw-r--r--core/typedefs.h11
16 files changed, 28 insertions, 18 deletions
diff --git a/core/core_bind.cpp b/core/core_bind.cpp
index 9a3234d4a2..8d03f35617 100644
--- a/core/core_bind.cpp
+++ b/core/core_bind.cpp
@@ -623,7 +623,6 @@ void OS::_bind_methods() {
// Those default values need to be specified for the docs generator,
// to avoid using values from the documentation writer's own OS instance.
- ADD_PROPERTY_DEFAULT("exit_code", 0);
ADD_PROPERTY_DEFAULT("low_processor_usage_mode", false);
ADD_PROPERTY_DEFAULT("low_processor_usage_mode_sleep_usec", 6900);
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index 7d42a9c8d2..3e1c9d2e4a 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -820,7 +820,7 @@ String ResourceLoader::_path_remap(const String &p_path, bool *r_translation_rem
}
String l = res_remaps[i].substr(split + 1).strip_edges();
int score = TranslationServer::get_singleton()->compare_locales(locale, l);
- if (score >= best_score) {
+ if (score > best_score) {
new_path = res_remaps[i].left(split);
best_score = score;
if (score == 10) {
diff --git a/core/math/aabb.h b/core/math/aabb.h
index 2eaaafa27d..3d19410ddf 100644
--- a/core/math/aabb.h
+++ b/core/math/aabb.h
@@ -41,7 +41,7 @@
*/
class Variant;
-class AABB {
+class _NO_DISCARD_ AABB {
public:
Vector3 position;
Vector3 size;
diff --git a/core/math/basis.h b/core/math/basis.h
index 709f2cb3cf..802da82089 100644
--- a/core/math/basis.h
+++ b/core/math/basis.h
@@ -34,7 +34,7 @@
#include "core/math/quaternion.h"
#include "core/math/vector3.h"
-class Basis {
+class _NO_DISCARD_ Basis {
private:
void _set_diagonal(const Vector3 &p_diag);
diff --git a/core/math/color.h b/core/math/color.h
index 6c09f7941c..72a4a5f8be 100644
--- a/core/math/color.h
+++ b/core/math/color.h
@@ -34,7 +34,7 @@
#include "core/math/math_funcs.h"
#include "core/string/ustring.h"
-struct Color {
+struct _NO_DISCARD_ Color {
union {
struct {
float r;
diff --git a/core/math/face3.h b/core/math/face3.h
index 5a34858ccb..3dbbca09e0 100644
--- a/core/math/face3.h
+++ b/core/math/face3.h
@@ -36,7 +36,7 @@
#include "core/math/transform_3d.h"
#include "core/math/vector3.h"
-class Face3 {
+class _NO_DISCARD_ Face3 {
public:
enum Side {
SIDE_OVER,
diff --git a/core/math/plane.h b/core/math/plane.h
index bac946502b..8cb6f62b3b 100644
--- a/core/math/plane.h
+++ b/core/math/plane.h
@@ -35,7 +35,7 @@
class Variant;
-class Plane {
+class _NO_DISCARD_ Plane {
public:
Vector3 normal;
real_t d = 0;
diff --git a/core/math/quaternion.h b/core/math/quaternion.h
index cf3762e090..2575d7d229 100644
--- a/core/math/quaternion.h
+++ b/core/math/quaternion.h
@@ -36,7 +36,7 @@
#include "core/math/vector3.h"
#include "core/string/ustring.h"
-class Quaternion {
+class _NO_DISCARD_ Quaternion {
public:
union {
struct {
diff --git a/core/math/rect2.h b/core/math/rect2.h
index f34550bef1..4ea24e8f88 100644
--- a/core/math/rect2.h
+++ b/core/math/rect2.h
@@ -35,7 +35,7 @@
struct Transform2D;
-struct Rect2 {
+struct _NO_DISCARD_ Rect2 {
Point2 position;
Size2 size;
@@ -363,7 +363,7 @@ struct Rect2 {
}
};
-struct Rect2i {
+struct _NO_DISCARD_ Rect2i {
Point2i position;
Size2i size;
diff --git a/core/math/transform_2d.h b/core/math/transform_2d.h
index 752a885eba..6c2d51bd9b 100644
--- a/core/math/transform_2d.h
+++ b/core/math/transform_2d.h
@@ -33,7 +33,7 @@
#include "core/math/rect2.h" // also includes vector2, math_funcs, and ustring
-struct Transform2D {
+struct _NO_DISCARD_ Transform2D {
// Warning #1: basis of Transform2D is stored differently from Basis. In terms of elements array, the basis matrix looks like "on paper":
// M = (elements[0][0] elements[1][0])
// (elements[0][1] elements[1][1])
diff --git a/core/math/transform_3d.h b/core/math/transform_3d.h
index c0ef2ecfc1..c16c278e74 100644
--- a/core/math/transform_3d.h
+++ b/core/math/transform_3d.h
@@ -35,7 +35,7 @@
#include "core/math/basis.h"
#include "core/math/plane.h"
-class Transform3D {
+class _NO_DISCARD_ Transform3D {
public:
Basis basis;
Vector3 origin;
diff --git a/core/math/vector2.h b/core/math/vector2.h
index a340036ac7..af40b9e68d 100644
--- a/core/math/vector2.h
+++ b/core/math/vector2.h
@@ -36,7 +36,7 @@
struct Vector2i;
-struct Vector2 {
+struct _NO_DISCARD_ Vector2 {
static const int AXIS_COUNT = 2;
enum Axis {
@@ -284,7 +284,7 @@ typedef Vector2 Point2;
/* INTEGER STUFF */
-struct Vector2i {
+struct _NO_DISCARD_ Vector2i {
enum Axis {
AXIS_X,
AXIS_Y,
diff --git a/core/math/vector3.h b/core/math/vector3.h
index d7a72b05a8..b62edef40f 100644
--- a/core/math/vector3.h
+++ b/core/math/vector3.h
@@ -37,7 +37,7 @@
#include "core/string/ustring.h"
class Basis;
-struct Vector3 {
+struct _NO_DISCARD_ Vector3 {
static const int AXIS_COUNT = 3;
enum Axis {
diff --git a/core/math/vector3i.h b/core/math/vector3i.h
index 1416c98057..1564ee9173 100644
--- a/core/math/vector3i.h
+++ b/core/math/vector3i.h
@@ -35,7 +35,7 @@
#include "core/string/ustring.h"
#include "core/typedefs.h"
-struct Vector3i {
+struct _NO_DISCARD_ Vector3i {
enum Axis {
AXIS_X,
AXIS_Y,
diff --git a/core/string/translation.cpp b/core/string/translation.cpp
index 5d7e583de1..674098b06c 100644
--- a/core/string/translation.cpp
+++ b/core/string/translation.cpp
@@ -544,7 +544,7 @@ Ref<Translation> TranslationServer::get_translation_object(const String &p_local
String l = t->get_locale();
int score = compare_locales(p_locale, l);
- if (score >= best_score) {
+ if (score > best_score) {
res = t;
best_score = score;
if (score == 10) {
@@ -617,7 +617,7 @@ StringName TranslationServer::_get_message_from_translations(const StringName &p
String l = t->get_locale();
int score = compare_locales(p_locale, l);
- if (score >= best_score) {
+ if (score > best_score) {
StringName r;
if (!plural) {
res = t->get_message(p_message, p_context);
diff --git a/core/typedefs.h b/core/typedefs.h
index e6034eb375..5929b5123b 100644
--- a/core/typedefs.h
+++ b/core/typedefs.h
@@ -71,6 +71,17 @@
#endif
#endif
+// No discard allows the compiler to flag warnings if we don't use the return value of functions / classes
+#ifndef _NO_DISCARD_
+#define _NO_DISCARD_ [[nodiscard]]
+#endif
+
+// In some cases _NO_DISCARD_ will get false positives,
+// we can prevent the warning in specific cases by preceding the call with a cast.
+#ifndef _ALLOW_DISCARD_
+#define _ALLOW_DISCARD_ (void)
+#endif
+
// Windows badly defines a lot of stuff we'll never use. Undefine it.
#ifdef _WIN32
#undef min // override standard definition