From 2c0863e9a07e5823d84d43753bf65599a6a96d52 Mon Sep 17 00:00:00 2001 From: firewave Date: Wed, 13 Aug 2025 15:08:31 +0200 Subject: [PATCH 1/3] CI-unixish.yml: generate all warnings in `NONNEG` build --- .github/workflows/CI-unixish.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI-unixish.yml b/.github/workflows/CI-unixish.yml index 9b720b95b4a..1ea2b30f536 100644 --- a/.github/workflows/CI-unixish.yml +++ b/.github/workflows/CI-unixish.yml @@ -239,9 +239,10 @@ jobs: run: | brew install coreutils + # TODO: avoid duplicating compiler flags from Makefile - name: Check syntax with NONNEG run: | - ls lib/*.cpp | xargs -n 1 -P $(nproc) g++ -fsyntax-only -std=c++0x -Ilib -Iexternals -Iexternals/picojson -Iexternals/simplecpp -Iexternals/tinyxml2 -DNONNEG + ls lib/*.cpp | xargs -n 1 -P $(nproc) g++ -pedantic -Wall -Wextra -Wcast-qual -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Wpacked -Wredundant-decls -Wundef -Wno-sign-compare -Wno-multichar -Woverloaded-virtual -fsyntax-only -std=c++11 -Ilib -Iexternals -Iexternals/picojson -Iexternals/simplecpp -Iexternals/tinyxml2 -DNONNEG build_cmake_boost: From 5b592514c48399874395c98fc84e82f5f1f2072a Mon Sep 17 00:00:00 2001 From: firewave Date: Wed, 13 Aug 2025 23:13:09 +0200 Subject: [PATCH 2/3] astutils.cpp: fixed `-Wtype-limits` GCC warning in `NONNEG` build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``` lib/astutils.cpp:115:23: error: comparison of unsigned expression in ‘< 0’ is always false [-Werror=type-limits] 115 | if (!tok || depth < 0) | ~~~~~~^~~ ``` --- lib/astutils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 8e6ee974f15..ad2a2e05ea7 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -109,7 +109,7 @@ static int getArgumentPos(const Token* ftok, const Token* tokToFind){ } template )> -static void astFlattenCopy(T* tok, const char* op, OuputIterator out, nonneg int depth = 100) +static void astFlattenCopy(T* tok, const char* op, OuputIterator out, int depth = 100) { --depth; if (!tok || depth < 0) From 2ecca59121dee0c537933bd4bdf3abf55f06da95 Mon Sep 17 00:00:00 2001 From: firewave Date: Mon, 18 Aug 2025 12:48:35 +0200 Subject: [PATCH 3/3] added make target `check-nonneg` --- .github/workflows/CI-unixish.yml | 3 +-- Makefile | 3 +++ tools/dmake/dmake.cpp | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI-unixish.yml b/.github/workflows/CI-unixish.yml index 1ea2b30f536..ee7d9cad034 100644 --- a/.github/workflows/CI-unixish.yml +++ b/.github/workflows/CI-unixish.yml @@ -239,10 +239,9 @@ jobs: run: | brew install coreutils - # TODO: avoid duplicating compiler flags from Makefile - name: Check syntax with NONNEG run: | - ls lib/*.cpp | xargs -n 1 -P $(nproc) g++ -pedantic -Wall -Wextra -Wcast-qual -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Wpacked -Wredundant-decls -Wundef -Wno-sign-compare -Wno-multichar -Woverloaded-virtual -fsyntax-only -std=c++11 -Ilib -Iexternals -Iexternals/picojson -Iexternals/simplecpp -Iexternals/tinyxml2 -DNONNEG + make check-nonneg build_cmake_boost: diff --git a/Makefile b/Makefile index 3a8403a1e38..0c3c979e95c 100644 --- a/Makefile +++ b/Makefile @@ -453,6 +453,9 @@ checkCWEEntries: /tmp/errorlist.xml .PHONY: validateRules validateRules: xmllint --noout rules/*.xml +.PHONY: check-nonneg +check-nonneg: + ls lib/*.cpp | xargs -n 1 -P $$(nproc) g++ -fsyntax-only -DNONNEG $(CXXFLAGS) $(INCLUDE_FOR_LIB) ###### Build diff --git a/tools/dmake/dmake.cpp b/tools/dmake/dmake.cpp index e5748ebf389..a9c5248706b 100644 --- a/tools/dmake/dmake.cpp +++ b/tools/dmake/dmake.cpp @@ -867,6 +867,10 @@ int main(int argc, char **argv) fout << ".PHONY: validateRules\n"; fout << "validateRules:\n"; fout << "\txmllint --noout rules/*.xml\n"; + fout << ".PHONY: check-nonneg\n"; + fout << "check-nonneg:\n"; + // TODO: how to use provided number of jobs? + fout << "\tls lib/*.cpp | xargs -n 1 -P $$(nproc) g++ -fsyntax-only -DNONNEG $(CXXFLAGS) $(INCLUDE_FOR_LIB)\n"; fout << "\n###### Build\n\n";