Skip to content

Commit fe8abcc

Browse files
committed
[flang] Catch attempt to apply ASYNCHRONOUS attribute to a non-variable
Complain about the ASYNCHRONOUS attribute on symbols that aren't variables. Differential Revision: https://reviews.llvm.org/D146573
1 parent e76d236 commit fe8abcc

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

flang/lib/Semantics/check-declarations.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,11 @@ void CheckHelper::Check(const Symbol &symbol) {
437437
symbol.name());
438438
}
439439
}
440+
if (symbol.attrs().test(Attr::ASYNCHRONOUS) &&
441+
!evaluate::IsVariable(symbol)) {
442+
messages_.Say(
443+
"An entity may not have the ASYNCHRONOUS attribute unless it is a variable"_err_en_US);
444+
}
440445
}
441446

442447
void CheckHelper::CheckCommonBlock(const Symbol &symbol) {

flang/test/Semantics/resolve20.f90

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ subroutine forward
5454
!ERROR: EXTERNAL attribute not allowed on 'bar'
5555
external :: bar
5656

57+
!ERROR: An entity may not have the ASYNCHRONOUS attribute unless it is a variable
58+
asynchronous :: async
59+
external :: async
60+
5761
!ERROR: PARAMETER attribute not allowed on 'm'
5862
parameter(m=2)
5963
!ERROR: PARAMETER attribute not allowed on 'foo'

0 commit comments

Comments
 (0)