Skip to content
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

Merged
merged 3 commits into from
Jan 22, 2024

Conversation

tblah
Copy link
Contributor

@tblah tblah commented Jan 15, 2024

This is allowed by gfortran and ifort with ![GCC|DEC]$ ATTRIBUTES NO_ARG_CHECK

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?
@tblah
Copy link
Contributor Author

tblah commented Jan 15, 2024

I'm not sure if ignore_tkr(r) is the right specifier for this, maybe there should be a new one? e.g. ignore_tkr(s)

@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Jan 15, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Jan 15, 2024

@llvm/pr-subscribers-flang-semantics

Author: Tom Eccles (tblah)

Changes

This is allowed by gfortran and ifort with ![GCC|DEC]$ ATTRIBUTES NO_ARG_CHECK


Full diff: https://github.com/llvm/llvm-project/pull/78196.diff

2 Files Affected:

  • (modified) flang/lib/Semantics/check-call.cpp (+2-1)
  • (added) flang/test/Semantics/ignore_tkr03.f90 (+18)
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

Copy link
Contributor

@klausler klausler left a 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.

@tblah
Copy link
Contributor Author

tblah commented Jan 16, 2024

Thanks for the review. I repurposed the (previously legacy) ignore_tkr(c).

@klausler
Copy link
Contributor

Thanks for the review. I repurposed the (previously legacy) ignore_tkr(c).

That might conflict with legacy codes still being compiled by nvfortran. I'll check.

@klausler
Copy link
Contributor

Thanks for the review. I repurposed the (previously legacy) ignore_tkr(c).

That might conflict with legacy codes still being compiled by nvfortran. I'll check.

The legacy meaning of C is your interpretation here, so I think it's okay.

@tblah
Copy link
Contributor Author

tblah commented Jan 22, 2024

@klausler thanks for checking my use of C.

As C is okay, is there anything blocking merging this patch?

Copy link
Contributor

@klausler klausler left a 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.

@tblah tblah merged commit 50e2581 into llvm:main Jan 22, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:semantics flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants