summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-09-17 21:41:32 +0800
committerruki <[email protected]>2023-09-17 21:41:39 +0800
commit97831c56d2ba3a719de0c80d9bcdc8db9163eb00 (patch)
treeaedaa7962d1c52bab5c916624bf89e7cf0b6e56c
parenta9e9084863ffc3d9e6aeb044e3f92a7deaa78036 (diff)
add pedantic warning #4209
-rw-r--r--xmake/modules/core/tools/cl.lua26
-rw-r--r--xmake/modules/core/tools/clang.lua7
-rw-r--r--xmake/modules/core/tools/gcc.lua2
-rw-r--r--xmake/modules/private/check/checkers/api/target/warnings.lua3
4 files changed, 28 insertions, 10 deletions
diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua
index 5f44197f6..607f0f4d9 100644
--- a/xmake/modules/core/tools/cl.lua
+++ b/xmake/modules/core/tools/cl.lua
@@ -130,8 +130,7 @@ end
-- make the fp-model flag
function nf_fpmodel(self, level)
- local maps =
- {
+ local maps = {
precise = "-fp:precise" -- default
, fast = "-fp:fast"
, strict = "-fp:strict"
@@ -142,9 +141,16 @@ function nf_fpmodel(self, level)
end
-- make the warning flag
-function nf_warning(self, level)
- local maps =
- {
+function nf_warnings(self, levels)
+ local flags = {}
+ local values = hashset.from(levels)
+ if values:has("all") and values:has("extra") then
+ table.insert(flags, "-W4")
+ values:remove("all")
+ values:remove("extra")
+ end
+
+ local maps = {
none = "-w"
, less = "-W1"
, more = "-W3"
@@ -153,7 +159,15 @@ function nf_warning(self, level)
, everything = "-Wall"
, error = "-WX"
}
- return maps[level]
+ for _, level in values:keys() do
+ local flag = maps[level]
+ if flag then
+ table.insert(flags, flag)
+ end
+ end
+ if #flags > 0 then
+ return flags
+ end
end
-- make the optimize flag
diff --git a/xmake/modules/core/tools/clang.lua b/xmake/modules/core/tools/clang.lua
index 915ee1cb9..28a00d84f 100644
--- a/xmake/modules/core/tools/clang.lua
+++ b/xmake/modules/core/tools/clang.lua
@@ -117,13 +117,14 @@ end
-- make the warning flag
function nf_warning(self, level)
- local maps =
- {
+ local maps = {
none = "-w"
, less = "-Wall"
, more = "-Wall"
, all = "-Wall"
- , allextra = "-Wall -Wextra"
+ , allextra = {"-Wall", "-Wextra"}
+ , extra = "-Wextra"
+ , pedantic = "-Wpedantic"
, everything = "-Weverything"
, error = "-Werror"
}
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index 263f96c7b..828380c15 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -128,6 +128,8 @@ function nf_warning(self, level)
, more = "-Wall"
, all = "-Wall"
, allextra = {"-Wall", "-Wextra"}
+ , extra = "-Wextra"
+ , pedantic = "-Wpedantic"
, everything = self:kind() == "cxx" and {"-Wall", "-Wextra", "-Weffc++"} or {"-Wall", "-Wextra"}
, error = "-Werror"
}
diff --git a/xmake/modules/private/check/checkers/api/target/warnings.lua b/xmake/modules/private/check/checkers/api/target/warnings.lua
index 4e6cf5794..016a3e6a3 100644
--- a/xmake/modules/private/check/checkers/api/target/warnings.lua
+++ b/xmake/modules/private/check/checkers/api/target/warnings.lua
@@ -23,5 +23,6 @@ import(".api_checker")
function main(opt)
opt = opt or {}
- api_checker.check_targets("warnings", table.join(opt, {values = {"none", "less", "more", "all", "allextra", "everything", "error"}}))
+ api_checker.check_targets("warnings", table.join(opt, {values = {
+ "none", "less", "more", "extra", "all", "allextra", "everything", "pedantic", "error"}}))
end