Skip to content

added make target check-nonneg / generate (and fixed) all warnings in NONNEG build#7747

Merged
firewave merged 3 commits intodanmar:mainfrom
firewave:nonneg-x
Aug 23, 2025
Merged

added make target check-nonneg / generate (and fixed) all warnings in NONNEG build#7747
firewave merged 3 commits intodanmar:mainfrom
firewave:nonneg-x

Conversation

@firewave
Copy link
Copy Markdown
Collaborator

No description provided.

@firewave
Copy link
Copy Markdown
Collaborator Author

Yeah - I will make this a Make/CMake target.

@firewave firewave changed the title generate (and fixed) all warnings in NONNEG build added make target check-nonneg / generate (and fixed) all warnings in NONNEG build Aug 18, 2025
```
lib/astutils.cpp:115:23: error: comparison of unsigned expression in ‘< 0’ is always false [-Werror=type-limits]
  115 |     if (!tok || depth < 0)
      |                 ~~~~~~^~~
```
@firewave
Copy link
Copy Markdown
Collaborator Author

I will add the CMake target in a follow-up. It is not as straight forward as I thought and it will most likely interfere with the pending CMake modernization.

@firewave firewave marked this pull request as ready for review August 18, 2025 10:55
@sonarqubecloud
Copy link
Copy Markdown

@firewave
Copy link
Copy Markdown
Collaborator Author

We should probably also run the tests with NONNEG but that is something for later.

@firewave
Copy link
Copy Markdown
Collaborator Author

The output from the new target from https://github.com/danmar/cppcheck/actions/runs/17038518479/job/48296502830:

ls lib/*.cpp | xargs -n 1 -P $(nproc) g++ -fsyntax-only -DNONNEG -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 -D_GLIBCXX_DEBUG -g -pipe -std=c++11 -Ilib -isystem externals -isystem externals/picojson -isystem externals/simplecpp -isystem externals/tinyxml2

@firewave
Copy link
Copy Markdown
Collaborator Author

I will add the CMake target in a follow-up. It is not as straight forward as I thought and it will most likely interfere with the pending CMake modernization.

I filed https://trac.cppcheck.net/ticket/14080 about this.

Comment thread lib/astutils.cpp

template<class T, class OuputIterator, REQUIRES("T must be a Token class", std::is_convertible<T*, const Token*> )>
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)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spontanously I would have changed the code instead so it can't be negative.. but it doesn't matter much. I can accept this.

@firewave firewave merged commit 9f21f84 into danmar:main Aug 23, 2025
63 checks passed
@firewave firewave deleted the nonneg-x branch August 23, 2025 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants