[flang-commits] [flang] [flang][OpenACC] Relax COMMON block usage restriction in OpenACC directives (PR #162659)
Eugene Epshteyn via flang-commits
flang-commits at lists.llvm.org
Mon Oct 20 10:02:03 PDT 2025
================
@@ -3627,6 +3627,27 @@ void ModuleVisitor::Post(const parser::UseStmt &x) {
}
}
}
+ // Go through the list of COMMON block symbols in the module scope and add
----------------
eugeneepshteyn wrote:
COMMON block names and sizes are already stored in `SemanticsContext`, available via `SemanticsContext::GetCommonBlocks()`. This is what lowering is using to generate correctly sized blob for COMMON.
We already have a warning for COMMON size differences. The following code
```
module common_multi_mod_a
integer :: a
common /my_common/ a
end module
module common_multi_mod_b
integer :: b
integer :: c
common /my_common/ b, c
end module
subroutine s1()
use common_multi_mod_a
a = 1
end subroutine
subroutine s2()
use common_multi_mod_b
b = 2
c = 3
end subroutine
subroutine s3()
use common_multi_mod_b
use common_multi_mod_a
a = 4
b = 5
c = 6
end subroutine
```
... generates the following warning:
```
$ flang -c common-multi-mod.f90 -pedantic
./common-multi-mod.f90:9:11: portability: A named COMMON block should have the same size everywhere it appears (8 bytes here) [-Wdistinct-common-sizes]
common /my_common/ b, c
^^^^^^^^^
./common-multi-mod.f90:3:11: Previously defined with a size of 4 bytes
common /my_common/ a
^^^^^^^^^
```
https://github.com/llvm/llvm-project/pull/162659
More information about the flang-commits
mailing list