[flang-commits] [flang] 5a0b91f - [flang][openacc] Fix false positive error in common block resolution
Valentin Clement via flang-commits
flang-commits at lists.llvm.org
Mon Jul 10 08:39:41 PDT 2023
Author: Valentin Clement
Date: 2023-07-10T08:39:35-07:00
New Revision: 5a0b91fc28212f105c9b49a62444f7b92a54b1ed
URL: https://github.com/llvm/llvm-project/commit/5a0b91fc28212f105c9b49a62444f7b92a54b1ed
DIFF: https://github.com/llvm/llvm-project/commit/5a0b91fc28212f105c9b49a62444f7b92a54b1ed.diff
LOG: [flang][openacc] Fix false positive error in common block resolution
The following error was triggered in the added test case.
This is a false positive.
COMMON block must be declared in the same scoping unit in which the OpenACC directive or clause appears
Reviewed By: kiranchandramohan
Differential Revision: https://reviews.llvm.org/D154742
Added:
Modified:
flang/lib/Semantics/resolve-directives.cpp
flang/test/Semantics/OpenACC/acc-resolve04.f90
Removed:
################################################################################
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 3692a4fcd87588..d96871b2965c11 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -1064,15 +1064,19 @@ void AccAttributeVisitor::Post(const parser::Name &name) {
Symbol *AccAttributeVisitor::ResolveAccCommonBlockName(
const parser::Name *name) {
- if (!name) {
- return nullptr;
- } else if (auto *prev{
- GetContext().scope.parent().FindCommonBlock(name->source)}) {
+ if (auto *prev{name
+ ? GetContext().scope.parent().FindCommonBlock(name->source)
+ : nullptr}) {
name->symbol = prev;
return prev;
- } else {
- return nullptr;
}
+ // Check if the Common Block is declared in the current scope
+ if (auto *commonBlockSymbol{
+ name ? GetContext().scope.FindCommonBlock(name->source) : nullptr}) {
+ name->symbol = commonBlockSymbol;
+ return commonBlockSymbol;
+ }
+ return nullptr;
}
void AccAttributeVisitor::ResolveAccObjectList(
diff --git a/flang/test/Semantics/OpenACC/acc-resolve04.f90 b/flang/test/Semantics/OpenACC/acc-resolve04.f90
index ee5e21adcb5e8c..8a72630a2ec9ff 100644
--- a/flang/test/Semantics/OpenACC/acc-resolve04.f90
+++ b/flang/test/Semantics/OpenACC/acc-resolve04.f90
@@ -1,7 +1,22 @@
! RUN: %flang_fc1 -fopenacc %s
+! Check common block resolution.
! Check that symbol are correctly resolved in device, host and self clause.
+subroutine sub(a)
+ implicit none
+ real :: a(10)
+ real :: b(10), c(10), d
+ common/foo/ b, d, c
+ integer :: i, n
+
+ !$acc declare present(/foo/)
+ !$acc parallel loop gang vector
+ do i = 1, n
+ b(i) = a(i) + c(i) * d
+ end do
+end subroutine
+
program test_resolve04
real :: a(10), b(10)
common /foo/ b, c
More information about the flang-commits
mailing list