Browse Source

Fix build with CORRADE_STANDARD_ASSERT.

And clean up the warnings. Like in Corrade it's Debug build only, for
the Release build it's better to just use CORRADE_NO_ASSERT instead.
pull/617/head
Vladimír Vondruš 3 years ago
parent
commit
3e8d393b86
  1. 1
      doc/changelog.dox
  2. 7
      src/Magnum/Implementation/ImageProperties.h
  3. 6
      src/Magnum/MeshTools/Combine.cpp
  4. 2
      src/Magnum/MeshTools/Concatenate.cpp
  5. 4
      src/Magnum/Shaders/Implementation/lineMiterLimit.h
  6. 21
      src/Magnum/Trade/AbstractImageConverter.cpp
  7. 14
      src/Magnum/Trade/AbstractSceneConverter.cpp
  8. 6
      src/Magnum/Trade/MeshData.h
  9. 6
      src/Magnum/Trade/SceneData.h
  10. 4
      src/Magnum/Vk/Assert.h

1
doc/changelog.dox

@ -855,6 +855,7 @@ See also:
[mosra/magnum#602](https://github.com/mosra/magnum/pull/602)) [mosra/magnum#602](https://github.com/mosra/magnum/pull/602))
- Fixed various variable shadowing warings on MSVC (see [mosra/magnum#611](https://github.com/mosra/magnum/issues/611)) - Fixed various variable shadowing warings on MSVC (see [mosra/magnum#611](https://github.com/mosra/magnum/issues/611))
- Fixed compilation on a non-deprecated build (see [mosra/magnum#612](https://github.com/mosra/magnum/pull/612)) - Fixed compilation on a non-deprecated build (see [mosra/magnum#612](https://github.com/mosra/magnum/pull/612))
- Fixed build of the @ref Vk library with @ref CORRADE_STANDARD_ASSERT
@subsection changelog-latest-bugfixes Bug fixes @subsection changelog-latest-bugfixes Bug fixes

7
src/Magnum/Implementation/ImageProperties.h

@ -40,7 +40,12 @@ namespace Magnum { namespace Implementation {
#ifndef CORRADE_NO_ASSERT #ifndef CORRADE_NO_ASSERT
inline void checkImageFlagsForSize(const char*, const ImageFlags1D, const Math::Vector<1, Int>&) {} inline void checkImageFlagsForSize(const char*, const ImageFlags1D, const Math::Vector<1, Int>&) {}
inline void checkImageFlagsForSize(const char*, const ImageFlags2D, const Vector2i&) {} inline void checkImageFlagsForSize(const char*, const ImageFlags2D, const Vector2i&) {}
inline void checkImageFlagsForSize(const char* const prefix, const ImageFlags3D flags, const Vector3i& size) { inline void checkImageFlagsForSize(const char*
#ifndef CORRADE_STANDARD_ASSERT
const prefix
#endif
, const ImageFlags3D flags, const Vector3i& size)
{
CORRADE_ASSERT(!(flags & ImageFlag3D::CubeMap) || size.x() == size.y(), CORRADE_ASSERT(!(flags & ImageFlag3D::CubeMap) || size.x() == size.y(),
prefix << "expected square faces for a cube map, got" << Debug::packed << size.xy(), ); prefix << "expected square faces for a cube map, got" << Debug::packed << size.xy(), );
CORRADE_ASSERT(!(flags & ImageFlag3D::CubeMap) || (flags & ImageFlag3D::Array) || size.z() == 6, CORRADE_ASSERT(!(flags & ImageFlag3D::CubeMap) || (flags & ImageFlag3D::Array) || size.z() == 6,

6
src/Magnum/MeshTools/Combine.cpp

@ -40,7 +40,7 @@ namespace Magnum { namespace MeshTools {
namespace { namespace {
Trade::MeshData combineIndexedImplementation( Trade::MeshData combineIndexedImplementation(
#ifndef CORRADE_NO_ASSERT #if !defined(CORRADE_NO_ASSERT) && !defined(CORRADE_STANDARD_ASSERT)
const char* assertPrefix, const char* assertPrefix,
#endif #endif
const MeshPrimitive primitive, Containers::Array<char>& combinedIndices, const UnsignedInt indexCount, const UnsignedInt indexStride, const Containers::Iterable<const Trade::MeshData>& meshes) const MeshPrimitive primitive, Containers::Array<char>& combinedIndices, const UnsignedInt indexCount, const UnsignedInt indexStride, const Containers::Iterable<const Trade::MeshData>& meshes)
@ -164,7 +164,7 @@ Trade::MeshData combineIndexedAttributes(const Containers::Iterable<const Trade:
} }
return combineIndexedImplementation( return combineIndexedImplementation(
#ifndef CORRADE_NO_ASSERT #if !defined(CORRADE_NO_ASSERT) && !defined(CORRADE_STANDARD_ASSERT)
"MeshTools::combineIndexedAttributes():", "MeshTools::combineIndexedAttributes():",
#endif #endif
primitive, combinedIndices, indexCount, indexStride, meshes); primitive, combinedIndices, indexCount, indexStride, meshes);
@ -227,7 +227,7 @@ Trade::MeshData combineFaceAttributes(const Trade::MeshData& mesh, const Trade::
/* Then combine the two into a single buffer */ /* Then combine the two into a single buffer */
return combineIndexedImplementation( return combineIndexedImplementation(
#ifndef CORRADE_NO_ASSERT #if !defined(CORRADE_NO_ASSERT) && !defined(CORRADE_STANDARD_ASSERT)
"MeshTools::combineFaceAttributes():", "MeshTools::combineFaceAttributes():",
#endif #endif
mesh.primitive(), combinedIndices, meshIndexCount, indexStride, { mesh.primitive(), combinedIndices, meshIndexCount, indexStride, {

2
src/Magnum/MeshTools/Concatenate.cpp

@ -63,7 +63,7 @@ struct MeshAttributeHash: std::hash<typename std::underlying_type<Trade::MeshAtt
}; };
Trade::MeshData concatenate(Containers::Array<char>&& indexData, const UnsignedInt vertexCount, Containers::Array<char>&& vertexData, Containers::Array<Trade::MeshAttributeData>&& attributeData, const Containers::Iterable<const Trade::MeshData>& meshes, const char* const assertPrefix) { Trade::MeshData concatenate(Containers::Array<char>&& indexData, const UnsignedInt vertexCount, Containers::Array<char>&& vertexData, Containers::Array<Trade::MeshAttributeData>&& attributeData, const Containers::Iterable<const Trade::MeshData>& meshes, const char* const assertPrefix) {
#ifdef CORRADE_NO_ASSERT #if defined(CORRADE_NO_ASSERT) || defined(CORRADE_STANDARD_ASSERT)
static_cast<void>(assertPrefix); static_cast<void>(assertPrefix);
#endif #endif

4
src/Magnum/Shaders/Implementation/lineMiterLimit.h

@ -32,7 +32,7 @@
namespace Magnum { namespace Shaders { namespace Implementation { namespace Magnum { namespace Shaders { namespace Implementation {
inline Float lineMiterLengthLimit(const char* const name, const Float limit) { inline Float lineMiterLengthLimit(const char* const name, const Float limit) {
#ifdef CORRADE_NO_ASSERT #if defined(CORRADE_NO_ASSERT) || defined(CORRADE_STANDARD_ASSERT)
static_cast<void>(name); static_cast<void>(name);
#endif #endif
CORRADE_ASSERT(limit >= 1.0f && !Math::isInf(limit), CORRADE_ASSERT(limit >= 1.0f && !Math::isInf(limit),
@ -43,7 +43,7 @@ inline Float lineMiterLengthLimit(const char* const name, const Float limit) {
inline Float lineMiterAngleLimit(const char* const name, const Rad limit) { inline Float lineMiterAngleLimit(const char* const name, const Rad limit) {
using namespace Math::Literals; using namespace Math::Literals;
#ifdef CORRADE_NO_ASSERT #if defined(CORRADE_NO_ASSERT) || defined(CORRADE_STANDARD_ASSERT)
static_cast<void>(name); static_cast<void>(name);
#endif #endif
CORRADE_ASSERT(limit > 0.0_radf && limit <= Rad{Constants::pi()}, CORRADE_ASSERT(limit > 0.0_radf && limit <= Rad{Constants::pi()},

21
src/Magnum/Trade/AbstractImageConverter.cpp

@ -293,7 +293,12 @@ Containers::Optional<ImageData3D> AbstractImageConverter::convert(const ImageDat
#ifndef CORRADE_NO_ASSERT #ifndef CORRADE_NO_ASSERT
namespace { namespace {
template<UnsignedInt dimensions, template<UnsignedInt, class> class View> bool checkImageValidity(const char* const messagePrefix, const View<dimensions, const char>& image) { template<UnsignedInt dimensions, template<UnsignedInt, class> class View> bool checkImageValidity(const char*
#ifndef CORRADE_STANDARD_ASSERT
const messagePrefix
#endif
, const View<dimensions, const char>& image)
{
/* At some point there might be a file format that allows zero-sized /* At some point there might be a file format that allows zero-sized
images, but so far I don't know about any. When such format appears, images, but so far I don't know about any. When such format appears,
this check will get moved to plugin implementations that can't work with this check will get moved to plugin implementations that can't work with
@ -560,7 +565,12 @@ AbstractImageConverter::convertToData(const ImageData3D& image) {
#ifndef CORRADE_NO_ASSERT #ifndef CORRADE_NO_ASSERT
namespace { namespace {
template<UnsignedInt dimensions> bool checkImageValidity(const char* const messagePrefix, const Containers::ArrayView<const BasicImageView<dimensions>> imageLevels) { template<UnsignedInt dimensions> bool checkImageValidity(const char*
#ifndef CORRADE_STANDARD_ASSERT
const messagePrefix
#endif
, const Containers::ArrayView<const BasicImageView<dimensions>> imageLevels)
{
CORRADE_ASSERT(!imageLevels.isEmpty(), CORRADE_ASSERT(!imageLevels.isEmpty(),
messagePrefix << "at least one image has to be specified", false); messagePrefix << "at least one image has to be specified", false);
@ -586,7 +596,12 @@ template<UnsignedInt dimensions> bool checkImageValidity(const char* const messa
return true; return true;
} }
template<UnsignedInt dimensions> bool checkImageValidity(const char* const messagePrefix, const Containers::ArrayView<const BasicCompressedImageView<dimensions>> imageLevels) { template<UnsignedInt dimensions> bool checkImageValidity(const char*
#ifndef CORRADE_STANDARD_ASSERT
const messagePrefix
#endif
, const Containers::ArrayView<const BasicCompressedImageView<dimensions>> imageLevels)
{
CORRADE_ASSERT(!imageLevels.isEmpty(), CORRADE_ASSERT(!imageLevels.isEmpty(),
messagePrefix << "at least one image has to be specified", false); messagePrefix << "at least one image has to be specified", false);

14
src/Magnum/Trade/AbstractSceneConverter.cpp

@ -905,7 +905,12 @@ bool AbstractSceneConverter::doAdd(UnsignedInt, const TextureData&, Containers::
#ifndef CORRADE_NO_ASSERT #ifndef CORRADE_NO_ASSERT
namespace { namespace {
template<UnsignedInt dimensions> bool checkImageValidity(const char* const messagePrefix, const ImageData<dimensions>& image) { template<UnsignedInt dimensions> bool checkImageValidity(const char*
#ifndef CORRADE_STANDARD_ASSERT
const messagePrefix
#endif
, const ImageData<dimensions>& image)
{
/* At some point there might be a file format that allows zero-sized /* At some point there might be a file format that allows zero-sized
images, but so far I don't know about any. When such format appears, images, but so far I don't know about any. When such format appears,
this check will get moved to plugin implementations that can't work with this check will get moved to plugin implementations that can't work with
@ -920,7 +925,12 @@ template<UnsignedInt dimensions> bool checkImageValidity(const char* const messa
return true; return true;
} }
template<UnsignedInt dimensions> bool checkImageValidity(const char* const messagePrefix, const Containers::Iterable<const ImageData<dimensions>>& imageLevels) { template<UnsignedInt dimensions> bool checkImageValidity(const char*
#ifndef CORRADE_STANDARD_ASSERT
const messagePrefix
#endif
, const Containers::Iterable<const ImageData<dimensions>>& imageLevels)
{
CORRADE_ASSERT(!imageLevels.isEmpty(), CORRADE_ASSERT(!imageLevels.isEmpty(),
messagePrefix << "at least one image level has to be specified", false); messagePrefix << "at least one image level has to be specified", false);

6
src/Magnum/Trade/MeshData.h

@ -2499,7 +2499,11 @@ template<class T> Containers::StridedArrayView1D<T> MeshData::mutableIndices() {
} }
#ifndef CORRADE_NO_ASSERT #ifndef CORRADE_NO_ASSERT
template<class T> bool MeshData::checkVertexFormatCompatibility(const MeshAttributeData& attribute, const char* const prefix) const { template<class T> bool MeshData::checkVertexFormatCompatibility(const MeshAttributeData& attribute, const char*
#ifndef CORRADE_STANDARD_ASSERT
const prefix
#endif
) const {
CORRADE_ASSERT(!isVertexFormatImplementationSpecific(attribute._format), CORRADE_ASSERT(!isVertexFormatImplementationSpecific(attribute._format),
prefix << "can't cast data from an implementation-specific vertex format" << reinterpret_cast<void*>(vertexFormatUnwrap(attribute._format)), false); prefix << "can't cast data from an implementation-specific vertex format" << reinterpret_cast<void*>(vertexFormatUnwrap(attribute._format)), false);
CORRADE_ASSERT(Implementation::isVertexFormatCompatible<typename std::remove_extent<T>::type>(attribute._format), CORRADE_ASSERT(Implementation::isVertexFormatCompatible<typename std::remove_extent<T>::type>(attribute._format),

6
src/Magnum/Trade/SceneData.h

@ -4162,7 +4162,11 @@ template<class T> Containers::StridedArrayView1D<T> SceneData::mutableMapping(co
} }
#ifndef CORRADE_NO_ASSERT #ifndef CORRADE_NO_ASSERT
template<class T> bool SceneData::checkFieldTypeCompatibility(const SceneFieldData& field, const char* const prefix) const { template<class T> bool SceneData::checkFieldTypeCompatibility(const SceneFieldData& field, const char*
#ifndef CORRADE_STANDARD_ASSERT
const prefix
#endif
) const {
CORRADE_ASSERT(Implementation::SceneFieldTypeTraits<typename std::remove_extent<T>::type>::isCompatible(field.fieldType()), CORRADE_ASSERT(Implementation::SceneFieldTypeTraits<typename std::remove_extent<T>::type>::isCompatible(field.fieldType()),
prefix << field._name << "is" << field.fieldType() << "but requested a type equivalent to" << Implementation::SceneFieldTypeFor<typename std::remove_extent<T>::type>::type(), false); prefix << field._name << "is" << field.fieldType() << "but requested a type equivalent to" << Implementation::SceneFieldTypeFor<typename std::remove_extent<T>::type>::type(), false);
CORRADE_ASSERT(!field.fieldArraySize() || std::is_array<T>::value, CORRADE_ASSERT(!field.fieldArraySize() || std::is_array<T>::value,

4
src/Magnum/Vk/Assert.h

@ -39,11 +39,11 @@
#ifndef CORRADE_STANDARD_ASSERT #ifndef CORRADE_STANDARD_ASSERT
#include <cstdlib> #include <cstdlib>
#include <Corrade/Utility/Debug.h> #include <Corrade/Utility/Debug.h>
#include "Magnum/Vk/Result.h"
#elif !defined(NDEBUG) #elif !defined(NDEBUG)
#include <cassert> #include <cassert>
#endif #endif
#include "Magnum/Vk/Result.h"
#endif #endif
/** /**

Loading…
Cancel
Save