mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-18 19:06:44 +00:00
[flang] Fix crash in CO_REDUCE semantics (#131211)
A std::optional<> value was being accessed without first ensuring its presence.
This commit is contained in:
parent
3f04fb42aa
commit
329bfa91b0
@ -1688,8 +1688,10 @@ static void CheckCoReduce(
|
||||
characteristics::FunctionResult::Attr::Allocatable,
|
||||
characteristics::FunctionResult::Attr::Pointer,
|
||||
};
|
||||
const auto *result{
|
||||
procChars ? procChars->functionResult->GetTypeAndShape() : nullptr};
|
||||
const characteristics::TypeAndShape *result{
|
||||
procChars && procChars->functionResult
|
||||
? procChars->functionResult->GetTypeAndShape()
|
||||
: nullptr};
|
||||
if (!procChars || !procChars->IsPure() ||
|
||||
procChars->dummyArguments.size() != 2 || !procChars->functionResult) {
|
||||
messages.Say(
|
||||
|
6
flang/test/Semantics/bug396.f90
Normal file
6
flang/test/Semantics/bug396.f90
Normal file
@ -0,0 +1,6 @@
|
||||
! RUN: %python %S/test_errors.py %s %flang_fc1
|
||||
external ext
|
||||
integer caf[*]
|
||||
!ERROR: OPERATION= argument of CO_REDUCE() must be a pure function of two data arguments
|
||||
call co_reduce(caf, ext)
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user