Repository navigation
Fix #15167 FN constVariable with typedef - #8990
chrchr-github wants to merge 3 commits into
Conversation
dmcppcheck
left a comment
There was a problem hiding this comment.
AI review
I found no problems. The new condition still skips a variable whose * comes from a typedef, such as typedef int* P; P p; or P a[2];. It now reports arrays whose element type is a typedef but not a pointer typedef, which is the FN in #15167. All the new warnings I got are valid: const can be added in each case and it compiles. I found no new false positives with pointer typedefs, function-pointer typedefs, array typedefs or typedefs of arrays of pointers.
Testing
- I built
cppcheckandtestrunnerinpr/, andcppcheckinbase/. ./testrunner TestOther: 0 failures.- I ran the cppcheck of the PR on
test/cfg/windows.cppwith--library=windows --platform=win64 --inline-suppr --check-library --enable=style,information --inconclusive --error-exitcode=1. It exited with 0, so the suppression that the PR changes from TODO to active is now matched. - I compared the
constVariableoutput of base and PR on every file intest/cfg/*.c*, without libraries. There was no difference. - I wrote scratch tests (
t1.cpp,t2.cpp) and compared base with the PR:- New warnings, all correct:
typedef int A[2]; A a = {0,0}; return a[0];typedef int I; I a[2][2] = {}; return a[0][0];typedef char CA[4]; CA a[2] = {}; return a[0][0];
- Still no warning, as expected:
- pointer typedefs:
P a[2],P const p,const P p,P* pp, andtypedef int* const CP - function-pointer and struct-pointer typedefs (
FP fs[1],PS a[1]) typedef P PA[2]andtypedef int* PA2[2]when the pointees are written- typedef arrays that are modified through
I* p = a, throughI& r = a[0], or passed asI (&)[2] - typedef arrays whose elements are written
- pointer typedefs:
- New warnings, all correct:
Automated review of 63bf235 by Claude. The pull request was built and tested locally.
|
Test results for commit 63bf235 (tools/test-my-pr.py, main compared to this PR): Test: http://ec2-16-170-140-253.eu-north-1.compute.amazonaws.com/pr-8990/ Posted automatically by the cppcheck PR test runner. +N: warnings only with this PR, -N: warnings only with main. The AI review is written by Claude and can be wrong. |
|
The regressions found by AI are either covered by https://trac.cppcheck.net/ticket/15170 or stem from a preexisting varid issue caused by unknown macros: |
No description provided.