Browse Source

I didn't expect new GCC would behave worse with deprecation warnings.

By now I tested on GCC 4.8, various Clang versions, most MSVC versions,
building the library was without warnings on all those, and so I
expected newer GCC to be also silent when it should be. Nope. Ugh.
next
Vladimír Vondruš 2 months ago
parent
commit
971ac890b5
  1. 19
      src/Magnum/Resource.h
  2. 28
      src/Magnum/ResourceManager.h

19
src/Magnum/Resource.h

@ -66,7 +66,10 @@ namespace Magnum {
@see @ref Resource::state(), @ref ResourceManager::state()
*/
enum class CORRADE_DEPRECATED_ENUM("the ResourceManager class is obsolete") ResourceState: UnsignedByte {
/* No CORRADE_DEPRECATED_ENUM() here, as it's already on the declaration in
Magnum.h and GCC stupidly warns that "type attributes ignored after type is
already defined". Happens for the other Resource* enums as well. */
enum class ResourceState: UnsignedByte {
/** The resource is not yet loaded (and no fallback is available). */
NotLoaded,
@ -179,15 +182,21 @@ class
* Creates empty resource. Resources are acquired from the manager by
* calling @ref ResourceManager::get().
*/
CORRADE_IGNORE_DEPRECATED_PUSH /* GCC except for 4.8 (!) warns here */
explicit Resource(): _manager{nullptr}, _lastCheck{0}, _state{ResourceState::Final}, _data{nullptr} {}
CORRADE_IGNORE_DEPRECATED_POP
/** @brief Copy constructor */
CORRADE_IGNORE_DEPRECATED_PUSH /* GCC except for 4.8 (!) warns here */
Resource(const Resource<T, U>& other): _manager{other._manager}, _key{other._key}, _lastCheck{other._lastCheck}, _state{other._state}, _data{other._data} {
if(_manager) _manager->incrementReferenceCount(_key);
}
CORRADE_IGNORE_DEPRECATED_POP
/** @brief Move constructor */
CORRADE_IGNORE_DEPRECATED_PUSH /* GCC except for 4.8 (!) warns here */
Resource(Resource<T, U>&& other) noexcept;
CORRADE_IGNORE_DEPRECATED_POP
/** @brief Destructor */
~Resource() {
@ -195,15 +204,21 @@ class
}
/** @brief Copy assignment */
CORRADE_IGNORE_DEPRECATED_PUSH /* GCC except for 4.8 (!) warns here */
Resource<T, U>& operator=(const Resource<T, U>& other);
CORRADE_IGNORE_DEPRECATED_POP
/** @brief Move assignment */
CORRADE_IGNORE_DEPRECATED_PUSH /* GCC except for 4.8 (!) warns here */
Resource<T, U>& operator=(Resource<T, U>&& other) noexcept;
CORRADE_IGNORE_DEPRECATED_POP
/** @brief Equality comparison */
CORRADE_IGNORE_DEPRECATED_PUSH /* GCC except for 4.8 (!) warns here */
bool operator==(const Resource<T, U>& other) const {
return _manager == other._manager && _key == other._key;
}
CORRADE_IGNORE_DEPRECATED_POP
/** @brief Equality comparison with other types is explicitly disallowed */
CORRADE_IGNORE_DEPRECATED_PUSH /* MSVC warns here */
@ -211,9 +226,11 @@ class
CORRADE_IGNORE_DEPRECATED_POP
/** @brief Non-equality comparison */
CORRADE_IGNORE_DEPRECATED_PUSH /* GCC except for 4.8 (!) warns here */
bool operator!=(const Resource<T, U>& other) const {
return !operator==(other);
}
CORRADE_IGNORE_DEPRECATED_POP
/** @brief Non-equality comparison with other types is explicitly disallowed */
CORRADE_IGNORE_DEPRECATED_PUSH /* MSVC warns here */

28
src/Magnum/ResourceManager.h

@ -60,7 +60,10 @@ namespace Magnum {
@see @ref ResourceManager::set(), @ref ResourceState
*/
CORRADE_IGNORE_DEPRECATED_PUSH /* MSVC warns for ResourceState usage */
enum class CORRADE_DEPRECATED_ENUM("the ResourceManager class is obsolete") ResourceDataState: UnsignedByte {
/* No CORRADE_DEPRECATED_ENUM() here, as it's already on the declaration in
Magnum.h and GCC stupidly warns that "type attributes ignored after type is
already defined". Happens for the other Resource* enums as well. */
enum class ResourceDataState: UnsignedByte {
/**
* The resource is currently loading. Parameter @p data in
* @ref ResourceManager::set() should be set to @cpp nullptr @ce.
@ -99,7 +102,10 @@ CORRADE_IGNORE_DEPRECATED_POP
@see @ref ResourceManager::set(), @ref ResourceManager::free()
*/
enum class CORRADE_DEPRECATED_ENUM("the ResourceManager class is obsolete") ResourcePolicy: UnsignedByte {
/* No CORRADE_DEPRECATED_ENUM() here, as it's already on the declaration in
Magnum.h and GCC stupidly warns that "type attributes ignored after type is
already defined". Happens for the other Resource* enums as well. */
enum class ResourcePolicy: UnsignedByte {
/** The resource will stay resident for whole lifetime of resource manager. */
Resident,
@ -386,42 +392,52 @@ template<class... Types> class CORRADE_DEPRECATED("the ResourceManager class is
* @brief Set fallback for not found resources
* @return Reference to self (for method chaining)
*/
CORRADE_IGNORE_DEPRECATED_PUSH /* GCC except for 4.8 (!) warns here */
template<class T> ResourceManager<Types...>& setFallback(T* data) {
this->Implementation::ResourceManagerData<T>::setFallback(data);
return *this;
}
CORRADE_IGNORE_DEPRECATED_POP
/**
* @overload
* @m_since{2019,10}
*/
CORRADE_IGNORE_DEPRECATED_PUSH /* GCC except for 4.8 (!) warns here */
template<class T> ResourceManager<Types...>& setFallback(Containers::Pointer<T>&& data) {
setFallback(data.release());
return *this;
}
CORRADE_IGNORE_DEPRECATED_POP
/** @overload */
CORRADE_IGNORE_DEPRECATED_PUSH /* GCC except for 4.8 (!) warns here */
template<class U> ResourceManager<Types...>& setFallback(U&& data) {
return setFallback(new typename std::decay<U>::type(std::forward<U>(data)));
}
CORRADE_IGNORE_DEPRECATED_POP
/**
* @brief Free all resources of given type which are not referenced
* @return Reference to self (for method chaining)
*/
CORRADE_IGNORE_DEPRECATED_PUSH /* GCC except for 4.8 (!) warns here */
template<class T> ResourceManager<Types...>& free() {
this->Implementation::ResourceManagerData<T>::free();
return *this;
}
CORRADE_IGNORE_DEPRECATED_POP
/**
* @brief Free all resources which are not referenced
* @return Reference to self (for method chaining)
*/
CORRADE_IGNORE_DEPRECATED_PUSH /* GCC except for 4.8 (!) warns here */
ResourceManager<Types...>& free() {
freeInternal(Implementation::ResourceTypePack<Types...>{});
return *this;
}
CORRADE_IGNORE_DEPRECATED_POP
/**
* @brief Clear all resources of given type
@ -430,10 +446,12 @@ template<class... Types> class CORRADE_DEPRECATED("the ResourceManager class is
* Unlike @ref free() this function assumes that no resource is
* referenced.
*/
CORRADE_IGNORE_DEPRECATED_PUSH /* GCC except for 4.8 (!) warns here */
template<class T> ResourceManager<Types...>& clear() {
this->Implementation::ResourceManagerData<T>::clear();
return *this;
}
CORRADE_IGNORE_DEPRECATED_POP
/**
* @brief Clear all resources
@ -442,10 +460,12 @@ template<class... Types> class CORRADE_DEPRECATED("the ResourceManager class is
* Unlike @ref free() this function assumes that no resource is
* referenced.
*/
CORRADE_IGNORE_DEPRECATED_PUSH /* GCC except for 4.8 (!) warns here */
ResourceManager<Types...>& clear() {
clearInternal(Implementation::ResourceTypePack<Types...>{});
return *this;
}
CORRADE_IGNORE_DEPRECATED_POP
/** @brief Loader for given type of resources */
template<class T> AbstractResourceLoader<T>* loader() {
@ -467,15 +487,19 @@ template<class... Types> class CORRADE_DEPRECATED("the ResourceManager class is
* @attention The loader is deleted on destruction before unloading
* all resources.
*/
CORRADE_IGNORE_DEPRECATED_PUSH /* GCC except for 4.8 (!) warns here */
template<class T> ResourceManager<Types...>& setLoader(AbstractResourceLoader<T>* loader) {
this->Implementation::ResourceManagerData<T>::setLoader(loader);
return *this;
}
CORRADE_IGNORE_DEPRECATED_POP
/** @overload */
CORRADE_IGNORE_DEPRECATED_PUSH /* GCC except for 4.8 (!) warns here */
template<class T> ResourceManager<Types...>& setLoader(Containers::Pointer<AbstractResourceLoader<T>>&& loader) {
return setLoader(loader.release());
}
CORRADE_IGNORE_DEPRECATED_POP
private:
template<class FirstType, class ...NextTypes> void freeInternal(Implementation::ResourceTypePack<FirstType, NextTypes...>) {

Loading…
Cancel
Save