Repository navigation
Fix #15314 internalError VarId set for bool literal - #9119
wjakobsson wants to merge 2 commits into
Conversation
dmcppcheck
left a comment
There was a problem hiding this comment.
AI review
The PR fixes the static_assert / _Static_assert case, the requires case and the for (V v{…}, w{…};;) case of #15314. No regressions showed up in my tests. One variant still fails in the PR build: void k() noexcept(S::v && true); raises the same internalError: VarId set for bool literal. The reason is that S::v && true inside noexcept(...) of a function declaration is still parsed as a declaration of a reference named true. If the PR is meant to close #15314 completely, noexcept ( probably needs the same treatment as sizeof ( and static_assert (. This is not a regression: base gives the same error. I found no other problems.
Comments
| # | Comment | By | Where | Status |
|---|---|---|---|---|
| 1 | noexcept(S::v && true) still gives internalError: VarId set for bool literal |
AI review | lib/tokenize.cpp:4995 |
🆕 New |
@wjakobsson, please fix, resolve or reply to the open and new comments: #1.
Testing
- I built
cppcheckandtestrunnerfrom pr/ andcppcheckfrom base/. ./testrunner TestVarID TestTokenizer TestSimplifyTemplate TestSymbolDatabaseran 1321 tests and 0 failed.- I compared base and PR one line at a time, each line after
struct S { static const bool v = false; };, withcppcheck --std=c++20 -q. A line counts as an error if the output containsinternalError.
| code | base | pr |
|---|---|---|
static_assert(S::v && true, ""); (namespace scope) |
error | ok |
struct T { static_assert(S::v && true, ""); }; |
error | ok |
static_assert(S::v && true); |
error | ok |
requires clauses, decltype, explicit(...), template args, alignas, if |
ok | ok |
void k() noexcept(S::v && true); |
error | error |
struct A { void k() noexcept(S::v && true); }; |
error | error |
- The
for (V v{ 1, x, true }, w{ 2, x, false }; ;)case: base gives the innerxa new varid (x@var5) and the PR correctly keepsx@var1. - C files with
_Static_assert(b && 1, "")and C23static_assertgive no errors.
The variant that still fails:
// n.cpp
struct S { static const bool v = false; };
void k() noexcept(S::v && true);$ /work/pr/cppcheck -q n.cpp
n.cpp:2:27: error: Internal error. VarId set for bool literal. [internalError]
void k() noexcept(S::v && true);
^
Automated review of 2d765dc by Claude. The pull request was built and tested locally.
| // No variable declarations in sizeof | ||
| if (Token::simpleMatch(tok->previous(), "sizeof (")) { | ||
| // No variable declarations in sizeof and static_assert | ||
| if (Token::Match(tok->previous(), "sizeof|_Static_assert (") || |
There was a problem hiding this comment.
AI review
The same #15314 error still happens with noexcept:
struct S { static const bool v = false; };
void k() noexcept(S::v && true);cppcheck -q n.cpp → n.cpp:2:27: error: Internal error. VarId set for bool literal. [internalError]. It also happens with a member declaration (struct A { void k() noexcept(S::v && true); };). Base has the same error, so this is not a regression, but it is the same bug through another keyword. Should noexcept ( be skipped here as well, like sizeof ( and static_assert (?
No description provided.