diff --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp index 6099ec419e415..966884fb4c32a 100644 --- a/flang/lib/Semantics/expression.cpp +++ b/flang/lib/Semantics/expression.cpp @@ -3247,6 +3247,13 @@ static void FixMisparsedFunctionReference( if (auto *func{ std::get_if>(&u)}) { parser::FunctionReference &funcRef{func->value()}; + // Ensure that there are no argument keywords + for (const auto &arg : + std::get>(funcRef.v.t)) { + if (std::get>(arg.t)) { + return; + } + } auto &proc{std::get(funcRef.v.t)}; if (Symbol *origSymbol{ common::visit(common::visitors{ diff --git a/flang/test/Semantics/call32.f90 b/flang/test/Semantics/call32.f90 new file mode 100644 index 0000000000000..80e9c02a7114c --- /dev/null +++ b/flang/test/Semantics/call32.f90 @@ -0,0 +1,8 @@ +! RUN: %python %S/test_errors.py %s %flang_fc1 -Werror +! Ensure that a seemingly misparsed function reference is +! not converted to an array references of the same name if +! there's an argument keyword. +real array(1) +!ERROR: 'array' is not a callable procedure +print *, array(argument=1) +end