Index: flang/lib/Semantics/resolve-names.cpp =================================================================== --- flang/lib/Semantics/resolve-names.cpp +++ flang/lib/Semantics/resolve-names.cpp @@ -2053,12 +2053,19 @@ // If the function has a type in the prefix, process it now. FuncInfo *info{Top()}; if (info && &info->scope == &scopeHandler_.currScope()) { - if (info->parsedType) { + if (info->parsedType && info->resultSymbol) { scopeHandler_.messageHandler().set_currStmtSource(info->source); if (const auto *type{ scopeHandler_.ProcessTypeSpec(*info->parsedType, true)}) { - if (!scopeHandler_.context().HasError(info->resultSymbol)) { - info->resultSymbol->SetType(*type); + Symbol &symbol{*info->resultSymbol}; + if (!scopeHandler_.context().HasError(symbol)) { + if (symbol.GetType()) { + scopeHandler_.Say(symbol.name(), + "Function cannot have both an explicit type prefix and a RESULT suffix"_err_en_US); + scopeHandler_.context().SetError(symbol); + } else { + symbol.SetType(*type); + } } } info->parsedType = nullptr;