-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
[flang] Allow assumed-shape element pass to dummy arg with ignore_tkr #78196
Conversation
This is allowed by gfortran and ifort with ![GCC|DEC]$ ATTRIBUTES NO_ARG_CHECK I'm not sure if 'r' is the right specifier for this, maybe there should be a new one?
I'm not sure if |
@llvm/pr-subscribers-flang-semantics Author: Tom Eccles (tblah) ChangesThis is allowed by gfortran and ifort with Full diff: https://github.com/llvm/llvm-project/pull/78196.diff 2 Files Affected:
diff --git a/flang/lib/Semantics/check-call.cpp b/flang/lib/Semantics/check-call.cpp
index ec8f99ca6bf48e..ba8903089f836d 100644
--- a/flang/lib/Semantics/check-call.cpp
+++ b/flang/lib/Semantics/check-call.cpp
@@ -535,7 +535,8 @@ static void CheckExplicitDataArg(const characteristics::DummyDataObject &dummy,
messages.Say(
"Element of pointer array may not be associated with a %s array"_err_en_US,
dummyName);
- } else if (IsAssumedShape(*actualLastSymbol)) {
+ } else if (IsAssumedShape(*actualLastSymbol) &&
+ !dummy.ignoreTKR.test(common::IgnoreTKR::Rank)) {
basicError = true;
messages.Say(
"Element of assumed-shape array may not be associated with a %s array"_err_en_US,
diff --git a/flang/test/Semantics/ignore_tkr03.f90 b/flang/test/Semantics/ignore_tkr03.f90
new file mode 100644
index 00000000000000..25182d879e1097
--- /dev/null
+++ b/flang/test/Semantics/ignore_tkr03.f90
@@ -0,0 +1,18 @@
+! RUN: %flang_fc1 -fdebug-unparse %s 2>&1 | FileCheck %s
+module library
+contains
+ subroutine lib_sub(buf)
+!dir$ ignore_tkr(r) buf
+ real :: buf(1:*)
+ end subroutine
+end module
+
+module user
+ use library
+contains
+ subroutine sub(var)
+ real :: var(:,:,:)
+! CHECK: CALL lib_sub
+ call lib_sub(var(1, 2, 3))
+ end subroutine
+end module
|
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.
I don't think that 'R' is the right letter to use here. It's not about rank, it's about storage sequence association with a potentially non-contiguous object. Besides assumed-shape arrays, you probably also want to allow non-CONTIGUOUS
pointers.
Thanks for the review. I repurposed the (previously legacy) |
That might conflict with legacy codes still being compiled by nvfortran. I'll check. |
The legacy meaning of |
@klausler thanks for checking my use of As |
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.
Ship it with my thanks.
This is allowed by gfortran and ifort with
![GCC|DEC]$ ATTRIBUTES NO_ARG_CHECK