Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,17 @@ score_gcc = use_extension("@score_bazel_cpp_toolchains//extensions:gcc.bzl", "gc
# score_communication_* cc_features (currently consumed by the LLVM toolchain).
SCORE_GCC_MINIMAL_WARNING_COMPILE_FLAGS = [

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more flags were added there for cross-toolchain parity, not to make warnings stricter than intended

"-Wall",
"-W",
"-Wno-error=deprecated-declarations",
"-Wno-error=cpp",
"-Wno-builtin-macro-redefined",
"-Wno-deprecated-non-prototype",
"-Wno-format-y2k",
"-Wno-free-nonheap-object",
"-Wno-maybe-uninitialized",
"-Wno-unused-macros",
"-Wno-unused-parameter",
"-Wno-unused-variable",
"-Wunused-but-set-parameter",
]

Expand Down Expand Up @@ -279,7 +285,7 @@ llvm = use_extension(
llvm.toolchain(
cxx_standard = {"": "c++17"},
extra_enabled_features = [
"//quality/compiler_warnings:default_flags",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should stay.
Also ideally move the default flags out of compiler_warnings. They are not about warnings at all. They are the defaults we require to make the compilation sane. Move them to bazel/toolchains/llvm/flags.bzl

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed!

"//quality/compiler_warnings:default_compile_flags",
"//quality/compiler_warnings:default_link_flags",
"//quality/compiler_warnings/clang:minimal_warnings",
],
Expand All @@ -289,6 +295,8 @@ llvm.toolchain(
"@score_cpp_policies//sanitizers/features:ubsan",
"@score_cpp_policies//sanitizers/features:lsan",
"@score_cpp_policies//sanitizers/features:tsan",
"//quality/compiler_warnings:minimal_warnings",
"//quality/compiler_warnings:strict_warnings",
"//quality/compiler_warnings:treat_warnings_as_errors",
"//quality/compiler_warnings:additional_warnings",
"//quality/compiler_warnings/clang:strict_warnings",
Expand Down
31 changes: 25 additions & 6 deletions quality/compiler_warnings/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ cc_args(
"-fno-omit-frame-pointer",
"-fcolor-diagnostics",
],
visibility = ["//quality/compiler_warnings:__subpackages__"],
)

cc_feature(
name = "default_flags",
name = "default_compile_flags",
args = [
":default_compile_args",
],
feature_name = "score_communication_default_flags",
feature_name = "score_communication_default_compile_flags",
visibility = ["//visibility:public"],
)

Expand Down Expand Up @@ -92,24 +93,44 @@ cc_args(
# Keep #warning visible without failing the build.
"-Wno-error=cpp",
"-Wno-error=deprecated-declarations",
"-Wno-unused-macros",
"-Wno-unused-parameter",
"-Wno-unused-variable",
],
visibility = ["//quality/compiler_warnings:__subpackages__"],
)

cc_feature(
name = "minimal_warnings",
args = [
":minimal_warnings_args",
],
feature_name = "score_communication_common_minimal_warnings",
visibility = ["//visibility:public"],
)

cc_args(
name = "strict_warnings_args",
actions = [
"@rules_cc//cc/toolchains/actions:compile_actions",
],
args = [
"-Wextra",
"-Wpedantic",
"-Wconversion",
"-Wsign-conversion",
],
visibility = ["//quality/compiler_warnings:__subpackages__"],
)

cc_feature(
Comment thread
LittleHuba marked this conversation as resolved.
name = "strict_warnings",
args = [
":strict_warnings_args",
],
feature_name = "score_communication_common_strict_warnings",
visibility = ["//visibility:public"],
)

cc_args(
name = "additional_warnings_args",
actions = [
Expand All @@ -118,9 +139,6 @@ cc_args(
args = [
"-Wcast-align",
"-Wcast-qual",
"-Wdouble-promotion",
"-Wformat-nonliteral",
"-Wpointer-arith",
"-Wredundant-decls",
"-Wundef",
"-Wwrite-strings",
Expand All @@ -134,5 +152,6 @@ cc_feature(
":additional_warnings_args",
],
feature_name = "score_communication_additional_warnings",
implies = [":strict_warnings"],
Comment thread
LittleHuba marked this conversation as resolved.
visibility = ["//visibility:public"],
)
29 changes: 16 additions & 13 deletions quality/compiler_warnings/clang/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,18 @@ cc_args(
args = [
# Suppress false positive from Clang's self-assignment overloaded check.
# See https://bugs.llvm.org/show_bug.cgi?id=43124
"-Wno-error=self-assign-overloaded",
"-Wno-return-type-c-linkage",
"-Wno-unused-command-line-argument",
],
)

cc_feature(
name = "minimal_warnings",
args = [
"//quality/compiler_warnings:minimal_warnings_args",
":minimal_warnings_args",
],
feature_name = "score_communication_minimal_warnings",
implies = ["//quality/compiler_warnings:minimal_warnings"],
visibility = ["//visibility:public"],
)

Expand All @@ -45,9 +46,7 @@ cc_args(
"@rules_cc//cc/toolchains/actions:compile_actions",
],
args = [
"-Wfloat-equal",
"-Wformat-security",
"-Wshadow-all",
# Demote shadow-uncaptured-local from error to warning. This diagnostic
# fires for code in external headers (e.g. score_baselibs simple_task.h)
# which we cannot fix.
Expand All @@ -60,11 +59,13 @@ cc_args(
cc_feature(
name = "strict_warnings",
args = [
"//quality/compiler_warnings:strict_warnings_args",
":strict_warnings_args",
],
feature_name = "score_communication_strict_warnings",
implies = ["minimal_warnings"],
implies = [
"//quality/compiler_warnings:strict_warnings",
"minimal_warnings",
],
visibility = ["//visibility:public"],
)

Expand All @@ -74,7 +75,14 @@ cc_args(
"@rules_cc//cc/toolchains/actions:compile_actions",
],
args = [
"-Wno-error",
"-Wno-error=conversion",
"-Wno-error=return-type",
"-Wno-error=shadow",
"-Wno-error=sign-compare",
"-Wno-error=sign-conversion",
"-Wno-error=strict-aliasing",
"-Wno-error=unknown-warning-option",
"-Wno-error=unused-function",
],
)

Expand All @@ -93,12 +101,7 @@ cc_args(
actions = [
"@rules_cc//cc/toolchains/actions:compile_actions",
],
args = [
"--no-warnings",
# Keep default-error diagnostics non-fatal in third-party code.
"-Wno-error=implicit-function-declaration",
"-Wno-error=missing-template-arg-list-after-template-kw",
],
args = ["-w"],
)

cc_feature(
Expand Down
42 changes: 34 additions & 8 deletions quality/compiler_warnings/gcc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ cc_args(
"@rules_cc//cc/toolchains/actions:compile_actions",
],
args = [
"-W",
"-Wno-builtin-macro-redefined",
"-Wno-deprecated-non-prototype",
"-Wno-format-y2k",
"-Wno-free-nonheap-object",
# Reduce known GCC false positives.
Expand All @@ -44,11 +47,11 @@ cc_args(
cc_feature(
name = "minimal_warnings",
args = [
"//quality/compiler_warnings:minimal_warnings_args",
":minimal_warnings_args_for_all_compile_actions",
":minimal_warnings_args_for_cpp_compile_actions",
],
feature_name = "score_communication_minimal_warnings",
implies = ["//quality/compiler_warnings:minimal_warnings"],
visibility = ["//visibility:public"],
)

Expand All @@ -59,8 +62,6 @@ cc_args(
],
args = [
"-Warray-bounds=2",
"-Wcast-align",
"-Wcast-qual",
"-Wdisabled-optimization",
"-Wfloat-conversion",
"-Wformat=2",
Expand All @@ -71,12 +72,9 @@ cc_args(
"-Wpacked",
"-Wscalar-storage-order",
"-Wsuggest-attribute=format",
"-Wundef",
"-Wunused-macros",
"-Wvector-operation-performance",
"-Wwrite-strings",
"-Wlogical-op",
"-Wredundant-decls",
"-Wshadow",
],
)
Expand Down Expand Up @@ -108,13 +106,15 @@ cc_args(
cc_feature(
name = "strict_warnings",
args = [
"//quality/compiler_warnings:strict_warnings_args",
":strict_warnings_args_for_all_compile_actions",
":strict_warnings_args_for_cpp_compile_actions",
":strict_warnings_args_for_c_compile_actions",
],
feature_name = "score_communication_strict_warnings",
implies = ["minimal_warnings"],
implies = [
"//quality/compiler_warnings:strict_warnings",
"minimal_warnings",
],
visibility = ["//visibility:public"],
)

Expand All @@ -126,6 +126,32 @@ cc_args(
args = [
# Must come after -Werror so it takes effect.
"-Wno-error",
"-Wno-error=address-of-packed-member",
"-Wno-error=alloc-size-larger-than=",
"-Wno-error=array-bounds",
"-Wno-error=attributes",
"-Wno-error=conversion",
"-Wno-error=dangling-pointer=2",
"-Wno-error=invalid-memory-model",
"-Wno-error=maybe-uninitialized",
"-Wno-error=misleading-indentation",
"-Wno-error=missing-attributes",
"-Wno-error=nonnull",
"-Wno-error=pessimizing-move",
"-Wno-error=range-loop-construct",
"-Wno-error=redundant-move",
"-Wno-error=return-type",
"-Wno-error=shadow",
"-Wno-error=sign-compare",
"-Wno-error=sign-conversion",
"-Wno-error=stringop-overflow=2",
"-Wno-error=stringop-truncation",
"-Wno-error=strict-aliasing",
"-Wno-error=tsan",
"-Wno-error=type-limits",
"-Wno-error=uninitialized",
"-Wno-error=unused-but-set-variable",
"-Wno-error=unused-function",
],
)

Expand Down
4 changes: 1 addition & 3 deletions quality/compiler_warnings/test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@rules_build_error//lang/cc:defs.bzl", "cc_build_error_test")
load("@rules_build_error//matcher:defs.bzl", "matcher")
load("//score/mw:common_features.bzl", "COMPILER_WARNING_FEATURES")
load("//:score/common_features.bzl", "COMPILER_WARNING_FEATURES")

# Compiler warning feature tests.
WARNING_FLAGS_BY_CASE = {
"conversion": ["-Wfloat-conversion"],
"shadow": ["-Wshadow"],
"sign_compare": ["-Wsign-compare"],
"unused_parameter": ["-Wunused-parameter"],

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed the unused flag and test cases

"cast_qual": ["-Wcast-qual"],
"format_nonliteral": ["-Wformat-nonliteral"],
"undef": ["-Wundef"],
"delete_non_virtual_dtor": ["-Wdelete-non-virtual-dtor"],
"overloaded_virtual": ["-Woverloaded-virtual"],
Expand Down
Loading
Loading