GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — add missing #line directive to misra.py by driftregion · Pull Request #8879 · cppcheck-opensource/cppcheck

Conversation

@driftregion

@driftregion driftregion commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Hello cppcheck maintainer. Thank you for your work.

The #line preprocessor directive (standard since C90) was missing from misra.py, leading to false positives in my analysis. I have added it here.

See:
https://en.cppreference.com/c/preprocessor/line

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@driftregion
add missing #line directive to misra.py
d4aa765
danmar
danmar reviewed Oct 1, 2026
View reviewed changes
Comment thread addons/misra.py
dir = mo.group(1)
if dir not in ['define', 'elif', 'else', 'endif', 'error', 'if', 'ifdef', 'ifndef', 'include',
'pragma', 'undef', 'warning']:
'pragma', 'undef', 'warning', 'line']:

@danmar danmar Oct 1, 2026

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

This is an AI review. Take it with a grain of salt and feel free to reject it by resolving the comment.

The fix looks right to me: #line is a standard directive, and with this change the 20.13 false positive is gone.

Could you add a regression test? One option that doesn't shift any line numbers in addons/test/misra/misra-test.c is to replace the empty line after #else1 // 20.13 (line 1946) with:

#line 1947

I tried it with the same commands CI uses (cppcheck --dump -DDUMMY --suppress=uninitvar --inline-suppr misra/misra-test.c --std=c89 --platform=unix64 + misra.py -verify). Without your fix it reports Not expected: misra/misra-test.c:1946 20.13, and with your fix it passes.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@driftregion driftregion Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Hi Daniel, thanks for your work maintaining cppcheck. I had a look at the AI reviews on #8879, #8876, and cppcheck-opensource/simplecpp#704 just now. They seem reasonable. Before I go about addressing them, I'd like to request your human opinion on whether you endorse the AI-proposed changes. This statement makes it clear that the review was AI-generated (great idea btw), but leaves me with some confusion about whether the human in the loop endorses its content:

This is an AI review. Take it with a grain of salt and feel free to reject it by resolving the comment.

Thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@danmar danmar Nov 3, 2026

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I looked quickly. Adding that test seems reasonable to me.

I will mostly trust peoples judgments about AI reviews.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
dmcppcheck
dmcppcheck reviewed Nov 6, 2026
View reviewed changes

@dmcppcheck dmcppcheck left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

AI review

I found no new problems. With this change, #line directives are no longer reported as misra-c2012-20.13, and I checked all the ways of spelling the directive that I tried. A malformed directive such as #lines 3 is still reported. The PR still doesn't add the regression test that was asked for in comments.md (#line 1947 in addons/test/misra/misra-test.c). That has already been raised, so I'm not repeating it as a separate comment.

Testing

  • I built cppcheck in pr/ with make -j8 cppcheck.
  • I wrote scratch/t.c with several spellings of the directive:
    #line 10
    # line 20 "x.c"
    #	line 30
    #line	40
    #  line 50
    #lines 3
    int x;
    I ran cppcheck --dump -q t.c and then python3 misra.py t.c.dump with both the PR's and the base's misra.py.
    • PR: 20.13 is reported only for #lines 3 (x.c:50), which is correct.
    • Base: 20.13 is reported for all 6 directives.
    • simplecpp turns tabs into single spaces in the directive string in the dump, so the space-only regex in misra_20_13 handles those cases correctly.
  • Existing MISRA verify test: I ran cppcheck --dump -DDUMMY --suppress=uninitvar --inline-suppr misra/misra-test.c --std=c89 --platform=unix64 followed by misra.py -verify misra/misra-test.c.dump. It reported no Not expected or Not detected lines.
  • pytest: python3 -m pytest addons/test/misra_test.py stopped with a collection error before running any tests, so that suite was not run. I did not look into the cause.

Automated review of d4aa765 by Claude. The pull request was built and tested locally.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@danmar danmar danmar left review comments
@dmcppcheck dmcppcheck dmcppcheck left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@driftregion @danmar @dmcppcheck
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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.