Skip to content

[flang] Dig deeper to find more EVENT_TYPE/LOCK_TYPE misuse #130687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions flang/lib/Semantics/check-declarations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3717,6 +3717,20 @@ void CheckHelper::CheckSymbolType(const Symbol &symbol) {
"'%s' has a type %s with a deferred type parameter but is neither an allocatable nor an object pointer"_err_en_US,
symbol.name(), dyType->AsFortran());
}
if (!symbol.has<ObjectEntityDetails>()) {
if (const DerivedTypeSpec *
derived{evaluate::GetDerivedTypeSpec(*dyType)}) {
if (IsEventTypeOrLockType(derived)) {
messages_.Say(
"Entity '%s' with EVENT_TYPE or LOCK_TYPE must be an object"_err_en_US,
symbol.name());
} else if (auto iter{FindEventOrLockPotentialComponent(*derived)}) {
messages_.Say(
"Entity '%s' with EVENT_TYPE or LOCK_TYPE potential subobject component '%s' must be an object"_err_en_US,
symbol.name(), iter.BuildResultDesignatorName());
}
}
}
}
}

Expand Down
14 changes: 14 additions & 0 deletions flang/test/Semantics/event02b.f90
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ program test_event_wait
character(len=128) error_message, non_scalar_char(1), co_indexed_character[*], superfluous_errmsg
logical invalid_type

type t
type(event_type) event
end type
!ERROR: Entity 'badfunc0' with EVENT_TYPE or LOCK_TYPE must be an object
procedure(type(event_type)) :: badfunc0
!ERROR: Entity 'badfunc1' with EVENT_TYPE or LOCK_TYPE must be an object
procedure(type(event_type)), pointer :: badfunc1
!ERROR: Entity 'badfunc2' with EVENT_TYPE or LOCK_TYPE potential subobject component '%event' must be an object
procedure(type(t)) badfunc2
!ERROR: Entity 'badfunc3' with EVENT_TYPE or LOCK_TYPE must be an object
type(event_type), external :: badfunc3
!ERROR: Entity 'badfunc4' with EVENT_TYPE or LOCK_TYPE potential subobject component '%event' must be an object
type(t), external :: badfunc4

!____________________ non-standard-conforming statements __________________________

!_________________________ invalid event-variable ________________________________
Expand Down