workaround for weird symbol issue on nvc++

This commit is contained in:
Mark Gillard
2024-03-19 14:07:25 +09:00
parent a851257c49
commit 1f7884e591
7 changed files with 97 additions and 8 deletions

View File

@@ -21,8 +21,12 @@ template:
-->
## Unreleased
## v3.4.0
- fixed "unresolved symbol" error with nvc++ (#220) (@Tomcat-42)
#### Fixes
- fixed `value_flags` not being preserved correctly when inserting into tables and arrays (#108) (@LebJe)

View File

@@ -9,6 +9,13 @@
#include "source_region.hpp"
#include "header_start.hpp"
// workaround for this: https://github.com/marzer/tomlplusplus/issues/220
#if TOML_NVCC
#define TOML_NVCC_WORKAROUND { return {}; }
#else
#define TOML_NVCC_WORKAROUND = 0
#endif
TOML_NAMESPACE_START
{
/// \brief A TOML node.
@@ -246,11 +253,11 @@ TOML_NAMESPACE_START
/// \brief Returns the node's type identifier.
TOML_PURE_GETTER
virtual node_type type() const noexcept = 0;
virtual node_type type() const noexcept TOML_NVCC_WORKAROUND;
/// \brief Returns true if this node is a table.
TOML_PURE_GETTER
virtual bool is_table() const noexcept = 0;
virtual bool is_table() const noexcept TOML_NVCC_WORKAROUND;
/// \brief Returns true if this node is an array.
TOML_PURE_GETTER
@@ -258,7 +265,7 @@ TOML_NAMESPACE_START
/// \brief Returns true if this node is an array containing only tables.
TOML_PURE_GETTER
virtual bool is_array_of_tables() const noexcept = 0;
virtual bool is_array_of_tables() const noexcept TOML_NVCC_WORKAROUND;
/// \brief Returns true if this node is a value.
TOML_PURE_GETTER
@@ -327,6 +334,8 @@ TOML_NAMESPACE_START
return is_time();
else if constexpr (std::is_same_v<type, date_time>)
return is_date_time();
TOML_UNREACHABLE;
}
/// @}
@@ -452,6 +461,8 @@ TOML_NAMESPACE_START
return as_time();
else if constexpr (std::is_same_v<unwrapped_type, date_time>)
return as_date_time();
TOML_UNREACHABLE;
}
/// \brief Gets a pointer to the node as a more specific node type (const overload).
@@ -481,6 +492,8 @@ TOML_NAMESPACE_START
return as_time();
else if constexpr (std::is_same_v<unwrapped_type, date_time>)
return as_date_time();
TOML_UNREACHABLE;
}
/// @}
@@ -1112,4 +1125,5 @@ TOML_IMPL_NAMESPACE_START
TOML_IMPL_NAMESPACE_END;
/// \endcond
#undef TOML_NVCC_WORKAROUND
#include "header_end.hpp"

View File

@@ -175,6 +175,14 @@
#endif
#endif
#ifndef TOML_NVCC
#ifdef __NVCOMPILER_MAJOR__
#define TOML_NVCC __NVCOMPILER_MAJOR__
#else
#define TOML_NVCC 0
#endif
#endif
//#=====================================================================================================================
//# ARCHITECTURE
//#=====================================================================================================================
@@ -395,6 +403,7 @@
#endif
// TOML_ALWAYS_INLINE
#ifndef TOML_ALWAYS_INLINE
#ifdef _MSC_VER
#define TOML_ALWAYS_INLINE __forceinline
#elif TOML_GCC || TOML_CLANG || TOML_HAS_ATTR(__always_inline__)
@@ -404,8 +413,10 @@
#else
#define TOML_ALWAYS_INLINE inline
#endif
#endif
// TOML_NEVER_INLINE
#ifndef TOML_NEVER_INLINE
#ifdef _MSC_VER
#define TOML_NEVER_INLINE TOML_DECLSPEC(noinline)
#elif TOML_CUDA // https://gitlab.gnome.org/GNOME/glib/-/issues/2555
@@ -418,19 +429,27 @@
#ifndef TOML_NEVER_INLINE
#define TOML_NEVER_INLINE
#endif
#endif
// MSVC attributes
#ifndef TOML_ABSTRACT_INTERFACE
#define TOML_ABSTRACT_INTERFACE TOML_DECLSPEC(novtable)
#endif
#ifndef TOML_EMPTY_BASES
#define TOML_EMPTY_BASES TOML_DECLSPEC(empty_bases)
#endif
// TOML_TRIVIAL_ABI
#ifndef TOML_TRIVIAL_ABI
#if TOML_CLANG || TOML_HAS_ATTR(__trivial_abi__)
#define TOML_TRIVIAL_ABI TOML_ATTR(__trivial_abi__)
#else
#define TOML_TRIVIAL_ABI
#endif
#endif
// TOML_NODISCARD
#ifndef TOML_NODISCARD
#if TOML_CPP >= 17 && TOML_HAS_CPP_ATTR(nodiscard) >= 201603
#define TOML_NODISCARD [[nodiscard]]
#elif TOML_CLANG || TOML_GCC || TOML_HAS_ATTR(__warn_unused_result__)
@@ -438,13 +457,16 @@
#else
#define TOML_NODISCARD
#endif
#endif
// TOML_NODISCARD_CTOR
#ifndef TOML_NODISCARD_CTOR
#if TOML_CPP >= 17 && TOML_HAS_CPP_ATTR(nodiscard) >= 201907
#define TOML_NODISCARD_CTOR [[nodiscard]]
#else
#define TOML_NODISCARD_CTOR
#endif
#endif
// pure + const
#ifndef TOML_PURE
@@ -494,6 +516,7 @@
#endif
// TOML_ASSUME
#ifndef TOML_ASSUME
#ifdef _MSC_VER
#define TOML_ASSUME(expr) __assume(expr)
#elif TOML_ICC || TOML_CLANG || TOML_HAS_BUILTIN(__builtin_assume)
@@ -505,8 +528,10 @@
#else
#define TOML_ASSUME(expr) static_cast<void>(0)
#endif
#endif
// TOML_UNREACHABLE
#ifndef TOML_UNREACHABLE
#ifdef _MSC_VER
#define TOML_UNREACHABLE __assume(0)
#elif TOML_ICC || TOML_CLANG || TOML_GCC || TOML_HAS_BUILTIN(__builtin_unreachable)
@@ -514,6 +539,7 @@
#else
#define TOML_UNREACHABLE static_cast<void>(0)
#endif
#endif
// TOML_LIKELY
#if TOML_CPP >= 20 && TOML_HAS_CPP_ATTR(likely) >= 201803

View File

@@ -1527,6 +1527,8 @@ TOML_NAMESPACE_START
}
return iterator{ ipos };
}
TOML_UNREACHABLE;
}
/// \brief Inserts a new value at a specific key if one did not already exist.

View File

@@ -92,7 +92,6 @@ TOML_ANON_NAMESPACE_START
val *= -1.0;
}
return weight + static_cast<size_t>(log10(val)) + 1u;
break;
}
case node_type::boolean: return 5u;

View File

@@ -184,6 +184,7 @@ TOML_POP_WARNINGS;
#undef TOML_NEVER_INLINE
#undef TOML_NODISCARD
#undef TOML_NODISCARD_CTOR
#undef TOML_NVCC
#undef TOML_OPEN_ENUM
#undef TOML_OPEN_FLAGS_ENUM
#undef TOML_PARSER_TYPENAME

View File

@@ -212,6 +212,14 @@
#endif
#endif
#ifndef TOML_NVCC
#ifdef __NVCOMPILER_MAJOR__
#define TOML_NVCC __NVCOMPILER_MAJOR__
#else
#define TOML_NVCC 0
#endif
#endif
#ifndef TOML_ARCH_ITANIUM
#if defined(__ia64__) || defined(__ia64) || defined(_IA64) || defined(__IA64__) || defined(_M_IA64)
#define TOML_ARCH_ITANIUM 1
@@ -420,6 +428,7 @@
#endif
// TOML_ALWAYS_INLINE
#ifndef TOML_ALWAYS_INLINE
#ifdef _MSC_VER
#define TOML_ALWAYS_INLINE __forceinline
#elif TOML_GCC || TOML_CLANG || TOML_HAS_ATTR(__always_inline__)
@@ -429,8 +438,10 @@
#else
#define TOML_ALWAYS_INLINE inline
#endif
#endif
// TOML_NEVER_INLINE
#ifndef TOML_NEVER_INLINE
#ifdef _MSC_VER
#define TOML_NEVER_INLINE TOML_DECLSPEC(noinline)
#elif TOML_CUDA // https://gitlab.gnome.org/GNOME/glib/-/issues/2555
@@ -443,19 +454,27 @@
#ifndef TOML_NEVER_INLINE
#define TOML_NEVER_INLINE
#endif
#endif
// MSVC attributes
#ifndef TOML_ABSTRACT_INTERFACE
#define TOML_ABSTRACT_INTERFACE TOML_DECLSPEC(novtable)
#endif
#ifndef TOML_EMPTY_BASES
#define TOML_EMPTY_BASES TOML_DECLSPEC(empty_bases)
#endif
// TOML_TRIVIAL_ABI
#ifndef TOML_TRIVIAL_ABI
#if TOML_CLANG || TOML_HAS_ATTR(__trivial_abi__)
#define TOML_TRIVIAL_ABI TOML_ATTR(__trivial_abi__)
#else
#define TOML_TRIVIAL_ABI
#endif
#endif
// TOML_NODISCARD
#ifndef TOML_NODISCARD
#if TOML_CPP >= 17 && TOML_HAS_CPP_ATTR(nodiscard) >= 201603
#define TOML_NODISCARD [[nodiscard]]
#elif TOML_CLANG || TOML_GCC || TOML_HAS_ATTR(__warn_unused_result__)
@@ -463,13 +482,16 @@
#else
#define TOML_NODISCARD
#endif
#endif
// TOML_NODISCARD_CTOR
#ifndef TOML_NODISCARD_CTOR
#if TOML_CPP >= 17 && TOML_HAS_CPP_ATTR(nodiscard) >= 201907
#define TOML_NODISCARD_CTOR [[nodiscard]]
#else
#define TOML_NODISCARD_CTOR
#endif
#endif
// pure + const
#ifndef TOML_PURE
@@ -519,6 +541,7 @@
#endif
// TOML_ASSUME
#ifndef TOML_ASSUME
#ifdef _MSC_VER
#define TOML_ASSUME(expr) __assume(expr)
#elif TOML_ICC || TOML_CLANG || TOML_HAS_BUILTIN(__builtin_assume)
@@ -530,8 +553,10 @@
#else
#define TOML_ASSUME(expr) static_cast<void>(0)
#endif
#endif
// TOML_UNREACHABLE
#ifndef TOML_UNREACHABLE
#ifdef _MSC_VER
#define TOML_UNREACHABLE __assume(0)
#elif TOML_ICC || TOML_CLANG || TOML_GCC || TOML_HAS_BUILTIN(__builtin_unreachable)
@@ -539,6 +564,7 @@
#else
#define TOML_UNREACHABLE static_cast<void>(0)
#endif
#endif
// TOML_LIKELY
#if TOML_CPP >= 20 && TOML_HAS_CPP_ATTR(likely) >= 201803
@@ -3614,6 +3640,13 @@ TOML_PUSH_WARNINGS;
#undef max
#endif
// workaround for this: https://github.com/marzer/tomlplusplus/issues/220
#if TOML_NVCC
#define TOML_NVCC_WORKAROUND { return {}; }
#else
#define TOML_NVCC_WORKAROUND = 0
#endif
TOML_NAMESPACE_START
{
class TOML_ABSTRACT_INTERFACE TOML_EXPORTED_CLASS node
@@ -3756,16 +3789,16 @@ TOML_NAMESPACE_START
}
TOML_PURE_GETTER
virtual node_type type() const noexcept = 0;
virtual node_type type() const noexcept TOML_NVCC_WORKAROUND;
TOML_PURE_GETTER
virtual bool is_table() const noexcept = 0;
virtual bool is_table() const noexcept TOML_NVCC_WORKAROUND;
TOML_PURE_GETTER
virtual bool is_array() const noexcept = 0;
TOML_PURE_GETTER
virtual bool is_array_of_tables() const noexcept = 0;
virtual bool is_array_of_tables() const noexcept TOML_NVCC_WORKAROUND;
TOML_PURE_GETTER
virtual bool is_value() const noexcept = 0;
@@ -3820,6 +3853,8 @@ TOML_NAMESPACE_START
return is_time();
else if constexpr (std::is_same_v<type, date_time>)
return is_date_time();
TOML_UNREACHABLE;
}
TOML_PURE_GETTER
@@ -3902,6 +3937,8 @@ TOML_NAMESPACE_START
return as_time();
else if constexpr (std::is_same_v<unwrapped_type, date_time>)
return as_date_time();
TOML_UNREACHABLE;
}
template <typename T>
@@ -3930,6 +3967,8 @@ TOML_NAMESPACE_START
return as_time();
else if constexpr (std::is_same_v<unwrapped_type, date_time>)
return as_date_time();
TOML_UNREACHABLE;
}
template <typename T>
@@ -4207,6 +4246,8 @@ TOML_IMPL_NAMESPACE_START
}
TOML_IMPL_NAMESPACE_END;
#undef TOML_NVCC_WORKAROUND
#ifdef _MSC_VER
#pragma pop_macro("min")
#pragma pop_macro("max")
@@ -8416,6 +8457,8 @@ TOML_NAMESPACE_START
}
return iterator{ ipos };
}
TOML_UNREACHABLE;
}
TOML_CONSTRAINED_TEMPLATE((is_key_or_convertible<KeyType&&> || impl::is_wide_string<KeyType>),
@@ -16976,7 +17019,6 @@ TOML_ANON_NAMESPACE_START
val *= -1.0;
}
return weight + static_cast<size_t>(log10(val)) + 1u;
break;
}
case node_type::boolean: return 5u;
@@ -17701,6 +17743,7 @@ TOML_POP_WARNINGS;
#undef TOML_NEVER_INLINE
#undef TOML_NODISCARD
#undef TOML_NODISCARD_CTOR
#undef TOML_NVCC
#undef TOML_OPEN_ENUM
#undef TOML_OPEN_FLAGS_ENUM
#undef TOML_PARSER_TYPENAME