Skip to content

Commit

Permalink
[flang] Disallow ASYNCHRONOUS for subroutine
Browse files Browse the repository at this point in the history
The check for inappropriate usage of the ASYNCHRONOUS attribute
needed to be moved in declaration checking so that it can catch
attempts to use it on a subroutine.

Differential Revision: https://reviews.llvm.org/D155970
  • Loading branch information
klausler committed Jul 21, 2023
1 parent e7cb677 commit 24445fc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 6 additions & 5 deletions flang/lib/Semantics/check-declarations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,12 @@ void CheckHelper::Check(const Symbol &symbol) {
CheckContiguous(symbol);
}
CheckGlobalName(symbol);
if (symbol.attrs().test(Attr::ASYNCHRONOUS) &&
!evaluate::IsVariable(symbol)) {
messages_.Say(
"An entity may not have the ASYNCHRONOUS attribute unless it is a variable"_err_en_US);
}

if (isDone) {
return; // following checks do not apply
}
Expand Down Expand Up @@ -429,11 +435,6 @@ void CheckHelper::Check(const Symbol &symbol) {
symbol.name());
}
}
if (symbol.attrs().test(Attr::ASYNCHRONOUS) &&
!evaluate::IsVariable(symbol)) {
messages_.Say(
"An entity may not have the ASYNCHRONOUS attribute unless it is a variable"_err_en_US);
}
}

void CheckHelper::CheckCommonBlock(const Symbol &symbol) {
Expand Down
2 changes: 2 additions & 0 deletions flang/test/Semantics/resolve20.f90
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ function f()
contains
subroutine bar
end subroutine
!ERROR: An entity may not have the ASYNCHRONOUS attribute unless it is a variable
subroutine test
asynchronous test
!ERROR: Abstract procedure interface 'foo2' may not be referenced
call foo2()
!ERROR: Abstract procedure interface 'f' may not be referenced
Expand Down

0 comments on commit 24445fc

Please sign in to comment.