Skip to content

Commit 24a2bdc

Browse files
authored
Merge pull request #1008 from CesiumGS/fix-gcc13
Fix compiler error on GCC 13
2 parents a836e27 + 472669a commit 24a2bdc

File tree

3 files changed

+47
-20
lines changed

3 files changed

+47
-20
lines changed

CesiumGltf/test/TestPropertyAttributePropertyView.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#if defined(__GNUC__) && !defined(__clang__)
2+
#pragma GCC diagnostic push
3+
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
4+
#endif
5+
16
#include "CesiumGltf/PropertyAttributePropertyView.h"
27

38
#include <CesiumUtility/Assert.h>
@@ -823,3 +828,7 @@ TEST_CASE("Check that PropertyAttributeProperty values override class property "
823828
REQUIRE(view.get(i) == expected[static_cast<size_t>(i)]);
824829
}
825830
}
831+
832+
#if defined(__GNUC__) && !defined(__clang__)
833+
#pragma GCC diagnostic pop
834+
#endif

CesiumGltf/test/TestPropertyTablePropertyView.cpp

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#if defined(__GNUC__) && !defined(__clang__)
2+
#pragma GCC diagnostic push
3+
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
4+
#endif
5+
16
#include "CesiumGltf/PropertyTablePropertyView.h"
27

38
#include <catch2/catch.hpp>
@@ -58,10 +63,10 @@ template <typename T>
5863
static void checkNumeric(
5964
const std::vector<T>& values,
6065
const std::vector<std::optional<T>>& expected,
61-
const std::optional<JsonValue> offset = std::nullopt,
62-
const std::optional<JsonValue> scale = std::nullopt,
63-
const std::optional<JsonValue> noData = std::nullopt,
64-
const std::optional<JsonValue> defaultValue = std::nullopt) {
66+
const std::optional<JsonValue>& offset = std::nullopt,
67+
const std::optional<JsonValue>& scale = std::nullopt,
68+
const std::optional<JsonValue>& noData = std::nullopt,
69+
const std::optional<JsonValue>& defaultValue = std::nullopt) {
6570
std::vector<std::byte> data;
6671
data.resize(values.size() * sizeof(T));
6772
std::memcpy(data.data(), values.data(), data.size());
@@ -103,10 +108,10 @@ template <typename T, typename D = typename TypeToNormalizedType<T>::type>
103108
static void checkNormalizedNumeric(
104109
const std::vector<T>& values,
105110
const std::vector<std::optional<D>>& expected,
106-
const std::optional<JsonValue> offset = std::nullopt,
107-
const std::optional<JsonValue> scale = std::nullopt,
108-
const std::optional<JsonValue> noData = std::nullopt,
109-
const std::optional<JsonValue> defaultValue = std::nullopt) {
111+
const std::optional<JsonValue>& offset = std::nullopt,
112+
const std::optional<JsonValue>& scale = std::nullopt,
113+
const std::optional<JsonValue>& noData = std::nullopt,
114+
const std::optional<JsonValue>& defaultValue = std::nullopt) {
110115
std::vector<std::byte> data;
111116
data.resize(values.size() * sizeof(T));
112117
std::memcpy(data.data(), values.data(), data.size());
@@ -211,8 +216,8 @@ static void checkVariableLengthArray(
211216
PropertyComponentType offsetType,
212217
int64_t instanceCount,
213218
const std::vector<std::optional<std::vector<DataType>>>& expected,
214-
const std::optional<JsonValue::Array> noData = std::nullopt,
215-
const std::optional<JsonValue::Array> defaultValue = std::nullopt) {
219+
const std::optional<JsonValue::Array>& noData = std::nullopt,
220+
const std::optional<JsonValue::Array>& defaultValue = std::nullopt) {
216221
// copy data to buffer
217222
std::vector<std::byte> buffer;
218223
buffer.resize(data.size() * sizeof(DataType));
@@ -292,8 +297,8 @@ static void checkNormalizedVariableLengthArray(
292297
PropertyComponentType offsetType,
293298
int64_t instanceCount,
294299
const std::vector<std::optional<std::vector<NormalizedType>>>& expected,
295-
const std::optional<JsonValue::Array> noData = std::nullopt,
296-
const std::optional<JsonValue::Array> defaultValue = std::nullopt) {
300+
const std::optional<JsonValue::Array>& noData = std::nullopt,
301+
const std::optional<JsonValue::Array>& defaultValue = std::nullopt) {
297302
// copy data to buffer
298303
std::vector<std::byte> buffer;
299304
buffer.resize(data.size() * sizeof(DataType));
@@ -421,10 +426,10 @@ static void checkFixedLengthArray(
421426
const std::vector<T>& data,
422427
int64_t fixedLengthArrayCount,
423428
const std::vector<std::optional<std::vector<T>>>& expected,
424-
const std::optional<JsonValue::Array> offset = std::nullopt,
425-
const std::optional<JsonValue::Array> scale = std::nullopt,
426-
const std::optional<JsonValue::Array> noData = std::nullopt,
427-
const std::optional<JsonValue::Array> defaultValue = std::nullopt) {
429+
const std::optional<JsonValue::Array>& offset = std::nullopt,
430+
const std::optional<JsonValue::Array>& scale = std::nullopt,
431+
const std::optional<JsonValue::Array>& noData = std::nullopt,
432+
const std::optional<JsonValue::Array>& defaultValue = std::nullopt) {
428433
int64_t instanceCount =
429434
static_cast<int64_t>(data.size()) / fixedLengthArrayCount;
430435

@@ -496,10 +501,10 @@ static void checkNormalizedFixedLengthArray(
496501
const std::vector<T>& data,
497502
int64_t fixedLengthArrayCount,
498503
const std::vector<std::optional<std::vector<D>>>& expected,
499-
const std::optional<JsonValue::Array> offset = std::nullopt,
500-
const std::optional<JsonValue::Array> scale = std::nullopt,
501-
const std::optional<JsonValue::Array> noData = std::nullopt,
502-
const std::optional<JsonValue::Array> defaultValue = std::nullopt) {
504+
const std::optional<JsonValue::Array>& offset = std::nullopt,
505+
const std::optional<JsonValue::Array>& scale = std::nullopt,
506+
const std::optional<JsonValue::Array>& noData = std::nullopt,
507+
const std::optional<JsonValue::Array>& defaultValue = std::nullopt) {
503508
int64_t instanceCount =
504509
static_cast<int64_t>(data.size()) / fixedLengthArrayCount;
505510

@@ -3711,3 +3716,7 @@ TEST_CASE("Check variable-length boolean array PropertyTablePropertyView") {
37113716
}
37123717
}
37133718
}
3719+
3720+
#if defined(__GNUC__) && !defined(__clang__)
3721+
#pragma GCC diagnostic pop
3722+
#endif

CesiumGltf/test/TestPropertyTexturePropertyView.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
#if defined(__GNUC__) && !defined(__clang__)
2+
#pragma GCC diagnostic push
3+
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
4+
#endif
5+
16
#include "CesiumGltf/KhrTextureTransform.h"
27
#include "CesiumGltf/PropertyTexturePropertyView.h"
38
#include "CesiumUtility/Math.h"
@@ -2051,3 +2056,7 @@ TEST_CASE("Test normalized PropertyTextureProperty constructs with "
20512056
REQUIRE(view.get(uv[0], uv[1]) == static_cast<double>(data[i]) / 255.0);
20522057
}
20532058
}
2059+
2060+
#if defined(__GNUC__) && !defined(__clang__)
2061+
#pragma GCC diagnostic pop
2062+
#endif

0 commit comments

Comments
 (0)