Skip to content

Commit

Permalink
Merge pull request #1008 from CesiumGS/fix-gcc13
Browse files Browse the repository at this point in the history
Fix compiler error on GCC 13
  • Loading branch information
kring authored Dec 1, 2024
2 parents a836e27 + 472669a commit 24a2bdc
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 20 deletions.
9 changes: 9 additions & 0 deletions CesiumGltf/test/TestPropertyAttributePropertyView.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif

#include "CesiumGltf/PropertyAttributePropertyView.h"

#include <CesiumUtility/Assert.h>
Expand Down Expand Up @@ -823,3 +828,7 @@ TEST_CASE("Check that PropertyAttributeProperty values override class property "
REQUIRE(view.get(i) == expected[static_cast<size_t>(i)]);
}
}

#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
49 changes: 29 additions & 20 deletions CesiumGltf/test/TestPropertyTablePropertyView.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif

#include "CesiumGltf/PropertyTablePropertyView.h"

#include <catch2/catch.hpp>
Expand Down Expand Up @@ -58,10 +63,10 @@ template <typename T>
static void checkNumeric(
const std::vector<T>& values,
const std::vector<std::optional<T>>& expected,
const std::optional<JsonValue> offset = std::nullopt,
const std::optional<JsonValue> scale = std::nullopt,
const std::optional<JsonValue> noData = std::nullopt,
const std::optional<JsonValue> defaultValue = std::nullopt) {
const std::optional<JsonValue>& offset = std::nullopt,
const std::optional<JsonValue>& scale = std::nullopt,
const std::optional<JsonValue>& noData = std::nullopt,
const std::optional<JsonValue>& defaultValue = std::nullopt) {
std::vector<std::byte> data;
data.resize(values.size() * sizeof(T));
std::memcpy(data.data(), values.data(), data.size());
Expand Down Expand Up @@ -103,10 +108,10 @@ template <typename T, typename D = typename TypeToNormalizedType<T>::type>
static void checkNormalizedNumeric(
const std::vector<T>& values,
const std::vector<std::optional<D>>& expected,
const std::optional<JsonValue> offset = std::nullopt,
const std::optional<JsonValue> scale = std::nullopt,
const std::optional<JsonValue> noData = std::nullopt,
const std::optional<JsonValue> defaultValue = std::nullopt) {
const std::optional<JsonValue>& offset = std::nullopt,
const std::optional<JsonValue>& scale = std::nullopt,
const std::optional<JsonValue>& noData = std::nullopt,
const std::optional<JsonValue>& defaultValue = std::nullopt) {
std::vector<std::byte> data;
data.resize(values.size() * sizeof(T));
std::memcpy(data.data(), values.data(), data.size());
Expand Down Expand Up @@ -211,8 +216,8 @@ static void checkVariableLengthArray(
PropertyComponentType offsetType,
int64_t instanceCount,
const std::vector<std::optional<std::vector<DataType>>>& expected,
const std::optional<JsonValue::Array> noData = std::nullopt,
const std::optional<JsonValue::Array> defaultValue = std::nullopt) {
const std::optional<JsonValue::Array>& noData = std::nullopt,
const std::optional<JsonValue::Array>& defaultValue = std::nullopt) {
// copy data to buffer
std::vector<std::byte> buffer;
buffer.resize(data.size() * sizeof(DataType));
Expand Down Expand Up @@ -292,8 +297,8 @@ static void checkNormalizedVariableLengthArray(
PropertyComponentType offsetType,
int64_t instanceCount,
const std::vector<std::optional<std::vector<NormalizedType>>>& expected,
const std::optional<JsonValue::Array> noData = std::nullopt,
const std::optional<JsonValue::Array> defaultValue = std::nullopt) {
const std::optional<JsonValue::Array>& noData = std::nullopt,
const std::optional<JsonValue::Array>& defaultValue = std::nullopt) {
// copy data to buffer
std::vector<std::byte> buffer;
buffer.resize(data.size() * sizeof(DataType));
Expand Down Expand Up @@ -421,10 +426,10 @@ static void checkFixedLengthArray(
const std::vector<T>& data,
int64_t fixedLengthArrayCount,
const std::vector<std::optional<std::vector<T>>>& expected,
const std::optional<JsonValue::Array> offset = std::nullopt,
const std::optional<JsonValue::Array> scale = std::nullopt,
const std::optional<JsonValue::Array> noData = std::nullopt,
const std::optional<JsonValue::Array> defaultValue = std::nullopt) {
const std::optional<JsonValue::Array>& offset = std::nullopt,
const std::optional<JsonValue::Array>& scale = std::nullopt,
const std::optional<JsonValue::Array>& noData = std::nullopt,
const std::optional<JsonValue::Array>& defaultValue = std::nullopt) {
int64_t instanceCount =
static_cast<int64_t>(data.size()) / fixedLengthArrayCount;

Expand Down Expand Up @@ -496,10 +501,10 @@ static void checkNormalizedFixedLengthArray(
const std::vector<T>& data,
int64_t fixedLengthArrayCount,
const std::vector<std::optional<std::vector<D>>>& expected,
const std::optional<JsonValue::Array> offset = std::nullopt,
const std::optional<JsonValue::Array> scale = std::nullopt,
const std::optional<JsonValue::Array> noData = std::nullopt,
const std::optional<JsonValue::Array> defaultValue = std::nullopt) {
const std::optional<JsonValue::Array>& offset = std::nullopt,
const std::optional<JsonValue::Array>& scale = std::nullopt,
const std::optional<JsonValue::Array>& noData = std::nullopt,
const std::optional<JsonValue::Array>& defaultValue = std::nullopt) {
int64_t instanceCount =
static_cast<int64_t>(data.size()) / fixedLengthArrayCount;

Expand Down Expand Up @@ -3711,3 +3716,7 @@ TEST_CASE("Check variable-length boolean array PropertyTablePropertyView") {
}
}
}

#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif
9 changes: 9 additions & 0 deletions CesiumGltf/test/TestPropertyTexturePropertyView.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif

#include "CesiumGltf/KhrTextureTransform.h"
#include "CesiumGltf/PropertyTexturePropertyView.h"
#include "CesiumUtility/Math.h"
Expand Down Expand Up @@ -2051,3 +2056,7 @@ TEST_CASE("Test normalized PropertyTextureProperty constructs with "
REQUIRE(view.get(uv[0], uv[1]) == static_cast<double>(data[i]) / 255.0);
}
}

#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif

0 comments on commit 24a2bdc

Please sign in to comment.