From ed4a27b2e1f795eceab48282d1e7d09f8002aa22 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Wed, 18 May 2022 13:15:00 -0700 Subject: [PATCH] Only set -Wall once. We set -Wall in the global cflags, and then again at the point where we decide whether or not to add -Werror. The trouble with this is that it undoes the effect of any attempt to disable a warning implied by -Wall. Discovered while trying to enable -Wmisleading-indentation (which is part of -Wall) in a way that doesn't apply to external/ or vendor/. Test: treehugger Change-Id: I68d74fb05922dd9f6bd4c8423ca69b485c15e3d2 --- cc/cc_test.go | 2 +- cc/compiler.go | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/cc/cc_test.go b/cc/cc_test.go index 2951b5aae..fb246243f 100644 --- a/cc/cc_test.go +++ b/cc/cc_test.go @@ -4041,7 +4041,7 @@ func TestIncludeDirectoryOrdering(t *testing.T) { conly := []string{"-fPIC", "${config.CommonGlobalConlyflags}"} cppOnly := []string{"-fPIC", "${config.CommonGlobalCppflags}", "${config.DeviceGlobalCppflags}", "${config.ArmCppflags}"} - cflags := []string{"-Wall", "-Werror", "-std=candcpp"} + cflags := []string{"-Werror", "-std=candcpp"} cstd := []string{"-std=gnu11", "-std=conly"} cppstd := []string{"-std=gnu++17", "-std=cpp", "-fno-rtti"} diff --git a/cc/compiler.go b/cc/compiler.go index eb5458fc6..49b6fba42 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -590,9 +590,8 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps } else if !inList("-Werror", flags.Local.CFlags) && !inList("-Werror", flags.Local.CppFlags) { if warningsAreAllowed(ctx.ModuleDir()) { addToModuleList(ctx, modulesAddedWallKey, module) - flags.Local.CFlags = append([]string{"-Wall"}, flags.Local.CFlags...) } else { - flags.Local.CFlags = append([]string{"-Wall", "-Werror"}, flags.Local.CFlags...) + flags.Local.CFlags = append([]string{"-Werror"}, flags.Local.CFlags...) } } }