Merge pull request #1447 from ethan-wallace/vs-warnings

Added /Wall to possible warning levels for Visual Studio
This commit is contained in:
Samuel Surtees 2020-06-21 15:37:56 +10:00 committed by GitHub
commit 2cee14c124
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 175 additions and 17 deletions

View File

@ -305,6 +305,7 @@
Default = "-wi", Default = "-wi",
High = "-wi", High = "-wi",
Extra = "-wi", Extra = "-wi",
Everything = "-wi",
}, },
} }

View File

@ -85,6 +85,7 @@
-- Default = "-w", -- TODO: check this... -- Default = "-w", -- TODO: check this...
High = "-Wall", High = "-Wall",
Extra = "-Wall -Wextra", Extra = "-Wall -Wextra",
Everything = "-Weverything",
}, },
symbols = { symbols = {
On = "-g", On = "-g",

View File

@ -121,6 +121,7 @@
Default = "-wi", Default = "-wi",
High = "-wi", High = "-wi",
Extra = "-wi", -- TODO: is there a way to get extra warnings? Extra = "-wi", -- TODO: is there a way to get extra warnings?
Everything = "-wi",
}, },
symbols = { symbols = {
On = "-g", On = "-g",

View File

@ -332,6 +332,23 @@
]] ]]
end end
function suite.runtimeLibraryIsDebug_onHighWarnings()
warnings "High"
prepare()
test.capture [[
<Tool
Name="VCCLCompilerTool"
Optimization="0"
BasicRuntimeChecks="3"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="4"
DebugInformationFormat="0"
/>
]]
end
-- --
-- Verify the correct warnings settings are used when FatalWarnings are enabled. -- Verify the correct warnings settings are used when FatalWarnings are enabled.

View File

@ -76,6 +76,18 @@
]] ]]
end end
--
-- Ensure that high warnings lead to the level 4 debug option
--
function suite.warningLevel_onHighWarnings()
warnings "High"
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
]]
end
-- --
-- If extra warnings is specified, pump up the volume. -- If extra warnings is specified, pump up the volume.
@ -91,6 +103,20 @@
]] ]]
end end
--
-- If Everything is wanted, turn it ALL on
--
function suite.warningLevel_onEverythingWarnings()
warnings "Everything"
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>EnableAllWarnings</WarningLevel>
]]
end
-- --
-- If the warnings are disabled, mute all warnings. -- If the warnings are disabled, mute all warnings.
-- --
@ -105,6 +131,20 @@
]] ]]
end end
--
-- Check default warning level.
--
function suite.warningLevel_onDefaultWarnings()
warnings "Default"
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
]]
end
-- --
-- If warnings are turned off, the fatal warnings flags should -- If warnings are turned off, the fatal warnings flags should
-- not be generated. -- not be generated.

View File

@ -1594,6 +1594,8 @@
local level local level
if cfg.warnings == p.OFF then if cfg.warnings == p.OFF then
level = "0" level = "0"
elseif cfg.warnings == "High" then
level = "4"
elseif cfg.warnings == "Extra" then elseif cfg.warnings == "Extra" then
level = "4" level = "4"
elseif not filecfg then elseif not filecfg then

View File

@ -2727,13 +2727,13 @@
function m.warningLevel(cfg) function m.warningLevel(cfg)
local map = { Off = "TurnOffAllWarnings", Extra = "Level4" } local map = { Off = "TurnOffAllWarnings", High = "Level4", Extra = "Level4", Everything = "EnableAllWarnings" }
m.element("WarningLevel", nil, map[cfg.warnings] or "Level3") m.element("WarningLevel", nil, map[cfg.warnings] or "Level3")
end end
function m.warningLevelFile(cfg, condition) function m.warningLevelFile(cfg, condition)
local map = { Off = "TurnOffAllWarnings", Extra = "Level4" } local map = { Off = "TurnOffAllWarnings", High = "Level4", Extra = "Level4", Everything = "EnableAllWarnings" }
if cfg.warnings then if cfg.warnings then
m.element("WarningLevel", condition, map[cfg.warnings] or "Level3") m.element("WarningLevel", condition, map[cfg.warnings] or "Level3")
end end

View File

@ -2332,6 +2332,55 @@
]] ]]
end end
function suite.XCBuildConfigurationProject_OnNoWarnings()
warnings "Off"
prepare()
xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
test.capture [[
A14350AC4595EE5E57CE36EC /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(NATIVE_ARCH_ACTUAL)";
CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
GCC_OPTIMIZATION_LEVEL = 0;
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
OBJROOT = obj/Debug;
ONLY_ACTIVE_ARCH = NO;
SYMROOT = bin/Debug;
WARNING_CFLAGS = "-w";
};
name = Debug;
};
]]
end
function suite.XCBuildConfigurationProject_OnHighWarnings()
warnings "High"
prepare()
xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
test.capture [[
A14350AC4595EE5E57CE36EC /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(NATIVE_ARCH_ACTUAL)";
CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
GCC_OPTIMIZATION_LEVEL = 0;
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
OBJROOT = obj/Debug;
ONLY_ACTIVE_ARCH = NO;
SYMROOT = bin/Debug;
WARNING_CFLAGS = "-Wall";
};
name = Debug;
};
]]
end
function suite.XCBuildConfigurationProject_OnExtraWarnings() function suite.XCBuildConfigurationProject_OnExtraWarnings()
warnings "Extra" warnings "Extra"
@ -2359,6 +2408,32 @@
end end
function suite.XCBuildConfigurationProject_OnEverythingWarnings()
warnings "Everything"
prepare()
xcode.XCBuildConfiguration_Project(tr, tr.configs[1])
test.capture [[
A14350AC4595EE5E57CE36EC /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(NATIVE_ARCH_ACTUAL)";
CONFIGURATION_BUILD_DIR = "$(SYMROOT)";
CONFIGURATION_TEMP_DIR = "$(OBJROOT)";
GCC_OPTIMIZATION_LEVEL = 0;
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
OBJROOT = obj/Debug;
ONLY_ACTIVE_ARCH = NO;
SYMROOT = bin/Debug;
WARNING_CFLAGS = "-Weverything";
};
name = Debug;
};
]]
end
function suite.XCBuildConfigurationProject_OnFatalWarnings() function suite.XCBuildConfigurationProject_OnFatalWarnings()
flags { "FatalWarnings" } flags { "FatalWarnings" }
prepare() prepare()

View File

@ -1450,8 +1450,14 @@
settings['SYMROOT'] = path.getrelative(tr.project.location, targetdir) settings['SYMROOT'] = path.getrelative(tr.project.location, targetdir)
end end
if cfg.warnings == "Extra" then if cfg.warnings == "Off" then
settings['WARNING_CFLAGS'] = '-w'
elseif cfg.warnings == "High" then
settings['WARNING_CFLAGS'] = '-Wall'
elseif cfg.warnings == "Extra" then
settings['WARNING_CFLAGS'] = '-Wall -Wextra' settings['WARNING_CFLAGS'] = '-Wall -Wextra'
elseif cfg.warnings == "Everything" then
settings['WARNING_CFLAGS'] = '-Weverything'
end end
overrideSettings(settings, cfg.xcodebuildsettings) overrideSettings(settings, cfg.xcodebuildsettings)

View File

@ -1309,6 +1309,7 @@
"Default", "Default",
"High", "High",
"Extra", "Extra",
"Everything",
} }
} }

View File

@ -101,9 +101,10 @@
RDRND = "-mrdrnd", RDRND = "-mrdrnd",
}, },
warnings = { warnings = {
Extra = {"-Wall", "-Wextra"},
High = "-Wall",
Off = "-w", Off = "-w",
High = "-Wall",
Extra = {"-Wall", "-Wextra"},
Everything = "-Weverything",
}, },
symbols = function(cfg, mappings) symbols = function(cfg, mappings)
local values = gcc.getdebugformat(cfg) local values = gcc.getdebugformat(cfg)

View File

@ -80,9 +80,10 @@
["SSE4.1"] = "/arch:SSE2", ["SSE4.1"] = "/arch:SSE2",
}, },
warnings = { warnings = {
Extra = "/W4",
High = "/W4",
Off = "/W0", Off = "/W0",
High = "/W4",
Extra = "/W4",
Everything = "/Wall",
}, },
staticruntime = { staticruntime = {
-- this option must always be emit (does it??) -- this option must always be emit (does it??)

View File

@ -74,16 +74,28 @@
-- Check the translation of CFLAGS. -- Check the translation of CFLAGS.
-- --
function suite.cflags_onNoWarnings()
warnings "Off"
prepare()
test.contains({ "-w" }, gcc.getcflags(cfg))
end
function suite.cflags_onHighWarnings()
warnings "High"
prepare()
test.contains({ "-Wall" }, gcc.getcflags(cfg))
end
function suite.cflags_onExtraWarnings() function suite.cflags_onExtraWarnings()
warnings "extra" warnings "Extra"
prepare() prepare()
test.contains({ "-Wall", "-Wextra" }, gcc.getcflags(cfg)) test.contains({ "-Wall", "-Wextra" }, gcc.getcflags(cfg))
end end
function suite.cflags_onHighWarnings() function suite.cflags_onEverythingWarnings()
warnings "high" warnings "Everything"
prepare() prepare()
test.contains({ "-Wall" }, gcc.getcflags(cfg)) test.contains({ "-Weverything" }, gcc.getcflags(cfg))
end end
function suite.cflags_onFatalWarnings() function suite.cflags_onFatalWarnings()
@ -112,12 +124,6 @@
test.contains({ "-ffloat-store" }, gcc.getcflags(cfg)) test.contains({ "-ffloat-store" }, gcc.getcflags(cfg))
end end
function suite.cflags_onNoWarnings()
warnings "Off"
prepare()
test.contains({ "-w" }, gcc.getcflags(cfg))
end
function suite.cflags_onSSE() function suite.cflags_onSSE()
vectorextensions "SSE" vectorextensions "SSE"
prepare() prepare()

View File

@ -224,6 +224,12 @@
test.contains("/W4", msc.getcflags(cfg)) test.contains("/W4", msc.getcflags(cfg))
end end
function suite.cflags_OnEverythingWarnings()
warnings "Everything"
prepare()
test.contains("/Wall", msc.getcflags(cfg))
end
function suite.cflags_OnFatalWarnings() function suite.cflags_OnFatalWarnings()
flags "FatalWarnings" flags "FatalWarnings"
prepare() prepare()