[flang-commits] [flang] be449d6 - [flang][openacc] fix a bug with checking data mapping clause when there is no default (#151419)
via flang-commits
flang-commits at lists.llvm.org
Wed Jul 30 22:51:12 PDT 2025
Author: Andre Kuhlenschmidt
Date: 2025-07-30T22:51:09-07:00
New Revision: be449d6b6587af30fd999a8ede88ff06bb7535df
URL: https://github.com/llvm/llvm-project/commit/be449d6b6587af30fd999a8ede88ff06bb7535df
DIFF: https://github.com/llvm/llvm-project/commit/be449d6b6587af30fd999a8ede88ff06bb7535df.diff
LOG: [flang][openacc] fix a bug with checking data mapping clause when there is no default (#151419)
Test case used to complain about `dosomething` requiring a data mapping
clause. Now no such error exists.
Added:
flang/test/Semantics/OpenACC/acc-default-none-function.f90
Modified:
flang/lib/Semantics/resolve-directives.cpp
Removed:
################################################################################
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
+
More information about the flang-commits
mailing list