New API strictaliasing() with GCC support
This commit is contained in:
parent
5899a7f34b
commit
60fc6d2897
@ -630,6 +630,18 @@
|
||||
tokens = true,
|
||||
}
|
||||
|
||||
api.register {
|
||||
name = "strictaliasing",
|
||||
scope = "config",
|
||||
kind = "string",
|
||||
allowed = {
|
||||
"Off",
|
||||
"Level1",
|
||||
"Level2",
|
||||
"Level3",
|
||||
}
|
||||
}
|
||||
|
||||
api.register {
|
||||
name = "system",
|
||||
scope = "config",
|
||||
|
@ -51,6 +51,12 @@
|
||||
if cfg.system ~= premake.WINDOWS then return "-fPIC" end
|
||||
end,
|
||||
},
|
||||
strictaliasing = {
|
||||
Off = "-fno-strict-aliasing",
|
||||
Level1 = { "-fstrict-aliasing", "-Wstrict-aliasing=1" },
|
||||
Level2 = { "-fstrict-aliasing", "-Wstrict-aliasing=2" },
|
||||
Level3 = { "-fstrict-aliasing", "-Wstrict-aliasing=3" },
|
||||
},
|
||||
optimize = {
|
||||
Off = "-O0",
|
||||
On = "-O2",
|
||||
|
@ -402,3 +402,32 @@
|
||||
test.isequal({ '-I"$(IntDir)/includes"' }, gcc.getincludedirs(cfg, cfg.includedirs))
|
||||
end
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Check handling of strict aliasing flags.
|
||||
--
|
||||
|
||||
function suite.cflags_onNoStrictAliasing()
|
||||
strictaliasing "Off"
|
||||
prepare()
|
||||
test.contains("-fno-strict-aliasing", gcc.getcflags(cfg))
|
||||
end
|
||||
|
||||
function suite.cflags_onLevel1Aliasing()
|
||||
strictaliasing "Level1"
|
||||
prepare()
|
||||
test.contains({ "-fstrict-aliasing", "-Wstrict-aliasing=1" }, gcc.getcflags(cfg))
|
||||
end
|
||||
|
||||
function suite.cflags_onLevel2Aliasing()
|
||||
strictaliasing "Level2"
|
||||
prepare()
|
||||
test.contains({ "-fstrict-aliasing", "-Wstrict-aliasing=2" }, gcc.getcflags(cfg))
|
||||
end
|
||||
|
||||
function suite.cflags_onLevel3Aliasing()
|
||||
strictaliasing "Level3"
|
||||
prepare()
|
||||
test.contains({ "-fstrict-aliasing", "-Wstrict-aliasing=3" }, gcc.getcflags(cfg))
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user