feat(types): array types and sizeof - #68
Merged
Merged
Conversation
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
3 tasks
rieske
force-pushed
the
feature/switch-case
branch
from
July 24, 2026 07:12
4e72ebc to
664d527
Compare
rieske
force-pushed
the
feature/recursive-type-sizeof
branch
from
July 24, 2026 07:12
df5b3ef to
fa34efb
Compare
rieske
force-pushed
the
feature/recursive-type-sizeof
branch
from
July 24, 2026 07:18
fa34efb to
adb305e
Compare
rieske
force-pushed
the
feature/switch-case
branch
from
July 24, 2026 07:18
664d527 to
608b6e1
Compare
rieske
force-pushed
the
feature/recursive-type-sizeof
branch
from
July 24, 2026 07:27
adb305e to
c27b7a9
Compare
rieske
force-pushed
the
feature/switch-case
branch
from
July 24, 2026 07:27
608b6e1 to
015d412
Compare
Add type::array as a recursive element type with size, wire sized array declarators, and implement sizeof (expr) / sizeof(type) including simple pointer type names. Functional tests cover sizeof and array declaration sizing without requiring array element access.
Fold array bounds during semantic analysis and report invalid sizes via semanticError instead of throwing from getFundamentalType. Frame layout for multi-element arrays remains one slot per local (sizeof-only safe).
Sized array types are established in semantic analysis; the declarator visitor no longer throws. Update the unit expectation accordingly.
Replace the inline type_name+abstract lambda with a free function to match other CSNB creators, and note that casts remain unimplemented while sizeof(type) works.
rieske
force-pushed
the
feature/recursive-type-sizeof
branch
from
July 24, 2026 07:34
c27b7a9 to
b9f786c
Compare
Reject array size overflow and incomplete element types, treat pointer-to-array as pointer-only, diagnose sizeof(void), and add functional/unit coverage for those paths (also restores Sizeof surface).
Diagnose sizeof of function designators (not just sizeof(type)), and keep FunctionDeclarator recovery when FormalArgument already rejected an incomplete array parameter type.
Treat only bare function types as incomplete for sizeof and array elements; allow pointer-to-function. Print nested array dimensions outside-in. Add regression coverage for both.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
type::array(T, n)with recursive element type andgetSize().sizeof exprandsizeof(type)for primitives and pointers.Review follow-ups
element_size * count/ count > INT_MAX).void a[3], void parameters).isArray()false for pointer-to-array.sizeof(void).Known limitations (intentional this slice)
Stack
PR 5/6 — base is master. Tip is #69.
Test plan
ctest