[flang] Disallow passing array actual arguments to ignore_tkr(r) scalars with VALUE attribute#166682
Merged
eugeneepshteyn merged 3 commits intollvm:mainfrom Nov 12, 2025
Merged
Conversation
…ars with VALUE attribute
Member
|
@llvm/pr-subscribers-flang-semantics Author: Eugene Epshteyn (eugeneepshteyn) ChangesScalars with VALUE attribute are likely passed in registers, so it's now clear what lowering should do with the array actual argument in this case. Fail this case with an error before getting to lowering. Full diff: https://github.com/llvm/llvm-project/pull/166682.diff 2 Files Affected:
diff --git a/flang/lib/Semantics/check-call.cpp b/flang/lib/Semantics/check-call.cpp
index 995deaa12dd3b..53a22768855e1 100644
--- a/flang/lib/Semantics/check-call.cpp
+++ b/flang/lib/Semantics/check-call.cpp
@@ -548,8 +548,13 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
actualLastSymbol = &ResolveAssociations(*actualLastSymbol);
}
int actualRank{actualType.Rank()};
- if (dummy.type.attrs().test(
- characteristics::TypeAndShape::Attr::AssumedShape)) {
+ if (dummyIsValue && dummyRank == 0 &&
+ dummy.ignoreTKR.test(common::IgnoreTKR::Rank) && actualRank > 0) {
+ messages.Say(
+ "Array actual argument may not be associated with IGNORE_TKR(R) scalar %s with VALUE attribute"_err_en_US,
+ dummyName);
+ } else if (dummy.type.attrs().test(
+ characteristics::TypeAndShape::Attr::AssumedShape)) {
// 15.5.2.4(16)
if (actualIsAssumedRank) {
messages.Say(
diff --git a/flang/test/Semantics/val-tkr.f90 b/flang/test/Semantics/val-tkr.f90
new file mode 100644
index 0000000000000..bed41f3ed0569
--- /dev/null
+++ b/flang/test/Semantics/val-tkr.f90
@@ -0,0 +1,22 @@
+! RUN: %python %S/test_errors.py %s %flang_fc1
+implicit none
+interface
+ subroutine s(b)
+ !dir$ ignore_tkr(tr) b
+ real, value :: b
+ end
+ subroutine s1(b)
+ !dir$ ignore_tkr(r) b
+ integer, value :: b
+ end
+end interface
+integer :: a(5), a1
+! forbid array to scalar with VALUE and ignore_tkr(r)
+!ERROR: Array actual argument may not be associated with IGNORE_TKR(R) scalar dummy argument 'b=' with VALUE attribute
+call s(a)
+!ERROR: Array actual argument may not be associated with IGNORE_TKR(R) scalar dummy argument 'b=' with VALUE attribute
+call s1(a)
+! allow scalar to scalar with VALUE
+call s(a1)
+call s1(a(1))
+end
|
jeanPerier
reviewed
Nov 6, 2025
Contributor
jeanPerier
left a comment
There was a problem hiding this comment.
Thanks Eugene.
Can you update flang/docs/Directives.md to say a word about the VALUE case to explain when it is allowed and what to expect when allowed?
klausler
approved these changes
Nov 6, 2025
Contributor
Author
Doc updated. Please review. |
git-crd
pushed a commit
to git-crd/crd-llvm-project
that referenced
this pull request
Nov 13, 2025
…ars with VALUE attribute (llvm#166682) Scalars with VALUE attribute are likely passed in registers, so it's now clear what lowering should do with the array actual argument in this case. Fail this case with an error before getting to lowering.
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.
Scalars with VALUE attribute are likely passed in registers, so it's now clear what lowering should do with the array actual argument in this case. Fail this case with an error before getting to lowering.