Fix #686: Add warning for bad line directives#687
Open
glankk wants to merge 18 commits into
Open
Conversation
danmar
reviewed
Jul 22, 2026
danmar
reviewed
Jul 22, 2026
danmar
reviewed
Jul 23, 2026
Co-authored-by: Daniel Marjamäki <daniel.marjamaki@gmail.com>
danmar
reviewed
Jul 23, 2026
Co-authored-by: Daniel Marjamäki <daniel.marjamaki@gmail.com>
danmar
reviewed
Jul 23, 2026
danmar
reviewed
Jul 23, 2026
| try { | ||
| line = std::stoul(ppTok->str()); | ||
| } catch (...) { | ||
| line = std::numeric_limits<unsigned long>::max(); |
Collaborator
There was a problem hiding this comment.
this value might not work well.. it means tokens might get line number 0 which cppcheck interprets as "no line".
I suggest that the value passed in the lineDirective call will be 1. After reporting the error message.. change it to 1?
Collaborator
Author
There was a problem hiding this comment.
Actually it might be better that we just ignore the line number and use the current one when it's out of range, what do you think?
Collaborator
Author
There was a problem hiding this comment.
Or just discard the line directive entirely.
Collaborator
There was a problem hiding this comment.
I would be fine with both those options.
danmar
reviewed
Jul 23, 2026
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.
readfilenow takes aDUIwith information about which standard to use, which is needed to determine if a warning should be issued or not.preprocessnow also includes outputs frommakeTokenListswhich callsreadfile. Some tests had to be fixed to have an ending newline because of this in order to pass.