Skip to content

fixed #504 / refs #507 - cleaned up and improved parsing of #line preprocessor directive#586

Open
firewave wants to merge 1 commit into
cppcheck-opensource:masterfrom
firewave:line-comment
Open

fixed #504 / refs #507 - cleaned up and improved parsing of #line preprocessor directive#586
firewave wants to merge 1 commit into
cppcheck-opensource:masterfrom
firewave:line-comment

Conversation

@firewave

@firewave firewave commented Nov 5, 2025

Copy link
Copy Markdown
Collaborator

No description provided.

@firewave

This comment was marked as resolved.

@firewave firewave force-pushed the line-comment branch 4 times, most recently from 5fa16f3 to 4c9bcb4 Compare November 10, 2025 02:06
@firewave firewave changed the title refs #507 - cleaned up and improved parsing of line preprocessor directive refs #507 - cleaned up and improved parsing of #line preprocessor directive Nov 29, 2025
@firewave firewave changed the title refs #507 - cleaned up and improved parsing of #line preprocessor directive fixed #504 / refs #507 - cleaned up and improved parsing of #line preprocessor directive Jan 2, 2026
@firewave firewave linked an issue Jun 2, 2026 that may be closed by this pull request
…d up and improved parsing of line preprocessor directive
@firewave firewave marked this pull request as ready for review June 17, 2026 10:17
Comment thread simplecpp.cpp
if (!ppTok || !ppTok->number)
continue;

const unsigned int line = std::atol(ppTok->str().c_str());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

could you please add a (portability) warning and some handling for wrong values? I believe negative values for instance are undefined behavior. The C99 specification says that it must be "digit-sequence". And:

the digit sequence shall not specify zero, nor a number greater than 2147483647.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I guess you mean a warn if the GNU extension version is being used. I think if the non-supporting compilers (i.e. MSVC) reject it that is unnecessary.

Regarding the handling of more (any) invalid values I would like to handle that through a separate issue and PR as a follow-up.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support prefix-less #line preprocessor directive without file

2 participants