Skip to content

Commit 72a166b

Browse files
committed
gql: suppress -Wextra warnings in generated ANTLR parser
The generated GQLParser.cpp carries Sempred methods whose _localctx parameter is unused (they delegate to precpred(_ctx, ...)). Under the parent repo's CI (ENABLE_WERROR=1 / -Werror) these produced -Werror=unused-parameter build failures for the gql extension. Mirror how the parent handles its generated ANTLR code (cypher_parser is silenced by -Wno-extra in third_party/CMakeLists.txt): disable -Wextra-only warnings for the generated parser/lexer/visitor OBJECT target. Hand-written gql code is unaffected; -no-visitor/-no-listener does not help since Sempred methods are always generated. Also vendor the Apache-2.0 opengql/grammar (GQL.g4 @ 1.9.0) under third_party/opengql so scripts/generate_gql_grammar.cmake works from a fresh clone and the grammar revision is pinned. Regeneration from the vendored grammar is byte-identical to the checked-in generated files.
1 parent e51e3ed commit 72a166b

4 files changed

Lines changed: 4065 additions & 0 deletions

File tree

gql/src/parser/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ add_library(lbug_gql_extension_parser
55
GQLParser.cpp
66
GQLVisitor.cpp)
77

8+
# The generated ANTLR parser/lexer/visitor are warning-clean under -Wall but, like
9+
# the parent repo's generated ANTLR code (see third_party/antlr4_cypher, which is
10+
# silenced by -Wno-extra in the parent's third_party/CMakeLists.txt), they declare
11+
# parameters that -Wextra flags as unused (e.g. the `_localctx` argument of the
12+
# generated Sempred methods, which delegate to precpred(_ctx, ...)). Those become
13+
# hard errors when the parent CI builds extensions with ENABLE_WERROR=1 / -Werror.
14+
# Mirror the parent's treatment of generated code: disable the -Wextra-only warnings
15+
# for this generated-object target only. Hand-written gql code is unaffected.
16+
if(NOT MSVC)
17+
target_compile_options(lbug_gql_extension_parser PRIVATE -Wno-extra)
18+
endif()
19+
820
set(GQL_EXTENSION_OBJECT_FILES
921
${GQL_EXTENSION_OBJECT_FILES} $<TARGET_OBJECTS:lbug_gql_extension_parser>
1022
PARENT_SCOPE)

0 commit comments

Comments
 (0)