phase0/01: recursive Type with closed variant payload - #80
Merged
Conversation
Replace the optional-bag / indirection-counter Type model with a std::variant payload and recursive pointer/array pointees so pointer-to-function and pointer-to-array no longer bleed nested kinds. Keep master-facing shims (getAlignment, canAssignFrom, memberCount, memberAt, isIncompleteStructure, completeStructure) and structure validation (incomplete members, duplicates, size overflow). Shared StructBody identity preserves incomplete tag completion for self-ref structs. Function gains an optional variadic flag (default false). Unit tests pin the recursive contracts; full ctest suite stays green. Also ignore /.grok for local plan tracking.
- Natural alignment is size for modeled primitives (long double = 16); drop MAX_ALIGN clamp on records. - completeStructure/completeUnion require an existing record body (domain_error on non-record). - array() rejects incomplete record elements. - pointer() applies qualifiers via Type(qualifiers) constructor. - Centralize record/array payload access via private helpers. - Rename incompleteRecord/getMembers/isIncompleteRecord as canonical APIs with structure* shims; rename elementStrideBytes. - Unit tests pin alignment, complete-on-non-record, and incomplete array.
- Collapse isPointerToBareFunction to isPointerToFunction alias. - isIncompleteMemberOrElementType includes incomplete records; drop redundant double-checks in Type.cpp. - isIncompleteObjectType uses isIncompleteRecord. - Fix stale sizeof bag-model comment in SA. - Unit-test incomplete-record for isIncompleteMemberOrElementType.
Stop clamping array element stride to 1 so sizeof(T[n]) is n*sizeof(T) for empty complete structs/unions. Add union layout and empty-record array unit tests.
- Layout complete into temporary members; swap only on success so failed re-complete cannot corrupt shared StructBody identity. - sizeof(type) rejects incomplete object types (void, bare function, incomplete records), matching unary sizeof. - Structure-named complete/incomplete predicates are struct-only; SA uses isIncompleteRecord for declarations. - Unit tests for exception-safe layout and structure-only aliases; functional test for sizeof(struct Incomplete); move residual Type tests into namespace.
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
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
Typewith closed variant payload (host finish-for-git transplant, Phase 0 foundation).Stack
Base:
master→ this PR →phase0/02-type-policy(and rest of stack)Test plan
ctest/ package tests green on this tip