diff --git a/flang/lib/Lower/IO.cpp b/flang/lib/Lower/IO.cpp --- a/flang/lib/Lower/IO.cpp +++ b/flang/lib/Lower/IO.cpp @@ -1764,6 +1764,11 @@ mlir::Value id = fir::getBase(converter.genExprValue( loc, getExpr(stmt), stmtCtx)); args.push_back(builder.createConvert(loc, beginFuncTy.getInput(1), id)); + args.push_back(locToFilename(converter, loc, beginFuncTy.getInput(2))); + args.push_back(locToLineNo(converter, loc, beginFuncTy.getInput(3))); + } else { + args.push_back(locToFilename(converter, loc, beginFuncTy.getInput(1))); + args.push_back(locToLineNo(converter, loc, beginFuncTy.getInput(2))); } auto cookie = builder.create(loc, beginFunc, args).getResult(0); genConditionHandlerCall(converter, loc, cookie, stmt.v, csi); diff --git a/flang/test/Lower/io-statement-1.f90 b/flang/test/Lower/io-statement-1.f90 --- a/flang/test/Lower/io-statement-1.f90 +++ b/flang/test/Lower/io-statement-1.f90 @@ -28,7 +28,7 @@ ! CHECK: call {{.*}}EndIoStatement endfile(8) - ! CHECK: call {{.*}}BeginWaitAll + ! CHECK: call {{.*}}BeginWaitAll(%{{.*}}, %{{.*}}, %{{.*}}) ! CHECK: call {{.*}}EndIoStatement wait(unit=8)