Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed several issues relating to the static and const keywords #123

Merged
merged 14 commits into from
Jan 8, 2025

Conversation

VisenDev
Copy link
Contributor

@VisenDev VisenDev commented Jan 1, 2025

This fixes several miscompilations I discovering when attempting to transpile my c code. I also added debug functionality to the parse_error() function which will emit the line and file of where the error was generated. This is helpful for finding out which part of the parser is not working.

@VisenDev
Copy link
Contributor Author

VisenDev commented Jan 1, 2025

catch-bad-whitespace is destroying me lol

@VisenDev
Copy link
Contributor Author

VisenDev commented Jan 1, 2025

I squashed all the commits together since a lot of them were me just fixing whitespace issues caught by the CI

pnut.c Outdated Show resolved Hide resolved
pnut.c Outdated Show resolved Hide resolved
@@ -2705,9 +2734,6 @@ ast parse_cast_expression() {
if (is_type_starter(tok)) {
type = parse_type_with_stars();

if (get_val(type) == 0 && get_op(type) == VOID_KW)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure the exe code generator works well with (void) casts. Do you mind writing a small test for this? You can take a look at tests/_all/comma.c for an example, and can use ./run-tests.sh sh --match cast.c to run the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I gave it a shot, i'm not really familiar with how the testing format works so it may take some tweaks

Makefile Outdated Show resolved Hide resolved
@VisenDev
Copy link
Contributor Author

VisenDev commented Jan 6, 2025

@laurenthuberdeau could you explain what the measure-file-size ci does?

@laurenthuberdeau
Copy link
Collaborator

laurenthuberdeau commented Jan 7, 2025

Sure! measure-file-size is a script I use to track pnut's size. Because I kept breaking the script by accident, I added a CI check so I wouldn't have to bisect and find the commit that broke it next time I wanted to use it. You can run it locally using ./analysis/measure-file-size.sh.

If we look at the difference between the 2 files using diff build/measure/pnut-sh.sh build/measure/pnut-sh-preincluded.sh, we can see lots of diffs like this one:

2512c2512
<       defstr __str_102 "pnut.c"
---
>       defstr __str_102 "build/measure/pnut-sh.c"

Looks like the value of the __FILE__ macro is different between the 2 compilations. It doesn't really break the script, but it fails a sanity check I added in the script that compares the result of compiling pnut.c using pnut-sh and compiling a "packed" version of pnut.c where the includes have been expanded.

Maybe we can add a intermediate __SOURCE_FILE__ macro that can either expand to __FILE__ or to some hard coded string when some compilation option is used to work around this issue?

Edit: I made this PR to fix the script: #132

pnut.c Outdated Show resolved Hide resolved
@laurenthuberdeau laurenthuberdeau merged commit 93bbc5c into udem-dlteam:main Jan 8, 2025
36 checks passed
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.

2 participants