Skip to content

Conversation

@jgarzik
Copy link
Contributor

@jgarzik jgarzik commented Dec 9, 2025

No description provided.

@jgarzik jgarzik requested a review from Copilot December 9, 2025 02:08
@jgarzik jgarzik self-assigned this Dec 9, 2025
@jgarzik jgarzik added the enhancement New feature or request label Dec 9, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements support for C99 compound literals (§6.5.2.5), which allow creating unnamed objects with initializer-list syntax directly in expressions. The implementation correctly handles both automatic storage duration (block scope) and static storage duration (file scope) as required by the C99 standard.

Key changes:

  • Parser now recognizes (type){initializer-list} syntax and handles incomplete array types (int[]){...}
  • New CompoundLiteral AST node added to represent these expressions
  • Linearizer generates appropriate storage (local variables or static globals) based on scope

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
cc/tests/datatypes/struct_type.rs Adds 7 comprehensive tests covering basic usage, designated initializers, arrays, function arguments, address-of, and file-scope compound literals
cc/parse/parser.rs Implements compound literal parsing in primary expressions and adds support for incomplete array types int[] in type names
cc/parse/ast.rs Adds CompoundLiteral enum variant to ExprKind with appropriate documentation
cc/ir/linearize.rs Implements three contexts for compound literals: initializers (creates static globals), lvalue (returns address), and rvalue (creates local storage with proper value/pointer semantics)
cc/arch/x86_64/codegen.rs Updates global emission to treat symbols starting with '.' as local (not globally visible)
cc/arch/aarch64/codegen.rs Updates global emission to treat symbols starting with '.' as local (not globally visible)
cc/doc/BUGS.md Removes the compound literal bug entry since the feature is now implemented

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jgarzik jgarzik merged commit 4f88b02 into main Dec 9, 2025
10 checks passed
@jgarzik jgarzik deleted the updates branch December 9, 2025 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants