diff --git a/flang/lib/Lower/Runtime.cpp b/flang/lib/Lower/Runtime.cpp --- a/flang/lib/Lower/Runtime.cpp +++ b/flang/lib/Lower/Runtime.cpp @@ -49,7 +49,14 @@ llvm::dbgs() << '\n'); expr.match( [&](const fir::CharBoxValue &x) { - TODO(loc, "STOP CharBoxValue first operand not lowered yet"); + callee = fir::runtime::getRuntimeFunc( + loc, builder); + calleeType = callee.getType(); + // Creates a pair of operands for the CHARACTER and its LEN. + operands.push_back( + builder.createConvert(loc, calleeType.getInput(0), x.getAddr())); + operands.push_back( + builder.createConvert(loc, calleeType.getInput(1), x.getLen())); }, [&](fir::UnboxedValue x) { callee = fir::runtime::getRuntimeFunc( diff --git a/flang/test/Lower/stop-statement.f90 b/flang/test/Lower/stop-statement.f90 --- a/flang/test/Lower/stop-statement.f90 +++ b/flang/test/Lower/stop-statement.f90 @@ -51,3 +51,15 @@ ! CHECK: fir.call @_Fortran{{.*}}StopStatement(%[[c0]], %[[false]], %[[bi1]]) ! CHECK-NEXT: fir.unreachable end subroutine + +! CHECK-LABEL stop_char_lit +subroutine stop_char_lit + ! CHECK-DAG: %[[false:.*]] = arith.constant false + ! CHECK-DAG: %[[five:.*]] = arith.constant 5 : index + ! CHECK-DAG: %[[lit:.*]] = fir.address_of(@_QQ{{.*}}) : !fir.ref> + ! CHECK-DAG: %[[buff:.*]] = fir.convert %[[lit]] : (!fir.ref>) -> !fir.ref + ! CHECK-DAG: %[[len:.*]] = fir.convert %[[five]] : (index) -> i64 + ! CHECK: fir.call @{{.*}}StopStatementText(%[[buff]], %[[len]], %[[false]], %[[false]]) : + ! CHECK-NEXT: fir.unreachable + stop 'crash' +end subroutine stop_char_lit