TOML_GCC_ATTR => TOML_GNU_ATTR

This commit is contained in:
Mark Gillard 2020-03-22 12:02:56 +02:00
parent f1664fa068
commit 60853e27db
4 changed files with 50 additions and 34 deletions

View File

@ -36,7 +36,7 @@
// macro hygiene
#if TOML_UNDEF_MACROS
#undef TOML_USE_STREAMS_FOR_FLOATS
#undef TOML_GCC_ATTR
#undef TOML_GNU_ATTR
#undef TOML_PUSH_WARNINGS
#undef TOML_DISABLE_SWITCH_WARNINGS
#undef TOML_DISABLE_INIT_WARNINGS

View File

@ -64,17 +64,25 @@
#define TOML_DISABLE_INIT_WARNINGS _Pragma("clang diagnostic ignored \"-Wmissing-field-initializers\"")
#define TOML_DISABLE_ALL_WARNINGS _Pragma("clang diagnostic ignored \"-Weverything\"")
#define TOML_POP_WARNINGS _Pragma("clang diagnostic pop")
#define TOML_GCC_ATTR(attr) __attribute__((attr))
#define TOML_ALWAYS_INLINE TOML_GCC_ATTR(__always_inline__) inline
#define TOML_ASSUME(cond) __builtin_assume(cond)
#define TOML_UNREACHABLE __builtin_unreachable()
#if defined(_MSC_VER) && defined(__has_declspec_attribute)
#if defined(_MSC_VER) // msvc compat mode
#if defined(__has_declspec_attribute)
#if __has_declspec_attribute(novtable)
#define TOML_INTERFACE __declspec(novtable)
#endif
#if __has_declspec_attribute(empty_bases)
#define TOML_EMPTY_BASES __declspec(empty_bases)
#endif
#define TOML_ALWAYS_INLINE __forceinline
#endif
#else // regular ol' clang
#define TOML_GNU_ATTR(attr) __attribute__((attr))
#ifdef __has_attribute
#if __has_attribute(always_inline)
#define TOML_ALWAYS_INLINE __attribute__((__always_inline__)) inline
#endif
#endif
#endif
#ifdef __EXCEPTIONS
#define TOML_COMPILER_EXCEPTIONS 1
@ -117,8 +125,8 @@
_Pragma("GCC diagnostic ignored \"-Wchar-subscripts\"") \
_Pragma("GCC diagnostic ignored \"-Wtype-limits\"")
#define TOML_POP_WARNINGS _Pragma("GCC diagnostic pop")
#define TOML_GCC_ATTR(attr) __attribute__((attr))
#define TOML_ALWAYS_INLINE TOML_GCC_ATTR(__always_inline__) inline
#define TOML_GNU_ATTR(attr) __attribute__((attr))
#define TOML_ALWAYS_INLINE __attribute__((__always_inline__)) inline
#define TOML_UNREACHABLE __builtin_unreachable()
#if !defined(TOML_RELOPS_REORDERING) && defined(__cpp_impl_three_way_comparison)
#define TOML_RELOPS_REORDERING 1
@ -195,8 +203,8 @@
#ifndef TOML_POP_WARNINGS
#define TOML_POP_WARNINGS
#endif
#ifndef TOML_GCC_ATTR
#define TOML_GCC_ATTR(attr)
#ifndef TOML_GNU_ATTR
#define TOML_GNU_ATTR(attr)
#endif
#ifndef TOML_INTERFACE
#define TOML_INTERFACE
@ -706,18 +714,18 @@ TOML_START
public:
TOML_NODISCARD_CTOR TOML_GCC_ATTR(nonnull)
TOML_NODISCARD_CTOR TOML_GNU_ATTR(nonnull)
parse_error(const char* desc, source_region&& src) noexcept
: std::runtime_error{ desc },
source_{ std::move(src) }
{}
TOML_NODISCARD_CTOR TOML_GCC_ATTR(nonnull)
TOML_NODISCARD_CTOR TOML_GNU_ATTR(nonnull)
parse_error(const char* desc, const source_region& src) noexcept
: parse_error{ desc, source_region{ src } }
{}
TOML_NODISCARD_CTOR TOML_GCC_ATTR(nonnull)
TOML_NODISCARD_CTOR TOML_GNU_ATTR(nonnull)
parse_error(const char* desc, const source_position& position, const source_path_ptr& path = {}) noexcept
: parse_error{ desc, source_region{ position, position, path } }
{}

View File

@ -46,7 +46,7 @@ TOML_IMPL_START
}
template <typename CHAR>
TOML_GCC_ATTR(nonnull) TOML_ALWAYS_INLINE
TOML_GNU_ATTR(nonnull) TOML_ALWAYS_INLINE
void print_to_stream(const char* str, size_t len, std::basic_ostream<CHAR>& stream) TOML_MAY_THROW
{
static_assert(sizeof(CHAR) == 1);
@ -64,7 +64,7 @@ TOML_IMPL_START
}
template <typename CHAR>
TOML_GCC_ATTR(nonnull) TOML_ALWAYS_INLINE
TOML_GNU_ATTR(nonnull) TOML_ALWAYS_INLINE
void print_to_stream(const char8_t* str, size_t len, std::basic_ostream<CHAR>& stream) TOML_MAY_THROW
{
static_assert(sizeof(CHAR) == 1);

View File

@ -105,17 +105,25 @@
#define TOML_DISABLE_INIT_WARNINGS _Pragma("clang diagnostic ignored \"-Wmissing-field-initializers\"")
#define TOML_DISABLE_ALL_WARNINGS _Pragma("clang diagnostic ignored \"-Weverything\"")
#define TOML_POP_WARNINGS _Pragma("clang diagnostic pop")
#define TOML_GCC_ATTR(attr) __attribute__((attr))
#define TOML_ALWAYS_INLINE TOML_GCC_ATTR(__always_inline__) inline
#define TOML_ASSUME(cond) __builtin_assume(cond)
#define TOML_UNREACHABLE __builtin_unreachable()
#if defined(_MSC_VER) && defined(__has_declspec_attribute)
#if defined(_MSC_VER) // msvc compat mode
#if defined(__has_declspec_attribute)
#if __has_declspec_attribute(novtable)
#define TOML_INTERFACE __declspec(novtable)
#endif
#if __has_declspec_attribute(empty_bases)
#define TOML_EMPTY_BASES __declspec(empty_bases)
#endif
#define TOML_ALWAYS_INLINE __forceinline
#endif
#else // regular ol' clang
#define TOML_GNU_ATTR(attr) __attribute__((attr))
#ifdef __has_attribute
#if __has_attribute(always_inline)
#define TOML_ALWAYS_INLINE __attribute__((__always_inline__)) inline
#endif
#endif
#endif
#ifdef __EXCEPTIONS
#define TOML_COMPILER_EXCEPTIONS 1
@ -158,8 +166,8 @@
_Pragma("GCC diagnostic ignored \"-Wchar-subscripts\"") \
_Pragma("GCC diagnostic ignored \"-Wtype-limits\"")
#define TOML_POP_WARNINGS _Pragma("GCC diagnostic pop")
#define TOML_GCC_ATTR(attr) __attribute__((attr))
#define TOML_ALWAYS_INLINE TOML_GCC_ATTR(__always_inline__) inline
#define TOML_GNU_ATTR(attr) __attribute__((attr))
#define TOML_ALWAYS_INLINE __attribute__((__always_inline__)) inline
#define TOML_UNREACHABLE __builtin_unreachable()
#if !defined(TOML_RELOPS_REORDERING) && defined(__cpp_impl_three_way_comparison)
#define TOML_RELOPS_REORDERING 1
@ -236,8 +244,8 @@
#ifndef TOML_POP_WARNINGS
#define TOML_POP_WARNINGS
#endif
#ifndef TOML_GCC_ATTR
#define TOML_GCC_ATTR(attr)
#ifndef TOML_GNU_ATTR
#define TOML_GNU_ATTR(attr)
#endif
#ifndef TOML_INTERFACE
#define TOML_INTERFACE
@ -594,18 +602,18 @@ TOML_START
public:
TOML_NODISCARD_CTOR TOML_GCC_ATTR(nonnull)
TOML_NODISCARD_CTOR TOML_GNU_ATTR(nonnull)
parse_error(const char* desc, source_region&& src) noexcept
: std::runtime_error{ desc },
source_{ std::move(src) }
{}
TOML_NODISCARD_CTOR TOML_GCC_ATTR(nonnull)
TOML_NODISCARD_CTOR TOML_GNU_ATTR(nonnull)
parse_error(const char* desc, const source_region& src) noexcept
: parse_error{ desc, source_region{ src } }
{}
TOML_NODISCARD_CTOR TOML_GCC_ATTR(nonnull)
TOML_NODISCARD_CTOR TOML_GNU_ATTR(nonnull)
parse_error(const char* desc, const source_position& position, const source_path_ptr& path = {}) noexcept
: parse_error{ desc, source_region{ position, position, path } }
{}
@ -1226,7 +1234,7 @@ TOML_IMPL_START
}
template <typename CHAR>
TOML_GCC_ATTR(nonnull) TOML_ALWAYS_INLINE
TOML_GNU_ATTR(nonnull) TOML_ALWAYS_INLINE
void print_to_stream(const char* str, size_t len, std::basic_ostream<CHAR>& stream) TOML_MAY_THROW
{
static_assert(sizeof(CHAR) == 1);
@ -1244,7 +1252,7 @@ TOML_IMPL_START
}
template <typename CHAR>
TOML_GCC_ATTR(nonnull) TOML_ALWAYS_INLINE
TOML_GNU_ATTR(nonnull) TOML_ALWAYS_INLINE
void print_to_stream(const char8_t* str, size_t len, std::basic_ostream<CHAR>& stream) TOML_MAY_THROW
{
static_assert(sizeof(CHAR) == 1);
@ -9157,7 +9165,7 @@ TOML_END
// macro hygiene
#if TOML_UNDEF_MACROS
#undef TOML_USE_STREAMS_FOR_FLOATS
#undef TOML_GCC_ATTR
#undef TOML_GNU_ATTR
#undef TOML_PUSH_WARNINGS
#undef TOML_DISABLE_SWITCH_WARNINGS
#undef TOML_DISABLE_INIT_WARNINGS