Browse Source

Ignore Clang's -Wdeprecated-literal-operator until we can drop GCC 4.8.

And also remove the other space, to be consistent with Doxygen links,
what Corrade uses, and have the literals easier to search for.
pull/364/merge
Vladimír Vondruš 2 years ago
parent
commit
cce12a27fb
  1. 28
      src/Magnum/Math/Angle.h
  2. 14
      src/Magnum/Math/Color.h
  3. 14
      src/Magnum/Math/Half.h
  4. 14
      src/Magnum/Math/Time.h

28
src/Magnum/Math/Angle.h

@ -157,6 +157,17 @@ namespace Literals {
#endif #endif
namespace AngleLiterals { namespace AngleLiterals {
/* According to https://wg21.link/CWG2521, space between "" and literal name is
deprecated because _Uppercase or __double names could be treated as reserved
depending on whether the space was present or not, and whitespace is not
load-bearing in any other contexts. Clang 17+ adds an off-by-default warning
for this; GCC 4.8 however *requires* the space there, so until GCC 4.8
support is dropped, we suppress this warning instead of removing the
space. */
#if defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 17
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-literal-operator"
#endif
/** @relatesalso Magnum::Math::Deg /** @relatesalso Magnum::Math::Deg
@brief Double-precision degree value literal @brief Double-precision degree value literal
@ -180,6 +191,9 @@ Example usage:
@m_keywords{_degf degf} @m_keywords{_degf degf}
*/ */
constexpr Deg<Float> operator"" _degf(long double value) { return Deg<Float>(Float(value)); } constexpr Deg<Float> operator"" _degf(long double value) { return Deg<Float>(Float(value)); }
#if defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 17
#pragma clang diagnostic pop
#endif
}} }}
@ -246,6 +260,17 @@ namespace Literals {
#endif #endif
namespace AngleLiterals { namespace AngleLiterals {
/* According to https://wg21.link/CWG2521, space between "" and literal name is
deprecated because _Uppercase or __double names could be treated as reserved
depending on whether the space was present or not, and whitespace is not
load-bearing in any other contexts. Clang 17+ adds an off-by-default warning
for this; GCC 4.8 however *requires* the space there, so until GCC 4.8
support is dropped, we suppress this warning instead of removing the
space. */
#if defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 17
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-literal-operator"
#endif
/** @relatesalso Magnum::Math::Rad /** @relatesalso Magnum::Math::Rad
@brief Double-precision radian value literal @brief Double-precision radian value literal
@ -263,6 +288,9 @@ See @link operator""_degf() @endlink for more information.
@m_keywords{_radf radf} @m_keywords{_radf radf}
*/ */
constexpr Rad<Float> operator"" _radf(long double value) { return Rad<Float>(Float(value)); } constexpr Rad<Float> operator"" _radf(long double value) { return Rad<Float>(Float(value)); }
#if defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 17
#pragma clang diagnostic pop
#endif
}} }}

14
src/Magnum/Math/Color.h

@ -1325,6 +1325,17 @@ namespace Literals {
#endif #endif
namespace ColorLiterals { namespace ColorLiterals {
/* According to https://wg21.link/CWG2521, space between "" and literal name is
deprecated because _Uppercase or __double names could be treated as reserved
depending on whether the space was present or not, and whitespace is not
load-bearing in any other contexts. Clang 17+ adds an off-by-default warning
for this; GCC 4.8 however *requires* the space there, so until GCC 4.8
support is dropped, we suppress this warning instead of removing the
space. */
#if defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 17
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-literal-operator"
#endif
/** @relatesalso Magnum::Math::Color3 /** @relatesalso Magnum::Math::Color3
@brief 8bit-per-channel linear RGB literal @brief 8bit-per-channel linear RGB literal
@ -1490,6 +1501,9 @@ Calls @ref Color4::fromSrgbAlphaInt() on the literal value. Example usage:
inline Color4<Float> operator"" _srgbaf(unsigned long long value) { inline Color4<Float> operator"" _srgbaf(unsigned long long value) {
return Color4<Float>::fromSrgbAlphaInt(UnsignedInt(value)); return Color4<Float>::fromSrgbAlphaInt(UnsignedInt(value));
} }
#if defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 17
#pragma clang diagnostic pop
#endif
}} }}

14
src/Magnum/Math/Half.h

@ -183,12 +183,26 @@ namespace Literals {
#endif #endif
namespace HalfLiterals { namespace HalfLiterals {
/* According to https://wg21.link/CWG2521, space between "" and literal name is
deprecated because _Uppercase or __double names could be treated as reserved
depending on whether the space was present or not, and whitespace is not
load-bearing in any other contexts. Clang 17+ adds an off-by-default warning
for this; GCC 4.8 however *requires* the space there, so until GCC 4.8
support is dropped, we suppress this warning instead of removing the
space. */
#if defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 17
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-literal-operator"
#endif
/** @relatesalso Magnum::Math::Half /** @relatesalso Magnum::Math::Half
@brief Half-float literal @brief Half-float literal
See @ref Half for more information. See @ref Half for more information.
*/ */
inline Half operator"" _h(long double value) { return Half(Float(value)); } inline Half operator"" _h(long double value) { return Half(Float(value)); }
#if defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 17
#pragma clang diagnostic pop
#endif
}} }}

14
src/Magnum/Math/Time.h

@ -288,6 +288,17 @@ namespace Literals {
everything already. Seeing 15.0_sec in unfamiliar code doesn't feel everything already. Seeing 15.0_sec in unfamiliar code doesn't feel
ambiguous, seeing 127_s or 0.5_h definitely does. */ ambiguous, seeing 127_s or 0.5_h definitely does. */
/* According to https://wg21.link/CWG2521, space between "" and literal name is
deprecated because _Uppercase or __double names could be treated as reserved
depending on whether the space was present or not, and whitespace is not
load-bearing in any other contexts. Clang 17+ adds an off-by-default warning
for this; GCC 4.8 however *requires* the space there, so until GCC 4.8
support is dropped, we suppress this warning instead of removing the
space. */
#if defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 17
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-literal-operator"
#endif
/** @relatesalso Magnum::Math::Nanoseconds /** @relatesalso Magnum::Math::Nanoseconds
@brief Nanosecond value literal @brief Nanosecond value literal
@m_since_latest @m_since_latest
@ -374,6 +385,9 @@ precision on a range of roughly ±2 hours. For example:
constexpr Nanoseconds<Long> operator"" _sec(long double value) { constexpr Nanoseconds<Long> operator"" _sec(long double value) {
return Nanoseconds<Long>{Long(value*1000000000.0l)}; return Nanoseconds<Long>{Long(value*1000000000.0l)};
} }
#if defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 17
#pragma clang diagnostic pop
#endif
}} }}

Loading…
Cancel
Save