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][cuda] Remove check for obsolete constraint #70707

Merged
merged 1 commit into from
Oct 31, 2023

Conversation

klausler
Copy link
Contributor

The online CUDA Fortran documentation states that a device subprogram must be a top-level module subprogram, but this has turned out to be an obsolete constraint. Stop enforcing it.

@llvmbot llvmbot added flang Flang issues not falling into any other category flang:semantics labels Oct 30, 2023
Copy link
Contributor

@clementval clementval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Peter! LGTM

@llvmbot
Copy link
Collaborator

llvmbot commented Oct 30, 2023

@llvm/pr-subscribers-flang-semantics

Author: Peter Klausler (klausler)

Changes

The online CUDA Fortran documentation states that a device subprogram must be a top-level module subprogram, but this has turned out to be an obsolete constraint. Stop enforcing it.


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

2 Files Affected:

  • (modified) flang/lib/Semantics/check-declarations.cpp (-6)
  • (modified) flang/test/Semantics/cuf02.cuf (-2)
diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp
index 2c2866d590ae5a4..32583643dc0f2e9 100644
--- a/flang/lib/Semantics/check-declarations.cpp
+++ b/flang/lib/Semantics/check-declarations.cpp
@@ -1394,12 +1394,6 @@ void CheckHelper::CheckSubprogram(
     if (ClassifyProcedure(symbol) == ProcedureDefinitionClass::Internal) {
       messages_.Say(symbol.name(),
           "A device subprogram may not be an internal subprogram"_err_en_US);
-    } else if ((*cudaAttrs == common::CUDASubprogramAttrs::Device ||
-                   *cudaAttrs == common::CUDASubprogramAttrs::HostDevice) &&
-        (symbol.owner().kind() != Scope::Kind::Module ||
-            details.isInterface())) {
-      messages_.Say(symbol.name(),
-          "An ATTRIBUTES(DEVICE) subprogram must be a top-level module procedure"_err_en_US);
     }
   }
   if ((!details.cudaLaunchBounds().empty() ||
diff --git a/flang/test/Semantics/cuf02.cuf b/flang/test/Semantics/cuf02.cuf
index 38b3e783d86b3a4..881a3005e2817bd 100644
--- a/flang/test/Semantics/cuf02.cuf
+++ b/flang/test/Semantics/cuf02.cuf
@@ -1,7 +1,6 @@
 ! RUN: %python %S/test_errors.py %s %flang_fc1
 module m
   interface
-    !ERROR: An ATTRIBUTES(DEVICE) subprogram must be a top-level module procedure
     attributes(device) subroutine exts1
     end
   end interface
@@ -44,6 +43,5 @@ module m
   end
 end
 
-!ERROR: An ATTRIBUTES(DEVICE) subprogram must be a top-level module procedure
 attributes(device) subroutine exts1
 end

The online CUDA Fortran documentation states that a device subprogram
must be a top-level module subprogram, but this has turned out to
be an obsolete constraint.  Stop enforcing it.
@klausler klausler merged commit f19af90 into llvm:main Oct 31, 2023
3 checks passed
@klausler klausler deleted the bug1421 branch October 31, 2023 19:39
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