Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.4] Misc. build and warning fixes to pass CI and compile with recent SCons and GCC/Clang #98864

Merged
merged 15 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/godot-cache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ runs:
steps:
# Upload cache on completion and check it out now
- name: Load .scons_cache directory
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{inputs.scons-cache}}
key: ${{inputs.cache-name}}-${{env.GODOT_BASE_BRANCH}}-${{github.ref}}-${{github.sha}}
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/godot-deps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ runs:
steps:
# Use python 3.x release (works cross platform)
- name: Set up Python 3.x
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
# Semantic version range syntax or exact version of a Python version
python-version: ${{ inputs.python-version }}
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/upload-artifact/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ runs:
using: "composite"
steps:
- name: Upload Godot Artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.name }}
path: ${{ inputs.path }}
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/android_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
name: Template (target=release, tools=no)

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

# Azure repositories are not reliable, we need to prevent azure giving us packages.
- name: Make apt sources.list use the default Ubuntu repositories
Expand All @@ -27,8 +27,9 @@ jobs:
sudo apt-get update

- name: Set up Java 11
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11

- name: Setup Godot build cache
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ios_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
name: Template (target=release, tools=no)

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup Godot build cache
uses: ./.github/actions/godot-cache
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/javascript_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ jobs:
name: Template (target=release, tools=no)

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

# Additional cache for Emscripten generated system libraries
- name: Load Emscripten cache
id: javascript-template-emscripten-cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{env.EM_CACHE_FOLDER}}
key: ${{env.EM_VERSION}}-${{github.job}}

- name: Set up Emscripten latest
uses: mymindstorm/setup-emsdk@v10
uses: mymindstorm/setup-emsdk@v14
with:
version: ${{env.EM_VERSION}}
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linux_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
artifact: true

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Linux dependencies
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
tools: false

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup Godot build cache
uses: ./.github/actions/godot-cache
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/server_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
tools: false

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Linux dependencies
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

# Azure repositories are not reliable, we need to prevent Azure giving us packages.
- name: Make apt sources.list use the default Ubuntu repositories
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
tools: false

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup Godot build cache
uses: ./.github/actions/godot-cache
Expand Down
9 changes: 5 additions & 4 deletions core/cowdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#define COWDATA_H_

#include <string.h>
#include <type_traits>

#include "core/error_macros.h"
#include "core/os/memory.h"
Expand Down Expand Up @@ -202,7 +203,7 @@ void CowData<T>::_unref(void *p_data) {
}
// clean up

if (!__has_trivial_destructor(T)) {
if (!std::is_trivially_destructible<T>::value) {
uint32_t *count = _get_size();
T *data = (T *)(count + 1);

Expand Down Expand Up @@ -237,7 +238,7 @@ uint32_t CowData<T>::_copy_on_write() {
T *_data = (T *)(mem_new);

// initialize new elements
if (__has_trivial_copy(T)) {
if (std::is_trivially_copyable<T>::value) {
memcpy(mem_new, _ptr, current_size * sizeof(T));

} else {
Expand Down Expand Up @@ -300,7 +301,7 @@ Error CowData<T>::resize(int p_size) {

// construct the newly created elements

if (!__has_trivial_constructor(T)) {
if (!std::is_trivially_constructible<T>::value) {
T *elems = _get_data();

for (int i = *_get_size(); i < p_size; i++) {
Expand All @@ -311,7 +312,7 @@ Error CowData<T>::resize(int p_size) {
*_get_size() = p_size;

} else if (p_size < current_size) {
if (!__has_trivial_destructor(T)) {
if (!std::is_trivially_destructible<T>::value) {
// deinitialize no longer needed elements
for (uint32_t i = p_size; i < *_get_size(); i++) {
T *t = &_get_data()[i];
Expand Down
5 changes: 3 additions & 2 deletions core/io/logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,11 @@ void RotatedFileLogger::rotate_file() {

if (FileAccess::exists(base_path)) {
if (max_files > 1) {
char timestamp[21];
const size_t TIMESTAMP_SIZE = 21;
char timestamp[TIMESTAMP_SIZE];
OS::Date date = OS::get_singleton()->get_date();
OS::Time time = OS::get_singleton()->get_time();
sprintf(timestamp, "_%04d-%02d-%02d_%02d.%02d.%02d", date.year, date.month, date.day, time.hour, time.min, time.sec);
snprintf(timestamp, TIMESTAMP_SIZE, "_%04d-%02d-%02d_%02d.%02d.%02d", date.year, date.month, date.day, time.hour, time.min, time.sec);

String backup_name = base_path.get_basename() + timestamp;
if (base_path.get_extension() != String()) {
Expand Down
12 changes: 7 additions & 5 deletions core/local_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#include "core/sort_array.h"
#include "core/vector.h"

#include <type_traits>

template <class T, class U = uint32_t, bool force_trivial = false>
class LocalVector {
private:
Expand Down Expand Up @@ -63,7 +65,7 @@ class LocalVector {
CRASH_COND_MSG(!data, "Out of memory");
}

if (!__has_trivial_constructor(T) && !force_trivial) {
if (!std::is_trivially_constructible<T>::value && !force_trivial) {
memnew_placement(&data[count++], T(p_elem));
} else {
data[count++] = p_elem;
Expand All @@ -76,7 +78,7 @@ class LocalVector {
for (U i = p_index; i < count; i++) {
data[i] = data[i + 1];
}
if (!__has_trivial_destructor(T) && !force_trivial) {
if (!std::is_trivially_destructible<T>::value && !force_trivial) {
data[count].~T();
}
}
Expand All @@ -89,7 +91,7 @@ class LocalVector {
if (count > p_index) {
data[p_index] = data[count];
}
if (!__has_trivial_destructor(T) && !force_trivial) {
if (!std::is_trivially_destructible<T>::value && !force_trivial) {
data[count].~T();
}
}
Expand Down Expand Up @@ -129,7 +131,7 @@ class LocalVector {
_FORCE_INLINE_ U size() const { return count; }
void resize(U p_size) {
if (p_size < count) {
if (!__has_trivial_destructor(T) && !force_trivial) {
if (!std::is_trivially_destructible<T>::value && !force_trivial) {
for (U i = p_size; i < count; i++) {
data[i].~T();
}
Expand All @@ -146,7 +148,7 @@ class LocalVector {
data = (T *)memrealloc(data, capacity * sizeof(T));
CRASH_COND_MSG(!data, "Out of memory");
}
if (!__has_trivial_constructor(T) && !force_trivial) {
if (!std::is_trivially_constructible<T>::value && !force_trivial) {
for (U i = count; i < p_size; i++) {
memnew_placement(&data[i], T);
}
Expand Down
4 changes: 2 additions & 2 deletions core/math/bsp_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ static int _bsp_find_best_half_plane(const Face3 *p_faces, const Vector<int> &p_
const Face3 &f = p_faces[indices[i]];
Plane p = f.get_plane();

int num_over = 0, num_under = 0, num_spanning = 0;
int num_over = 0, num_under = 0; //num_spanning = 0;

for (int j = 0; j < ic; j++) {
if (i == j) {
Expand All @@ -294,7 +294,7 @@ static int _bsp_find_best_half_plane(const Face3 *p_faces, const Vector<int> &p_
}

if (over && under) {
num_spanning++;
//num_spanning++;
} else if (over) {
num_over++;
} else {
Expand Down
2 changes: 0 additions & 2 deletions core/math/quick_hull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
if (O->get().plane.is_equal_approx(f.plane)) {
//merge and delete edge and contiguous face, while repointing edges (uuugh!)
int ois = O->get().indices.size();
int merged = 0;

for (int j = 0; j < ois; j++) {
//search a
Expand All @@ -409,7 +408,6 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
if (idx != a) {
f.indices.insert(i + 1, idx);
i++;
merged++;
}
Edge e2(idx, idxn);

Expand Down
9 changes: 5 additions & 4 deletions core/os/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "core/safe_refcount.h"

#include <stddef.h>
#include <type_traits>

#ifndef PAD_ALIGN
#define PAD_ALIGN 16 //must always be greater than this at much
Expand Down Expand Up @@ -111,7 +112,7 @@ void memdelete(T *p_class) {
if (!predelete_handler(p_class)) {
return; // doesn't want to be deleted
}
if (!__has_trivial_destructor(T)) {
if (!std::is_trivially_destructible<T>::value) {
p_class->~T();
}

Expand All @@ -123,7 +124,7 @@ void memdelete_allocator(T *p_class) {
if (!predelete_handler(p_class)) {
return; // doesn't want to be deleted
}
if (!__has_trivial_destructor(T)) {
if (!std::is_trivially_destructible<T>::value) {
p_class->~T();
}

Expand Down Expand Up @@ -152,7 +153,7 @@ T *memnew_arr_template(size_t p_elements, const char *p_descr = "") {
ERR_FAIL_COND_V(!mem, failptr);
*(mem - 1) = p_elements;

if (!__has_trivial_constructor(T)) {
if (!std::is_trivially_constructible<T>::value) {
T *elems = (T *)mem;

/* call operator new */
Expand All @@ -179,7 +180,7 @@ template <typename T>
void memdelete_arr(T *p_class) {
uint64_t *ptr = (uint64_t *)p_class;

if (!__has_trivial_destructor(T)) {
if (!std::is_trivially_destructible<T>::value) {
uint64_t elem_count = *(ptr - 1);

for (uint64_t i = 0; i < elem_count; i++) {
Expand Down
4 changes: 2 additions & 2 deletions core/ring_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,12 @@ class RingBuffer {
size_mask = mask;
};

RingBuffer<T>(int p_power = 0) {
RingBuffer(int p_power = 0) {
read_pos = 0;
write_pos = 0;
resize(p_power);
};
~RingBuffer<T>(){};
~RingBuffer() {}
};

#endif
2 changes: 1 addition & 1 deletion core/safe_refcount.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class SafeNumeric {
}
}

_ALWAYS_INLINE_ explicit SafeNumeric<T>(T p_value = static_cast<T>(0)) {
_ALWAYS_INLINE_ explicit SafeNumeric(T p_value = static_cast<T>(0)) {
set(p_value);
}
};
Expand Down
3 changes: 0 additions & 3 deletions editor/editor_properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,6 @@ class EditorPropertyLayersGrid : public Control {
const int vofs = (grid_size.height - h) / 2;

int layer_index = 0;
int block_index = 0;

Point2 arrow_pos;

Expand Down Expand Up @@ -769,8 +768,6 @@ class EditorPropertyLayersGrid : public Control {
break;
}
}

++block_index;
}

if ((expansion_rows != prev_expansion_rows) && expanded) {
Expand Down
2 changes: 0 additions & 2 deletions editor/project_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,6 @@ class ProjectDialog : public ConfirmationDialog {

Vector<String> failed_files;

int idx = 0;
while (ret == UNZ_OK) {
//get filename
unz_file_info info;
Expand Down Expand Up @@ -566,7 +565,6 @@ class ProjectDialog : public ConfirmationDialog {
}
}

idx++;
ret = unzGoToNextFile(pkg);
}

Expand Down
4 changes: 0 additions & 4 deletions editor/script_create_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,18 +204,14 @@ String ScriptCreateDialog::_validate_path(const String &p_path, bool p_file_must

bool found = false;
bool match = false;
int index = 0;
for (List<String>::Element *E = extensions.front(); E; E = E->next()) {
if (E->get().nocasecmp_to(extension) == 0) {
//FIXME (?) - changing language this way doesn't update controls, needs rework
//language_menu->select(index); // change Language option by extension
found = true;
if (E->get() == ScriptServer::get_language(language_menu->get_selected())->get_extension()) {
match = true;
}
break;
}
index++;
}

if (!found) {
Expand Down
2 changes: 1 addition & 1 deletion main/input_default.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ InputDefault::JoyEvent InputDefault::_get_mapped_axis_event(const JoyDeviceMappi
return event;
}

void InputDefault::_get_mapped_hat_events(const JoyDeviceMapping &mapping, int p_hat, JoyEvent r_events[]) {
void InputDefault::_get_mapped_hat_events(const JoyDeviceMapping &mapping, int p_hat, JoyEvent r_events[(size_t)HAT_MAX]) {
for (int i = 0; i < mapping.bindings.size(); i++) {
const JoyBinding binding = mapping.bindings[i];
if (binding.inputType == TYPE_HAT && binding.input.hat.hat == p_hat) {
Expand Down
Loading