-
Notifications
You must be signed in to change notification settings - Fork 419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Narrow lvalue checking special case from arrays to array views #22816
Merged
Conversation
This file contains 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
--- Signed-off-by: Michael Ferguson <[email protected]>
mppf
changed the title
Restrict lvalue checking from arrays to array slices
Narrow lvalue checking special case from arrays to array slices
Jul 26, 2023
--- Signed-off-by: Michael Ferguson <[email protected]>
To avoid compilation error in runtime/configMatters/comm/unordered/unorderedCopyStress --- Signed-off-by: Michael Ferguson <[email protected]>
--- Signed-off-by: Michael Ferguson <[email protected]>
--- Signed-off-by: Michael Ferguson <[email protected]>
To avoid the lvalue error but still have the tests check the if-expr array memory management. --- Signed-off-by: Michael Ferguson <[email protected]>
lydia-duncan
approved these changes
Jul 27, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor update request to the PR message but otherwise this is great, thanks!
mppf
changed the title
Narrow lvalue checking special case from arrays to array slices
Narrow lvalue checking special case from arrays to array views
Jul 27, 2023
mppf
added a commit
that referenced
this pull request
Aug 1, 2023
Adjusts a test to adapt to the new error from PR #22816. Test change only - not reviewed.
jabraham17
added a commit
that referenced
this pull request
Aug 22, 2023
Deprecates ref-maybe-const for array formal arguments. Compiler will warn when a ref-maybe-const formal is inferred to be `ref` in `cullOverReferences`. This will not warn for compiler generated functions or outer variables (when outlining nested functions). It is written in a way that exceptions can be removed to implement other ref-maybe-const deprecations. Implements part of the decisions for #21398 (comment) ## Summary of changes - add explicit intents (either `ref` or `const`) where needed in modules and tests - some functions, the body was modified to remove the need for an explicit intent (eg `ref a = ...` to `const ref a = ...`) - tweaks `compiler/passes/expandExternArrayCalls.cpp` to interpret intents and use `c_ptrConst`. - added temporaries for lvalue errors due to #22816 - tweaks `compiler/passes/normalize.cpp` to fix lvalue error with `convertToExternalArray`. - rewrite `bulkAdd` for sparse domains to prefer codepaths that do not require `sort` - calling sort along any codepath requires the `inds` to be marked as `ref` - instead of taking a `preserveInds` boolean argument, now there is a separate `bulkAddNoPreserveInds` - change uses of `c_ptrTo` to `c_ptrToConst` where applicable ## New tests - add `test/deprecated/ref-maybe-const.chpl` - also added deprecation tests for this intents, task intents, and forall intents, these are marked notest for now - futurize `test/functions/ferguson/ref-pair/ifexpr/ifexpr2-1.chpl` - add `test/users/ibertolacc/void_extern_proc_array_ref.chpl` ## Testing - paratest (llvm) with futures - paratest (llvm) with gasnet - paratest (c) - paratest with --verify [Reviewed by @vasslitvinov] closes Cray/chapel-private#5218
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.
Resolves #22330
Resolves #20166
This PR implements Option 2 from #22330 by changing an exception in
isLegalLvalueActualArg
for arrays into an exception for array views (including slices). That makes arrays more consistent with other types while allowing code assigning to a slice, e.g.,A[2..n-1] = 1.0
, to continue to work. The rationale for having an exception for array views is 1) they are a pretty special type already and 2) they arguably behave more as a reference than a value (and in the future, might be considered a special kind of reference).For example, here is a program that previously compiled, but after this PR fails to compile with an lvalue error:
To address this error, a user will need to add a new variable:
To do so, this PR updates
isLegalLvalueActualArg
as described above and also updates the code propagating flags to promotion wrapper functions to considerFLAG_REF_TO_CONST_WHEN_CONST_THIS
, to address an issue that was revealed in testing. While there, this PR moves the code propagatingFLAG_OPERATOR
, frominitPromotionWrapper
tobuildEmptyWrapper
(where the other flags are handled).Reviewed by @lydia-duncan - thanks!