parser: allow readonly storage and results for untyped constref - #49
Open
Moonbot-Tech wants to merge 2 commits into
Open
parser: allow readonly storage and results for untyped constref#49Moonbot-Tech wants to merge 2 commits into
Moonbot-Tech wants to merge 2 commits into
Conversation
…stream#41766) A formal constref parameter, like an ordinary const, may bind to a constant expression, but the assignment check rejected it with "Can't assign values to const variable", and codegen materialized a non-reference actual only for const formals. Add valid_const to the check and materialize the actual for constref formals the same way as for const ones: both promise the callee an address. FPC issue: https://gitlab.com/freepascal.org/fpc/source/-/issues/41766 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Author
|
FPC merge request: https://gitlab.com/freepascal.org/fpc/source/-/merge_requests/1554 |
Make the original forwarding oracle endian-independent. Cover storage identity, register and managed results, forwarding and simultaneous temporaries; keep readonly-to-writable and scalar-literal rejection controls. Clarify valid_const scope without changing compiler behavior.
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.
Problem. FPC #41766: forwarding an element of readonly storage to an untyped
constrefparameter was rejected as an assignment to a const variable.Fix. Permit readonly storage in the frontend and materialize accepted non-reference actuals, such as function results, for the call. Existing references retain their addresses. The earlier title overstated the change:
valid_constis not permission to pass arbitrary scalar literals or arithmetic expressions.Tests. The original buffer test is now endian-independent.
tw41766avaries storage origin (local, field, dynamic array, typed constant, integer/FP/managed function result), direct/forwarded/typed consumers, evaluation counts and two simultaneous temporaries.tw41766b/ckeep scalar-literal and readonly-to-var/out rejection controls.Validation. The new runtime matrix passes on this Unleashed branch at -O3 on Win64. The corresponding FPC branch passes -O-/-O2/-O3 on Win64 and -O3 on i386-win32. Removing only constref materialization from the FPC patch makes the new matrix fail with IE 200304235, independently covering that part of the fix.
Upstream MR: https://gitlab.com/freepascal.org/fpc/source/-/merge_requests/1554. This PR waits for the FPC decision.