Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added /Wall to possible warning levels for Visual Studio #1447

Merged
merged 5 commits into from
Jun 21, 2020
Merged
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
1 change: 1 addition & 0 deletions modules/d/tools/dmd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@
Default = "-wi",
High = "-wi",
Extra = "-wi",
Everything = "-wi",
},
}

Expand Down
1 change: 1 addition & 0 deletions modules/d/tools/gdc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
-- Default = "-w", -- TODO: check this...
High = "-Wall",
Extra = "-Wall -Wextra",
Everything = "-Weverything",
},
symbols = {
On = "-g",
Expand Down
1 change: 1 addition & 0 deletions modules/d/tools/ldc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
Default = "-wi",
High = "-wi",
Extra = "-wi", -- TODO: is there a way to get extra warnings?
Everything = "-wi",
},
symbols = {
On = "-g",
Expand Down
17 changes: 17 additions & 0 deletions modules/vstudio/tests/vc200x/test_compiler_block.lua
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,23 @@
]]
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.
Expand Down
40 changes: 40 additions & 0 deletions modules/vstudio/tests/vc2010/test_compile_settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@
]]
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.
Expand All @@ -91,6 +103,20 @@
]]
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.
--
Expand All @@ -105,6 +131,20 @@
]]
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
-- not be generated.
Expand Down
2 changes: 2 additions & 0 deletions modules/vstudio/vs200x_vcproj.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1594,6 +1594,8 @@
local level
if cfg.warnings == p.OFF then
level = "0"
elseif cfg.warnings == "High" then
level = "4"
elseif cfg.warnings == "Extra" then
level = "4"
elseif not filecfg then
Expand Down
4 changes: 2 additions & 2 deletions modules/vstudio/vs2010_vcxproj.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2727,13 +2727,13 @@


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")
end


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
m.element("WarningLevel", condition, map[cfg.warnings] or "Level3")
end
Expand Down
75 changes: 75 additions & 0 deletions modules/xcode/tests/test_xcode_project.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2332,6 +2332,55 @@
]]
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()
warnings "Extra"
Expand Down Expand Up @@ -2359,6 +2408,32 @@
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()
flags { "FatalWarnings" }
prepare()
Expand Down
8 changes: 7 additions & 1 deletion modules/xcode/xcode_common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1450,8 +1450,14 @@
settings['SYMROOT'] = path.getrelative(tr.project.location, targetdir)
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'
elseif cfg.warnings == "Everything" then
settings['WARNING_CFLAGS'] = '-Weverything'
end

overrideSettings(settings, cfg.xcodebuildsettings)
Expand Down
1 change: 1 addition & 0 deletions src/_premake_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1309,6 +1309,7 @@
"Default",
"High",
"Extra",
"Everything",
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/tools/gcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,10 @@
RDRND = "-mrdrnd",
},
warnings = {
Extra = {"-Wall", "-Wextra"},
High = "-Wall",
Off = "-w",
High = "-Wall",
Extra = {"-Wall", "-Wextra"},
Everything = "-Weverything",
},
symbols = function(cfg, mappings)
local values = gcc.getdebugformat(cfg)
Expand Down
5 changes: 3 additions & 2 deletions src/tools/msc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@
["SSE4.1"] = "/arch:SSE2",
},
warnings = {
Extra = "/W4",
High = "/W4",
Off = "/W0",
High = "/W4",
Extra = "/W4",
Everything = "/Wall",
},
staticruntime = {
-- this option must always be emit (does it??)
Expand Down
26 changes: 16 additions & 10 deletions tests/tools/test_gcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,30 @@
-- Check the translation of CFLAGS.
--

function suite.cflags_onExtraWarnings()
warnings "extra"
function suite.cflags_onNoWarnings()
warnings "Off"
prepare()
test.contains({ "-Wall", "-Wextra" }, gcc.getcflags(cfg))
test.contains({ "-w" }, gcc.getcflags(cfg))
end

function suite.cflags_onHighWarnings()
warnings "high"
warnings "High"
prepare()
test.contains({ "-Wall" }, gcc.getcflags(cfg))
end

function suite.cflags_onExtraWarnings()
warnings "Extra"
prepare()
test.contains({ "-Wall", "-Wextra" }, gcc.getcflags(cfg))
end

function suite.cflags_onEverythingWarnings()
warnings "Everything"
prepare()
test.contains({ "-Weverything" }, gcc.getcflags(cfg))
end

function suite.cflags_onFatalWarnings()
flags { "FatalWarnings" }
prepare()
Expand All @@ -112,12 +124,6 @@
test.contains({ "-ffloat-store" }, gcc.getcflags(cfg))
end

function suite.cflags_onNoWarnings()
warnings "Off"
prepare()
test.contains({ "-w" }, gcc.getcflags(cfg))
end

function suite.cflags_onSSE()
vectorextensions "SSE"
prepare()
Expand Down
6 changes: 6 additions & 0 deletions tests/tools/test_msc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@
test.contains("/W4", msc.getcflags(cfg))
end

function suite.cflags_OnEverythingWarnings()
warnings "Everything"
prepare()
test.contains("/Wall", msc.getcflags(cfg))
end

function suite.cflags_OnFatalWarnings()
flags "FatalWarnings"
prepare()
Expand Down