Add warnings(); deprecate ExtraWarnings and NoWarnings flags

This commit is contained in:
Jason Perkins 2013-09-29 12:39:07 -04:00
parent 686f3f071a
commit 91635859b9
8 changed files with 56 additions and 41 deletions

View File

@ -646,6 +646,16 @@
kind = "key-path-list", kind = "key-path-list",
} }
api.register {
name = "warnings",
scope = "config",
kind = "string",
allowed = {
"Off",
"Default",
"Extra",
}
}
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
@ -696,6 +706,12 @@
return DOC_URL .. "optimize" return DOC_URL .. "optimize"
end) end)
api.deprecateValue("flags", { "ExtraWarnings", "NoWarnings" }, function(value)
local map = { ExtraWarnings = "Extra", NoWarnings = "Off" }
warnings (map[value] or "Default")
return DOC_URL .. "warnings"
end)
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
-- --

View File

@ -1185,21 +1185,16 @@
function vc200x.warnings(cfg) function vc200x.warnings(cfg)
-- if NoWarnings flags specified just disable warnings, and return. if cfg.warnings == "Off" then
if cfg.flags.NoWarnings then
_p(4,'WarningLevel="0"') _p(4,'WarningLevel="0"')
return else
end _p(4,'WarningLevel="%d"', iif(cfg.warnings == "Extra", 4, 3))
if cfg.flags.FatalWarnings then
-- else setup all warning blocks as needed. _p(4,'WarnAsError="%s"', vc200x.bool(true))
_p(4,'WarningLevel="%d"', iif(cfg.flags.ExtraWarnings, 4, 3)) end
if _ACTION < "vs2008" and not cfg.flags.Managed then
if cfg.flags.FatalWarnings then _p(4,'Detect64BitPortabilityProblems="%s"', vc200x.bool(not cfg.flags.No64BitChecks))
_p(4,'WarnAsError="%s"', vc200x.bool(true)) end
end
if _ACTION < "vs2008" and not cfg.flags.Managed then
_p(4,'Detect64BitPortabilityProblems="%s"', vc200x.bool(not cfg.flags.No64BitChecks))
end end
end end

View File

@ -1126,7 +1126,7 @@
function vc2010.treatWarningAsError(cfg) function vc2010.treatWarningAsError(cfg)
if cfg.flags.FatalWarnings and not cfg.flags.NoWarnings then if cfg.flags.FatalWarnings and cfg.warnings ~= "Off" then
_p(3,'<TreatWarningAsError>true</TreatWarningAsError>') _p(3,'<TreatWarningAsError>true</TreatWarningAsError>')
end end
end end
@ -1146,13 +1146,8 @@
function vc2010.warningLevel(cfg) function vc2010.warningLevel(cfg)
local w = "Level3" local map = { Off = "TurnOffAllWarnings", Extra = "Level4" }
if cfg.flags.NoWarnings then vc2010.element(3, "WarningLevel", nil, "%s", map[cfg.warnings] or "Level3")
w = "TurnOffAllWarnings"
elseif cfg.flags.ExtraWarnings then
w = "Level4"
end
vc2010.element(3, "WarningLevel", nil, "%s", w)
end end

View File

@ -96,9 +96,7 @@
x64 = "-m64", x64 = "-m64",
}, },
flags = { flags = {
ExtraWarnings = "-Wall -Wextra",
FatalWarnings = "-Werror", FatalWarnings = "-Werror",
NoWarnings = "-w",
NoFramePointer = "-fomit-frame-pointer", NoFramePointer = "-fomit-frame-pointer",
Symbols = "-g" Symbols = "-g"
}, },
@ -114,6 +112,10 @@
vectorextensions = { vectorextensions = {
SSE = "-msse", SSE = "-msse",
SSE2 = "-msse2", SSE2 = "-msse2",
},
warnings = {
Extra = "-Wall -Wextra",
Off = "-w",
} }
} }

View File

@ -22,12 +22,16 @@
-- --
snc.cflags = { snc.cflags = {
ExtraWarnings = "-Xdiag=2", flags = {
FatalWarnings = "-Xquit=2", FatalWarnings = "-Xquit=2",
},
warnings = {
Extra = "-Xdiag=2",
}
} }
function snc.getcflags(cfg) function snc.getcflags(cfg)
local flags = table.translate(cfg.flags, snc.cflags) local flags = config.mapFlags(cfg, snc.cflags)
return flags return flags
end end

View File

@ -327,11 +327,11 @@
-- --
-- Verify the correct warnings settings are used when ExtraWarnings are enabled. -- Verify the correct warnings settings are used when extra warnings are enabled.
-- --
function suite.runtimeLibraryIsDebug_onExtraWarnings() function suite.runtimeLibraryIsDebug_onExtraWarnings()
flags { "ExtraWarnings" } warnings "Extra"
prepare() prepare()
test.capture [[ test.capture [[
<Tool <Tool
@ -374,11 +374,12 @@
-- --
-- Verify the correct warnings settings are used when NoWarnings are enabled. -- Verify the correct warnings settings are used when no warnings are enabled.
-- --
function suite.runtimeLibraryIsDebug_onNoWarnings_whichDisablesAllOtherWarningsFlags() function suite.runtimeLibraryIsDebug_onNoWarnings_whichDisablesAllOtherWarningsFlags()
flags { "NoWarnings", "ExtraWarnings", "FatalWarnings" } flags { "FatalWarnings" }
warnings "Off"
prepare() prepare()
test.capture [[ test.capture [[
<Tool <Tool
@ -421,12 +422,12 @@
-- --
-- Verify the correct warnings settings are used when NoWarnings are enabled. -- Verify the correct warnings settings are used when no warnings are enabled.
-- --
function suite.runtimeLibraryIsDebug_onVS2005_NoWarnings() function suite.runtimeLibraryIsDebug_onVS2005_NoWarnings()
_ACTION = "vs2005" _ACTION = "vs2005"
flags { "NoWarnings" } warnings "Off"
prepare() prepare()
test.capture [[ test.capture [[
<Tool <Tool

View File

@ -76,11 +76,11 @@
-- --
-- If the ExtraWarnings flag is specified, pump up the volume. -- If extra warnings is specified, pump up the volume.
-- --
function suite.warningLevel_onExtraWarnings() function suite.warningLevel_onExtraWarnings()
flags "ExtraWarnings" warnings "Extra"
prepare() prepare()
test.capture [[ test.capture [[
<ClCompile> <ClCompile>
@ -90,11 +90,11 @@
end end
-- --
-- If the NoWarnings flag is specified, mute on warnings. -- If the warnings are disabled, mute all warnings.
-- --
function suite.warningLevel_onNoWarnings() function suite.warningLevel_onNoWarnings()
flags "NoWarnings" warnings "Off"
prepare() prepare()
test.capture [[ test.capture [[
<ClCompile> <ClCompile>
@ -104,11 +104,13 @@
end end
-- --
-- NoWarnings disables ExtraWarnings FatalWarnings flagss. -- If warnings are turned off, the fatal warnings flags should
-- not be generated.
-- --
function suite.warningLevel_onNoWarningsOverOtherWarningsFlags() function suite.warningLevel_onNoWarningsOverOtherWarningsFlags()
flags { "NoWarnings", "ExtraWarnings", "FatalWarnings" } flags { "FatalWarnings" }
warnings "Off"
prepare() prepare()
test.capture [[ test.capture [[
<ClCompile> <ClCompile>

View File

@ -73,7 +73,7 @@
-- --
function suite.cflags_onExtraWarnings() function suite.cflags_onExtraWarnings()
flags { "ExtraWarnings" } warnings "extra"
prepare() prepare()
test.isequal({ "-Wall -Wextra" }, gcc.getcflags(cfg)) test.isequal({ "-Wall -Wextra" }, gcc.getcflags(cfg))
end end
@ -97,7 +97,7 @@
end end
function suite.cflags_onNoWarnings() function suite.cflags_onNoWarnings()
flags { "NoWarnings" } warnings "Off"
prepare() prepare()
test.isequal({ "-w" }, gcc.getcflags(cfg)) test.isequal({ "-w" }, gcc.getcflags(cfg))
end end