From 113fb320197274c88c481ce92491394efae14112 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 3 May 2023 22:19:30 +0800 Subject: [PATCH 1/2] compaction: disambiguate format_to() we should always qualify `format_to` with its namespace. otherwise we'd have following failure when compiling with libstdc++ from GCC-13: ``` /home/kefu/dev/scylladb/compaction/table_state.hh:65:16: error: call to 'format_to' is ambiguous return format_to(ctx.out(), "{}.{} compaction_group={}", s->ks_name(), s->cf_name(), t.get_group_id()); ^~~~~~~~~ ``` Signed-off-by: Kefu Chai Closes #13760 --- compaction/table_state.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compaction/table_state.hh b/compaction/table_state.hh index 7f0a52a4fe..adf1e35113 100644 --- a/compaction/table_state.hh +++ b/compaction/table_state.hh @@ -62,7 +62,7 @@ struct formatter : formatter { template auto format(const compaction::table_state& t, FormatContext& ctx) const { auto s = t.schema(); - return format_to(ctx.out(), "{}.{} compaction_group={}", s->ks_name(), s->cf_name(), t.get_group_id()); + return fmt::format_to(ctx.out(), "{}.{} compaction_group={}", s->ks_name(), s->cf_name(), t.get_group_id()); } }; From c76486c508934c976bd84c6b50d79138e21a42eb Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 3 May 2023 23:04:14 +0800 Subject: [PATCH 2/2] build: only apply -Wno-parentheses-equality to ANTLR generated sources it turns out the only places where we have compiler warnings of -W-parentheses-equality is the source code generated by ANTLR. strictly speaking, this is valid C++ code, just not quite readable from the hygienic point of view. so let's enable this warning in the source tree, but only disable it when compiling the sources generated by ANTLR. please note, this warning option is supported by both GCC and Clang, so no need to test if it is supported. for a sample of the warnings, see: ``` /home/kefu/dev/scylladb/build/cmake/cql3/CqlLexer.cpp:21752:38: error: equality comparison with extraneous parentheses [-Werror,-Wparentheses-equality] if ( (LA4_0 == '$')) ~~~~~~^~~~~~ /home/kefu/dev/scylladb/build/cmake/cql3/CqlLexer.cpp:21752:38: note: remove extraneous parentheses around the comparison to silence this warning if ( (LA4_0 == '$')) ~ ^ ~ ``` Signed-off-by: Kefu Chai --- cmake/mode.common.cmake | 1 - configure.py | 6 +++--- cql3/CMakeLists.txt | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/cmake/mode.common.cmake b/cmake/mode.common.cmake index faf4c437ce..a23e0ba777 100644 --- a/cmake/mode.common.cmake +++ b/cmake/mode.common.cmake @@ -2,7 +2,6 @@ set(disabled_warnings c++11-narrowing mismatched-tags overloaded-virtual - parentheses-equality unsupported-friend) include(CheckCXXCompilerFlag) foreach(warning ${disabled_warnings}) diff --git a/configure.py b/configure.py index c934fd56bd..d27d2d36d6 100755 --- a/configure.py +++ b/configure.py @@ -1351,7 +1351,6 @@ warnings = [ '-Werror', '-Wno-mismatched-tags', # clang-only '-Wno-tautological-compare', - '-Wno-parentheses-equality', '-Wno-c++11-narrowing', '-Wno-ignored-attributes', '-Wno-overloaded-virtual', @@ -2031,13 +2030,14 @@ with open(buildfile, 'w') as f: for cc in grammar.sources('$builddir/{}/gen'.format(mode)): obj = cc.replace('.cpp', '.o') f.write('build {}: cxx.{} {} || {}\n'.format(obj, mode, cc, ' '.join(serializers))) + flags = '-Wno-parentheses-equality' if cc.endswith('Parser.cpp'): # Unoptimized parsers end up using huge amounts of stack space and overflowing their stack - flags = '-O1' if modes[mode]['optimization-level'] in ['0', 'g', 's'] else '' + flags += ' -O1' if modes[mode]['optimization-level'] in ['0', 'g', 's'] else '' if has_sanitize_address_use_after_scope: flags += ' -fno-sanitize-address-use-after-scope' - f.write(' obj_cxxflags = %s\n' % flags) + f.write(f' obj_cxxflags = {flags}\n') f.write(f'build $builddir/{mode}/gen/empty.cc: gen\n') for hh in headers: f.write('build $builddir/{mode}/{hh}.o: checkhh.{mode} {hh} | $builddir/{mode}/gen/empty.cc || {gen_headers_dep}\n'.format( diff --git a/cql3/CMakeLists.txt b/cql3/CMakeLists.txt index 4c4527ae51..261efc1f5c 100644 --- a/cql3/CMakeLists.txt +++ b/cql3/CMakeLists.txt @@ -7,7 +7,7 @@ generate_cql_grammar( SOURCES cql_grammar_srcs) set_source_files_properties(${cql_grammar_srcs} PROPERTIES - COMPILE_FLAGS "-Wno-uninitialized") + COMPILE_FLAGS "-Wno-uninitialized -Wno-parentheses-equality") add_library(cql3 STATIC) target_sources(cql3