Skip to content

Commit

Permalink
fix warning about googletest-1.15 with -std=c++14
Browse files Browse the repository at this point in the history
  • Loading branch information
oathdruid committed Aug 20, 2024
1 parent 62c3277 commit f06ef06
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 4 deletions.
13 changes: 10 additions & 3 deletions copts.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ BABYLON_CLANG_COPTS = ['-faligned-new', '-Weverything', '-Wno-unknown-warning-op
'-Wno-padded',
# 常规的隐式转换一般是可控的
'-Wno-implicit-int-conversion', '-Wno-implicit-float-conversion', '-Wno-double-promotion', '-Wno-shorten-64-to-32',
# 静态初始化是注册器模式和Google Test使用的典型方案
'-Wno-global-constructors',
# 采用前置下划线方案表达内部宏是一个典型实践方案
'-Wno-reserved-id-macro', '-Wno-reserved-identifier',
# __VA_ARGS__扩展作为c++20之前的通用方案继续保留使用
Expand All @@ -38,6 +36,15 @@ BABYLON_COPTS = select({

BABYLON_TEST_COPTS = BABYLON_COPTS + select({
'//:compiler_gcc': [],
'//:compiler_clang': ['-Wno-exit-time-destructors', '-Wno-sign-conversion'],
'//:compiler_clang': [
# 静态初始化是注册器模式和Google Test使用的典型方案
'-Wno-global-constructors',
# 静态变量的析构顺序可能引起的问题对于单测本身并无大碍,且可以简化单测实现
'-Wno-exit-time-destructors',
# 跨符号转换对单测自身并无大碍,且可以简化单测实现
'-Wno-sign-conversion',
# googletest-1.15开始使用了c++17属性
'-Wno-c++17-attribute-extensions'
],
'//conditions:default': [],
})
2 changes: 1 addition & 1 deletion example/use-arena-with-brpc/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
bazel_dep(name = 'babylon', version = '1.3.2')
bazel_dep(name = 'brpc', version = '1.10.0')
bazel_dep(name = 'brpc', version = '1.9.0')
bazel_dep(name = 'tcmalloc', version = '0.0.0-20240411-5ed309d')
single_version_override(module_name = 'protobuf', version = '25.3.arenastring')
5 changes: 5 additions & 0 deletions src/babylon/any.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ BABYLON_NAMESPACE_BEGIN

////////////////////////////////////////////////////////////////////////////////
// Any::TypeDescriptor begin
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Wunknown-warning-option"
#pragma GCC diagnostic ignored "-Wglobal-constructors"
template <typename T, typename E>
__attribute__((init_priority(101)))
Any::Meta Any::TypeDescriptor<T, E>::meta_for_instance {
Expand All @@ -35,6 +39,7 @@ Any::Meta Any::TypeDescriptor<T, E>::meta_for_inplace_non_trivial {
&TypeDescriptor<typename ::std::decay<T>::type>().descriptor) |
static_cast<uint64_t>(HolderType::INPLACE_NON_TRIVIAL) << 56 |
static_cast<uint64_t>(Type::INSTANCE) << 48};
#pragma GCC diagnostic pop

#if __cplusplus < 201703L
template <typename T>
Expand Down
4 changes: 4 additions & 0 deletions src/babylon/anyflow/builtin/expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class UnaryOperator : public Operator {
#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Wunknown-warning-option"
#pragma GCC diagnostic ignored "-Wexit-time-destructors"
#pragma GCC diagnostic ignored "-Wglobal-constructors"
::std::unordered_map<::std::string, ::std::function<::std::unique_ptr<Operator>(
const Operator::ValueIndex&,
const Operator::ValueIndex&)>>
Expand Down Expand Up @@ -234,6 +235,7 @@ class BinaryOperator : public Operator {
#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Wunknown-warning-option"
#pragma GCC diagnostic ignored "-Wexit-time-destructors"
#pragma GCC diagnostic ignored "-Wglobal-constructors"
::std::vector<::std::tuple<size_t, Any::Type>> BinaryOperator::TYPE_LEVEL =
BinaryOperator::generate_type_level();
::std::unordered_map<
Expand Down Expand Up @@ -377,6 +379,7 @@ ::std::unordered_map<
#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Wunknown-warning-option"
#pragma GCC diagnostic ignored "-Wexit-time-destructors"
#pragma GCC diagnostic ignored "-Wglobal-constructors"
// 定义这些运算符
__BABYLON_DEFINE_UNARY_OPERATOR(Not, !);
__BABYLON_DEFINE_UNARY_OPERATOR(Neg, -);
Expand Down Expand Up @@ -429,6 +432,7 @@ struct Option {
#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Wunknown-warning-option"
#pragma GCC diagnostic ignored "-Wexit-time-destructors"
#pragma GCC diagnostic ignored "-Wglobal-constructors"
static struct QuotedString : public grammar<const char*, ::std::string()> {
QuotedString() noexcept : base_type(start, "quoted_string") {
start = '"' >> *(escaped_slash | escaped_quote | common_char) >> '"';
Expand Down
1 change: 1 addition & 0 deletions src/babylon/application_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ void ApplicationContext::ComponentHolder::create_singleton(
#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Wunknown-warning-option"
#pragma GCC diagnostic ignored "-Wexit-time-destructors"
#pragma GCC diagnostic ignored "-Wglobal-constructors"
ApplicationContext::EmptyComponentHolder
ApplicationContext::EMPTY_COMPONENT_HOLDER;
#pragma GCC diagnostic pop
Expand Down
4 changes: 4 additions & 0 deletions src/babylon/logging/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class DefaultLogStreamProvider : public LogStreamProvider {
#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Wunknown-warning-option"
#pragma GCC diagnostic ignored "-Wexit-time-destructors"
#pragma GCC diagnostic ignored "-Wglobal-constructors"
static thread_local DefaultLogStream stream;
#pragma GCC diagnostic pop
stream.set_severity(static_cast<LogSeverity>(severity));
Expand All @@ -42,10 +43,12 @@ class DefaultLogStreamProvider : public LogStreamProvider {
#if __cplusplus < 201703L
constexpr StringView DefaultLogStreamProvider::SEVERITY_NAME[];
#endif // __cplusplus < 201703L

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Wunknown-warning-option"
#pragma GCC diagnostic ignored "-Wexit-time-destructors"
#pragma GCC diagnostic ignored "-Wglobal-constructors"
static DefaultLogStreamProvider s_default_provider;
#pragma GCC diagnostic pop
// DefaultLogStreamProvider end
Expand All @@ -65,6 +68,7 @@ void LogInterface::set_provider(
#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Wunknown-warning-option"
#pragma GCC diagnostic ignored "-Wexit-time-destructors"
#pragma GCC diagnostic ignored "-Wglobal-constructors"
static ::std::unique_ptr<LogStreamProvider> s_provider;
#pragma GCC diagnostic pop
s_provider = ::std::move(provider);
Expand Down

0 comments on commit f06ef06

Please sign in to comment.