-
Notifications
You must be signed in to change notification settings - Fork 147
Improve C language features #240
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
Conversation
| int cast_ptr_level = 0; | ||
|
|
||
| /* Look ahead to see if we have a typename followed by ) */ | ||
| if (lex_peek(T_identifier, lookahead_token)) { |
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.
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.
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.
We can handle va_arg macro implementation in a follow-up PR.
- 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
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.
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.
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.