Skip to content
This repository was archived by the owner on Apr 1, 2025. It is now read-only.

Commit 8d0fe6c

Browse files
authored
Replace BOND_NORETURN with [[noreturn]]
Bond requires a C++11 compiler, The `[[noreturn]]` attribute is part of C++11 and is supported by all of the minimum versions of the compilers Bond supports. Replace the `BOND_NORETURN` macro with the `[[noreturn]]` attribute. The platform/compiler adapter macros are considered implementation details of Bond. The removal of `BOND_NORETURN` is not considered a breaking change.
1 parent fa9723e commit 8d0fe6c

File tree

11 files changed

+40
-29
lines changed

11 files changed

+40
-29
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ tag versions. The Bond compiler (`gbc`) and
1111
different versioning scheme, following the Haskell community's
1212
[package versioning policy](https://wiki.haskell.org/Package_versioning_policy).
1313

14+
## Unreleased ##
15+
16+
* IDL core version: TBD
17+
* C++ version: TBD, bug fix bump needed
18+
* C# NuGet version: TBD
19+
* `gbc` & compiler library: TBD
20+
21+
### C++ ###
22+
23+
* Bond now uses the `[[noreturn]]` attribute to annotate functions that do
24+
not return. Previously, it used compiler-specific annotations.
25+
1426
## 9.0.3: 2020-08-06 ##
1527

1628
* IDL core version: 3.0

cpp/inc/bond/core/config.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
#define BOND_NOEXCEPT BOOST_NOEXCEPT_OR_NOTHROW
5959
#define BOND_NOEXCEPT_IF BOOST_NOEXCEPT_IF
6060
#define BOND_NOEXCEPT_EXPR BOOST_NOEXCEPT_EXPR
61-
#define BOND_NORETURN BOOST_NORETURN
6261
#define BOND_CONSTEXPR BOOST_CONSTEXPR
6362
#define BOND_CONSTEXPR_OR_CONST BOOST_CONSTEXPR_OR_CONST
6463
#define BOND_STATIC_CONSTEXPR BOOST_STATIC_CONSTEXPR

cpp/inc/bond/core/detail/validate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class SchemaValidator
235235
}
236236

237237
template <typename T>
238-
BOND_NORETURN bool UnknownField(uint16_t id, const T&) const
238+
[[noreturn]] bool UnknownField(uint16_t id, const T&) const
239239
{
240240
UnknownSchemaDefException(id);
241241
}

cpp/inc/bond/core/exception.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ struct CoreException
5353
};
5454

5555

56-
BOND_NORETURN inline void MergerContainerException(uint32_t payload, uint32_t obj)
56+
[[noreturn]] inline void MergerContainerException(uint32_t payload, uint32_t obj)
5757
{
5858
BOND_THROW(CoreException,
5959
"Merge failed: container mismatch, length in the payload: "
6060
<< payload << " length in the object: " << obj);
6161
}
6262

6363

64-
BOND_NORETURN inline void InvalidKeyTypeException()
64+
[[noreturn]] inline void InvalidKeyTypeException()
6565
{
6666
BOND_THROW(CoreException,
6767
"Map key type not valid");
@@ -71,7 +71,7 @@ BOND_NORETURN inline void InvalidKeyTypeException()
7171
namespace detail
7272
{
7373
template <typename Key>
74-
BOND_NORETURN inline void ElementNotFoundExceptionHelper(
74+
[[noreturn]] inline void ElementNotFoundExceptionHelper(
7575
const Key& key,
7676
typename boost::enable_if<is_wstring<Key>>::type* = nullptr)
7777
{
@@ -91,7 +91,7 @@ namespace detail
9191
}
9292

9393
template <typename Key>
94-
BOND_NORETURN inline void ElementNotFoundExceptionHelper(
94+
[[noreturn]] inline void ElementNotFoundExceptionHelper(
9595
const Key& key,
9696
typename boost::disable_if<is_wstring<Key>>::type* = nullptr)
9797
{
@@ -102,56 +102,56 @@ namespace detail
102102

103103

104104
template <typename Key>
105-
BOND_NORETURN inline void ElementNotFoundException(const Key& key)
105+
[[noreturn]] inline void ElementNotFoundException(const Key& key)
106106
{
107107
detail::ElementNotFoundExceptionHelper(key);
108108
}
109109

110110

111-
BOND_NORETURN inline void UnknownProtocolException()
111+
[[noreturn]] inline void UnknownProtocolException()
112112
{
113113
BOND_THROW(CoreException,
114114
"Unmarshaling failed: unsupported protocol");
115115
}
116116

117117

118-
BOND_NORETURN inline void UnknownProtocolException(uint16_t magic)
118+
[[noreturn]] inline void UnknownProtocolException(uint16_t magic)
119119
{
120120
BOND_THROW(CoreException,
121121
"Unsupported protocol: "
122122
<< (char)(magic & 0xFF) << (char)(magic >> 8));
123123
}
124124

125125

126-
BOND_NORETURN inline void NothingException()
126+
[[noreturn]] inline void NothingException()
127127
{
128128
BOND_THROW(CoreException,
129129
"Field value is 'nothing'");
130130
}
131131

132132

133-
BOND_NORETURN inline void InvalidEnumValueException(const char* value, const char* enum_)
133+
[[noreturn]] inline void InvalidEnumValueException(const char* value, const char* enum_)
134134
{
135135
BOND_THROW(bond::CoreException,
136136
"Unexpected value " << value << " for enum " << enum_);
137137
}
138138

139139

140-
BOND_NORETURN inline void InvalidEnumValueException(int32_t value, const char* enum_)
140+
[[noreturn]] inline void InvalidEnumValueException(int32_t value, const char* enum_)
141141
{
142142
BOND_THROW(bond::CoreException,
143143
"Unexpected value " << value << " for enum " << enum_);
144144
}
145145

146146

147-
BOND_NORETURN inline void RapidJsonException(const char* error, size_t offset)
147+
[[noreturn]] inline void RapidJsonException(const char* error, size_t offset)
148148
{
149149
BOND_THROW(CoreException,
150150
"JSON parser error: " << error << " at offset " << offset);
151151
}
152152

153153

154-
BOND_NORETURN inline void UnicodeConversionException()
154+
[[noreturn]] inline void UnicodeConversionException()
155155
{
156156
BOND_THROW(CoreException,
157157
"Unicode conversion exception");
@@ -176,7 +176,7 @@ struct SchemaValidateException
176176
};
177177

178178

179-
BOND_NORETURN
179+
[[noreturn]]
180180
inline void StructBaseDifferentException(const StructDef& src,
181181
const StructDef& dst)
182182
{
@@ -186,7 +186,7 @@ inline void StructBaseDifferentException(const StructDef& src,
186186
}
187187

188188

189-
BOND_NORETURN
189+
[[noreturn]]
190190
inline void RequiredFieldMissingException(const StructDef& s_dst,
191191
const FieldDef& f_dst)
192192
{
@@ -196,7 +196,7 @@ inline void RequiredFieldMissingException(const StructDef& s_dst,
196196
}
197197

198198

199-
BOND_NORETURN
199+
[[noreturn]]
200200
inline void OptionalToRequiredException(const StructDef& s_src,
201201
const StructDef& s_dst,
202202
const FieldDef& f_src,
@@ -209,7 +209,7 @@ inline void OptionalToRequiredException(const StructDef& s_src,
209209
}
210210

211211

212-
BOND_NORETURN
212+
[[noreturn]]
213213
inline void FieldTypeIncompatibleException(const StructDef& s_src,
214214
const StructDef& s_dst,
215215
const FieldDef& f_src,
@@ -222,7 +222,7 @@ inline void FieldTypeIncompatibleException(const StructDef& s_src,
222222
}
223223

224224

225-
BOND_NORETURN inline void UnknownSchemaDefException(uint16_t id)
225+
[[noreturn]] inline void UnknownSchemaDefException(uint16_t id)
226226
{
227227
BOND_THROW(SchemaValidateException,
228228
"Failed to validate schema compatibility; "

cpp/inc/bond/core/maybe.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace bond
2020
{
2121

2222

23-
BOND_NORETURN void NothingException();
23+
[[noreturn]] void NothingException();
2424

2525
namespace detail
2626
{

cpp/inc/bond/core/stl_containers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace bond
2323
{
2424

2525
template <typename Key>
26-
BOND_NORETURN void ElementNotFoundException(const Key& key);
26+
[[noreturn]] void ElementNotFoundException(const Key& key);
2727

2828
// is_string<std::basic_string<char, T, A> >
2929
template<typename T, typename A> struct

cpp/inc/bond/core/transforms.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ class RequiredFieldValiadator
424424
{}
425425

426426
private:
427-
BOND_NORETURN void MissingFieldException() const;
427+
[[noreturn]] void MissingFieldException() const;
428428

429429
mutable uint16_t _required;
430430
};
@@ -599,7 +599,7 @@ class To
599599
}
600600
}
601601

602-
BOND_NORETURN void UnexpectedStructStopException() const
602+
[[noreturn]] void UnexpectedStructStopException() const
603603
{
604604
// Force instantiation of template statics
605605
(void)typename schema<T>::type();

cpp/inc/bond/ext/grpc/win_thread_pool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace bond { namespace ext { namespace grpc
2525
{
2626
namespace detail
2727
{
28-
BOND_NORETURN void Win32Exception(const char* message)
28+
[[noreturn]] void Win32Exception(const char* message)
2929
{
3030
throw std::system_error{
3131
std::error_code{ static_cast<int>(::GetLastError()), std::system_category() },

cpp/inc/bond/stream/input_buffer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ class InputBuffer
223223
}
224224

225225
protected:
226-
BOND_NORETURN void EofException(uint32_t size) const
226+
[[noreturn]] void EofException(uint32_t size) const
227227
{
228228
BOND_THROW(StreamException,
229229
"Read out of bounds: " << size << " bytes requested, offset: "

cpp/inc/bond/stream/stream_interface.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class InputStream
5151
// Return type is not required to be specifically bond::blob.
5252
// See GetBufferRange for more details.
5353
template <typename InputBuffer>
54-
BOND_NORETURN inline blob GetCurrentBuffer(const InputBuffer& /*input*/)
54+
[[noreturn]] inline blob GetCurrentBuffer(const InputBuffer& /*input*/)
5555
{
5656
BOOST_STATIC_ASSERT_MSG(
5757
detail::mpl::always_false<InputBuffer>::value,
@@ -66,7 +66,7 @@ BOND_NORETURN inline blob GetCurrentBuffer(const InputBuffer& /*input*/)
6666
// output buffer associated with the writer (i.e. there is an overloaded Write
6767
// function that accepts it).
6868
template <typename Blob>
69-
BOND_NORETURN inline Blob GetBufferRange(const Blob& /*begin*/, const Blob& /*end*/)
69+
[[noreturn]] inline Blob GetBufferRange(const Blob& /*begin*/, const Blob& /*end*/)
7070
{
7171
BOOST_STATIC_ASSERT_MSG(
7272
detail::mpl::always_false<Blob>::value,
@@ -106,7 +106,7 @@ class OutputStream
106106
// compatible properties as the original one (e.g. while serializing
107107
// bonded<T> for untagged protocols).
108108
template <typename OutputBuffer>
109-
BOND_NORETURN inline OutputBuffer CreateOutputBuffer(const OutputBuffer& /*other*/)
109+
[[noreturn]] inline OutputBuffer CreateOutputBuffer(const OutputBuffer& /*other*/)
110110
{
111111
BOOST_STATIC_ASSERT_MSG(
112112
detail::mpl::always_false<OutputBuffer>::value,

0 commit comments

Comments
 (0)