Repository navigation
Fix #15310: internalError with shadowing typedef - #9116
Open
ludviggunne wants to merge 2 commits into
Open
ludviggunne wants to merge 2 commits into
ludviggunne wants to merge 2 commits into
Conversation
dmcppcheck
reviewed
Dec 4, 2026
dmcppcheck
left a comment
Contributor
There was a problem hiding this comment.
AI review
I found no problems. For a self-referencing typedef inside any { scope (function, class or namespace), the PR now falls back to the old simplifier instead of throwing internalError. On every shadowing case I tried, the output is correct where base reported internalError, and none of my tests gave a regression, crash or hang. At global scope it still throws as before. The backward scan only runs when a self-referencing name is found, so it adds no cost to the normal path.
Testing
- Build:
make -j8 cppcheck testrunnerinpr/andmake -j8 cppcheckinbase/both built without errors. - Unit tests:
./testrunnerpassed with 0 failures for TestSimplifyTypedef (216 tests, including the newsimplifyTypedef165), TestSimplifyUsing, TestTokenizer and TestGarbage. - Fuzz files: the PR's
cppcheck -qran on every file intest/cli/fuzz-crash,fuzz-crash_candfuzz-timeoutwith a 20 s timeout per file. None crashed, hung or returned non-zero. - My own inputs: run with
cppcheck -q --debug, PR against base:struct T{}; void f(){ typedef T* T; { T y = 0; T z[2]; } }: base givesinternalError, the PR givesT * y; … T * z[2];(correct).typedef const U* U;in a function, followed by a null dereference: base givesinternalErrorand the null dereference is never reported; the PR reportsnullPointer.void f(){ typedef T* T; typedef T* T; T p; }: the PR givesT * * p;(correct).void k(){ typedef void (*T)(T); T fp; }: the PR givesvoid (*fp)(T);(correct).typedef T* T;in a namespace, a class and a struct (struct S { typedef S* S; S p; };), and a typedef shadowing an earlier local typedef: all handled by the PR, allinternalErrorin base.extern "C" { typedef T* T; T p; }:internalErrorin both base and the PR.typedef T T[3];andtypedef T T::*T;:syntaxErrorin both base and the PR.typedef V<T> T;,typedef struct T T;,typedef decltype(T) T;: same output as base.void f(){ typedef unsigned T T; T p; }: base givesinternalError, the PR givesunsigned int T p ;. The code is invalid C++, so I'm not reporting it.
Automated review of 42910b8 by Claude. The pull request was built and tested locally.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.