aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorbulatman <bulatman@yandex-team.com>2023-06-08 20:05:16 +0300
committerbulatman <bulatman@yandex-team.com>2023-06-08 20:05:16 +0300
commitdf6af3ee4741c667cf0c449696f768186bdc5752 (patch)
tree21ad8fed13c87e0ebec4bb5456f667a79d11c745 /util
parent8642bc755ab5b51752619694224388b2d247c737 (diff)
downloadydb-df6af3ee4741c667cf0c449696f768186bdc5752.tar.gz
Require semicolon after saveload macroses
Diffstat (limited to 'util')
-rw-r--r--util/system/compiler.h4
-rw-r--r--util/ysafeptr.h5
-rw-r--r--util/ysaveload.h7
-rw-r--r--util/ysaveload_ut.cpp2
4 files changed, 14 insertions, 4 deletions
diff --git a/util/system/compiler.h b/util/system/compiler.h
index 32acd43488..953837f919 100644
--- a/util/system/compiler.h
+++ b/util/system/compiler.h
@@ -613,6 +613,10 @@ _YandexAbort();
#define Y_REINITIALIZES_OBJECT
#endif
+// Use at the end of macros declaration. It allows macros usage only with semicolon at the end.
+// It prevents from warnings for extra semicolons when building with flag `-Wextra-semi`.
+#define Y_SEMICOLON_GUARD static_assert(true, "")
+
#ifdef __cplusplus
void UseCharPointerImpl(volatile const char*);
diff --git a/util/ysafeptr.h b/util/ysafeptr.h
index af7dfd4bed..c33f66db84 100644
--- a/util/ysafeptr.h
+++ b/util/ysafeptr.h
@@ -1,6 +1,7 @@
#pragma once
#include <stddef.h>
+#include <util/system/compiler.h>
#include <util/system/yassert.h>
#include <util/system/defaults.h>
#include <util/system/tls.h>
@@ -209,7 +210,9 @@ protected: \
this->ObjData += nHoldObjs; \
} \
\
-private:
+private: \
+ Y_SEMICOLON_GUARD
+
#define OBJECT_NOCOPY_METHODS(classname) OBJECT_METHODS(classname)
#define BASIC_REGISTER_CLASS(classname) \
Y_PRAGMA_DIAGNOSTIC_PUSH \
diff --git a/util/ysaveload.h b/util/ysaveload.h
index 02efb4049b..f3451e2ad5 100644
--- a/util/ysaveload.h
+++ b/util/ysaveload.h
@@ -8,6 +8,7 @@
#include <util/generic/algorithm.h>
#include <util/stream/output.h>
#include <util/stream/input.h>
+#include <util/system/compiler.h>
#ifndef __NVCC__
// cuda is compiled in C++14 mode at the time
@@ -710,7 +711,8 @@ static inline void LoadMany(S* s, Ts&... t) {
\
inline void Load(IInputStream* s) { \
::LoadMany(s, __VA_ARGS__); \
- }
+ } \
+ Y_SEMICOLON_GUARD
#define Y_SAVELOAD_DEFINE_OVERRIDE(...) \
void Save(IOutputStream* s) const override { \
@@ -719,7 +721,8 @@ static inline void LoadMany(S* s, Ts&... t) {
\
void Load(IInputStream* s) override { \
::LoadMany(s, __VA_ARGS__); \
- }
+ } \
+ Y_SEMICOLON_GUARD
template <class T>
struct TNonVirtualSaver {
diff --git a/util/ysaveload_ut.cpp b/util/ysaveload_ut.cpp
index c241ed0ee1..7656f8e941 100644
--- a/util/ysaveload_ut.cpp
+++ b/util/ysaveload_ut.cpp
@@ -57,7 +57,7 @@ class TSaveLoadTest: public TTestBase {
TString Str;
ui32 Int;
- Y_SAVELOAD_DEFINE(Str, Int)
+ Y_SAVELOAD_DEFINE(Str, Int);
};
private: