Skip to content

Conversation

@lumynou5
Copy link
Contributor

@lumynou5 lumynou5 commented May 18, 2025

A parameter list is either a single keyword "void" or a comma-separated list of parameters according to the standard. Previously, only the latter is supported, and the former leads to unexpected token errors.

Summary by Bito

This pull request significantly enhances the parser by allowing a single 'void' keyword as a valid parameter list, resolving unexpected token errors and standardizing function signatures across multiple files. New tests have been added to ensure robust handling of parameter declarations.

Unit tests added: True

Estimated effort to review (1-5, lower is better): 2 - The changes are clear and well-documented, making the review process straightforward.

@jserv jserv requested review from ChAoSUnItY and DrXiao May 18, 2025 05:03
Copy link
Collaborator

@ChAoSUnItY ChAoSUnItY left a comment

Choose a reason for hiding this comment

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

Please add tests in tests/driver.sh to validate your work follows specification's description.

@DrXiao
Copy link
Collaborator

DrXiao commented May 18, 2025

The current shecc also contains functions such as global_init() and global_release() that have no parameters., I think the proposed changes can modify them as well by explicitly adding void to their parameter lists. Therefore, the bootstrapping process can also validate whether the usage of void is correctly parsed.

@lumynou5 lumynou5 requested a review from ChAoSUnItY May 19, 2025 14:31
Copy link
Collaborator

@ChAoSUnItY ChAoSUnItY left a comment

Choose a reason for hiding this comment

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

Rebase the latest master branch and resolve the error.

@lumynou5 lumynou5 force-pushed the void-parameter-list branch from d025779 to 2649b08 Compare May 20, 2025 07:32
lumynou5 added 4 commits May 20, 2025 15:41
A parameter list is either a single keyword "void" or a comma-separated
list of parameters according to the standard.  Previously, only the
latter is supported, and the former leads to unexpected token errors.
'void' must be the only parameter and unnamed to indicate no parameters.
Previously, the check for functions with first parameter of void
pointer, etc. didn't consider the illegal forms, so those could pass
compilation.
Adds the keyword "void" to the parameter lists of functions.  This helps
validation of the implementation of "void" parameter lists in the
bootstrapping process.  Especially K&R style exists until C23, though
it's not implemented in shecc now, shecc is first built by another
compiler such as gcc and is written in C99 (as per Makefile).

Suggested-by: Yu-En Hsiao <[email protected]>
@lumynou5 lumynou5 force-pushed the void-parameter-list branch from 2649b08 to fb762cd Compare May 20, 2025 07:43
@lumynou5 lumynou5 requested a review from ChAoSUnItY May 20, 2025 07:43
@jserv jserv merged commit 68ef318 into sysprog21:master May 20, 2025
6 checks passed
@jserv
Copy link
Collaborator

jserv commented May 20, 2025

Thank @lumynou5 for contributing!

@lumynou5 lumynou5 deleted the void-parameter-list branch May 20, 2025 15:44
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.

4 participants