You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[flang][OpenMP] Refactor/update semantic checks for ALLOCATE directive (#164420)
OpenMP 5.0 and 5.1 allowed the ALLOCATE directive to appear in two
forms, declarative and executable. The syntax of an individual directive
was the same in both cases, but the semantic restrictions were slightly
different.
- Update the semantic checks to reflect the different restrictions,
gather them in a single function.
- Improve test for the presence of a TARGET region, add a check for
REQUIRES directive.
- Update tests.
"List item '%s' in ALLOCATE directive must not be a dummy "
1700
-
"argument"_err_en_US,
1701
-
source.ToString());
1750
+
"An ALLOCATE directive in a TARGET region must specify an ALLOCATOR clause or REQUIRES(DYNAMIC_ALLOCATORS) must be specified"_err_en_US);
1751
+
}
1752
+
}
1753
+
1754
+
auto maybePredefined{maybeHasPredefinedAllocator(allocator)};
1755
+
1756
+
for (auto &[symbol, source] : symbols) {
1757
+
if (!inExecutableAllocate_) {
1758
+
if (symbol->owner() != thisScope) {
1759
+
context_.Say(source,
1760
+
"A list item on a declarative ALLOCATE must be declared in the same scope in which the directive appears"_err_en_US);
1761
+
}
1762
+
if (IsPointer(*symbol) || IsAllocatable(*symbol)) {
1763
+
context_.Say(source,
1764
+
"A list item in a declarative ALLOCATE cannot have the ALLOCATABLE or POINTER attribute"_err_en_US);
1765
+
}
1702
1766
}
1703
1767
if (symbol->GetUltimate().has<AssocEntityDetails>()) {
1704
1768
context_.Say(source,
1705
-
"List item '%s' in ALLOCATE directive must not be an associate "
1706
-
"name"_err_en_US,
1707
-
source.ToString());
1769
+
"A list item in a declarative ALLOCATE cannot be an associate name"_err_en_US);
1770
+
}
1771
+
if (symbol->attrs().test(Attr::SAVE) || IsCommonBlock(*symbol)) {
1772
+
if (!allocator) {
1773
+
context_.Say(source,
1774
+
"If a list item is a named common block or has SAVE attribute, an ALLOCATOR clause must be present with a predefined allocator"_err_en_US);
1775
+
} elseif (!maybePredefined) {
1776
+
context_.Say(source,
1777
+
"If a list item is a named common block or has SAVE attribute, only a predefined allocator may be used on the ALLOCATOR clause"_err_en_US);
1778
+
}
1779
+
}
1780
+
if (FindCommonBlockContaining(*symbol)) {
1781
+
context_.Say(source,
1782
+
"A variable that is part of a common block may not be specified as a list item in an ALLOCATE directive, except implicitly via the named common block"_err_en_US);
"List items specified in the ALLOCATE directive must not have the ALLOCATABLE attribute unless the directive is associated with an ALLOCATE statement"_err_en_US);
Copy file name to clipboardExpand all lines: flang/test/Semantics/OpenMP/allocate06.f90
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ subroutine allocate()
11
11
integer:: a, b, x
12
12
real, dimension (:,:), allocatable:: darray
13
13
14
-
!ERROR: List items specified in the ALLOCATE directive must not have the ALLOCATABLE attribute unless the directive is associated with an ALLOCATE statement
14
+
!ERROR: A list item in a declarative ALLOCATE cannot have the ALLOCATABLE or POINTER attribute
0 commit comments