code-yeongyu / code-yeongyu/c11-compiler-zig-omo

[Sisyphus] phase-2 / zcc / Wave 4 — Semantic analysis

Open
#20 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
3
Forks
0
PR merge metrics
No merged PRs in 30d

Description

## Scope
Implement semantic analysis: type checking, constraint validation, and C11-specific semantics.

## Deliverables
- `phase2/zcc/src/sema.zig` — semantic analyzer.
- `phase2/zcc/src/diag.zig` — diagnostic engine (errors, warnings, notes with locations).
- `phase2/zcc/src/types.zig` — type representation and operations (integer promotions, usual arithmetic conversions, qualifier propagation).

## Coverage
- Type checking for all expressions and statements.
- Integer promotions and usual arithmetic conversions per C11 §6.3.
- Lvalue / rvalue distinction and qualifier propagation.
- `_Atomic` type semantics (atomic array rejection, atomic struct/union rules).
- `_Static_assert` compile-time constant evaluation.
- Alignment checks (`_Alignas` on bit-field rejection, valid alignment values).
- VLA constraints (VLA in struct rejection, VLA size evaluation).
- All C11 constraint violations must produce a diagnostic.

## Success Criteria
1. **Must REJECT** every source file under `phase1/c11-ref/negative/*.c` with a diagnostic that matches the constraint diagnostic produced by gcc/clang (same constraint, same approximate wording acceptable).
2. All positive reference files (`001..023`) pass semantic analysis with zero errors.
3. Diagnostics include file, line, column, and a human-readable message.

## Dependencies on Prior Waves
- **Wave 0–3** — parser must produce AST before it can be semantically analyzed.

## Suggested Role Assignment
`sema-engineer`

## Test Corpus Expectations
- Negative corpus: each `negative/*.c` must trigger exactly the expected constraint error.
- Positive corpus: `001..023` must pass sema cleanly.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with phase2/zcc/src/sema.zig, then read phase2/zcc/src/diag.zig and phase2/zcc/src/types.zig to understand the semantic-analysis, diagnostic, and type-operation responsibilities. Use phase1/c11-ref/negative/*.c and the positive reference files 001..023 as the test corpus. Done means negative files produce the expected constraint diagnostics, positive files pass without errors, and diagnostics include file, line, column, and a human-readable message.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, zig
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.