Skip to content

Conversation

@jserv
Copy link
Collaborator

@jserv jserv commented Aug 10, 2025

The commits focus on type safety improvements, new C language features (unions, compound literals, sizeof), and enhanced string/literal support.

Summary by Bito

This pull request significantly enhances C language features by improving type safety, adding support for unions and compound literals, and enhancing the handling of literals and escape sequences. It introduces new casting operations and includes comprehensive tests to ensure robustness and correctness, making the language more expressive and safer.

int cast_ptr_level = 0;

/* Look ahead to see if we have a typename followed by ) */
if (lex_peek(T_identifier, lookahead_token)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure if this would be too much to be fit into this patch, but it would be good to also have macro parameter handled here, so later va_arg macro could be implemented.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We can handle va_arg macro implementation in a follow-up PR.

jserv added 6 commits August 12, 2025 14:51
- Binary literal support with 0b/0B prefix
- Hexadecimal escape sequences (\xHH)
- Octal escape sequences (\nnn)
- Additional escape characters (\a, \b, \v, \f, \e, \?)
- Adjacent string literal concatenation
- Code formatted with clang-format-18
- sizeof expression support for variables and expressions
- Union type support with proper memory layout
- Compound literal support for basic types and arrays
- Type casting support with explicit (type) syntax
- Enhanced type system with union handling
- Code formatted with clang-format-18
- Add OP_cast instruction for type conversions
- Implement cast support in ARM backend
- Implement cast support in RISC-V backend
- Add cast handling in SSA and register allocation
- Code formatted with clang-format-18
- Add explicit casts in libc for type clarity
- Enhance ELF generation with proper type handling
- Ensure consistent type usage throughout runtime
- Code formatted with clang-format-18
- Tests for binary literals and edge cases
- Tests for all escape sequences
- Tests for sizeof expressions
- Tests for type casting operations
- Tests for compound literals
- Tests for union types and operations
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.

Most of logic looks fine, though I've also noticed some implementation inaccuracies compared to C99 definition in section 5.2.4.1 Translation Limits, but it should be fine at this moment.

@jserv jserv merged commit d2e1d20 into master Aug 12, 2025
12 checks passed
@jserv jserv deleted the cfront branch August 12, 2025 07:21
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.

3 participants