Skip to content

Commit

Permalink
pw_build: Only use -Wextra-semi on C++ files with GCC
Browse files Browse the repository at this point in the history
GCC doesn't like it when -Wextra-semi is a C flag, and only allows it
when compiling C++.

Bug: b/306734552, b/301262374
Change-Id: Ic6407823843134defd3485e143a5d138249f6bec
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/177171
Pigweed-Auto-Submit: Armando Montanez <[email protected]>
Presubmit-Verified: CQ Bot Account <[email protected]>
Reviewed-by: Wyatt Hepler <[email protected]>
Commit-Queue: Auto-Submit <[email protected]>
  • Loading branch information
armandomontanez authored and CQ Bot Account committed Oct 21, 2023
1 parent 26ccfc6 commit 35460f8
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions pw_build/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import("$dir_pw_build/cc_blob_library.gni")
import("$dir_pw_build/python.gni")
import("$dir_pw_build/relative_source_file_names.gni")
import("$dir_pw_docgen/docs.gni")
import("$dir_pw_toolchain/generate_toolchain.gni")
import("$dir_pw_toolchain/traits.gni")
import("$dir_pw_unit_test/test.gni")
import("target_types.gni")
Expand Down Expand Up @@ -138,10 +139,16 @@ config("extra_strict_warnings") {
# This config MUST NOT be used downstream to allow for warnings to be
# added in the future without breaking downstream.
config("internal_strict_warnings") {
cflags = [
"-Wextra-semi",
"-Wswitch-enum",
]
cflags = [ "-Wswitch-enum" ]

# TODO: b/301262374 - Provide a better way to detect the compiler type.
if (defined(pw_toolchain_SCOPE.cc) &&
get_path_info(pw_toolchain_SCOPE.cc, "file") == "clang") {
cflags += [ "-Wextra-semi" ]
} else {
# TODO: b/306734552 - On GCC, this only works as a C++ flag.
cflags_cc = [ "-Wextra-semi" ]
}

# TODO: b/243069432 - Enable pedantic warnings on Windows when they pass.
if (host_os != "win") {
Expand Down

0 comments on commit 35460f8

Please sign in to comment.