Skip to content

[flang][openacc] fix a bug with checking data mapping clause when there is no default #151419

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

Merged
merged 2 commits into from
Jul 31, 2025

Conversation

akuhlens
Copy link
Contributor

@akuhlens akuhlens commented Jul 30, 2025

Test case used to complain about dosomething requiring a data mapping clause. Now no such error exists.

@akuhlens akuhlens requested a review from eugeneepshteyn July 30, 2025 23:23
@akuhlens akuhlens requested a review from klausler July 30, 2025 23:27
@eugeneepshteyn
Copy link
Contributor

Typo in description? "use too"

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.

LGTM and thanks

@akuhlens akuhlens marked this pull request as ready for review July 31, 2025 03:00
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:openmp openacc flang:semantics labels Jul 31, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 31, 2025

@llvm/pr-subscribers-flang-semantics

@llvm/pr-subscribers-flang-openmp

Author: Andre Kuhlenschmidt (akuhlens)

Changes

Test case used to complain about dosomething requiring a data mapping clause. Now no such error exists.


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

2 Files Affected:

  • (modified) flang/lib/Semantics/resolve-directives.cpp (+2-2)
  • (added) flang/test/Semantics/OpenACC/acc-default-none-function.f90 (+20)
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 4c3e509b5a36d..aa006b1a353ed 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -1545,6 +1545,7 @@ void AccAttributeVisitor::Post(const parser::AccDefaultClause &x) {
 void AccAttributeVisitor::Post(const parser::Name &name) {
   auto *symbol{name.symbol};
   if (symbol && !dirContext_.empty() && GetContext().withinConstruct) {
+    symbol = &symbol->GetUltimate();
     if (!symbol->owner().IsDerivedType() && !symbol->has<ProcEntityDetails>() &&
         !symbol->has<SubprogramDetails>() && !IsObjectWithDSA(*symbol)) {
       if (Symbol * found{currScope().FindSymbol(name.source)}) {
@@ -1553,8 +1554,7 @@ void AccAttributeVisitor::Post(const parser::Name &name) {
         } else if (GetContext().defaultDSA == Symbol::Flag::AccNone) {
           // 2.5.14.
           context_.Say(name.source,
-              "The DEFAULT(NONE) clause requires that '%s' must be listed in "
-              "a data-mapping clause"_err_en_US,
+              "The DEFAULT(NONE) clause requires that '%s' must be listed in a data-mapping clause"_err_en_US,
               symbol->name());
         }
       }
diff --git a/flang/test/Semantics/OpenACC/acc-default-none-function.f90 b/flang/test/Semantics/OpenACC/acc-default-none-function.f90
new file mode 100644
index 0000000000000..f0a697fc21669
--- /dev/null
+++ b/flang/test/Semantics/OpenACC/acc-default-none-function.f90
@@ -0,0 +1,20 @@
+! RUN: %python %S/../test_errors.py %s %flang -fopenacc -pedantic
+
+module mm_acc_rout_function
+contains
+    integer function dosomething(res)
+        !$acc routine seq
+        integer :: res
+        dosomething = res + 1
+    end function
+end module
+    
+program main
+    use mm_acc_rout_function
+    implicit none
+    integer :: res = 1
+    !$acc serial default(none) copy(res)
+    res = dosomething(res)
+    !$acc end serial
+end program
+

@akuhlens akuhlens merged commit be449d6 into llvm:main Jul 31, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:openmp flang:semantics flang Flang issues not falling into any other category openacc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants