forked from OSchip/llvm-project
[flang] Handle character constant for error code in STOP stmt
Handle character constant ofr error code in the STOP statement. Depends on D118992 This patch is part of the upstreaming effort from fir-dev branch. Reviewed By: kiranchandramohan, schweitz Differential Revision: https://reviews.llvm.org/D118993
This commit is contained in:
parent
74751f4b0c
commit
a8d48fe0fe
|
@ -49,7 +49,14 @@ void Fortran::lower::genStopStatement(
|
||||||
llvm::dbgs() << '\n');
|
llvm::dbgs() << '\n');
|
||||||
expr.match(
|
expr.match(
|
||||||
[&](const fir::CharBoxValue &x) {
|
[&](const fir::CharBoxValue &x) {
|
||||||
TODO(loc, "STOP CharBoxValue first operand not lowered yet");
|
callee = fir::runtime::getRuntimeFunc<mkRTKey(StopStatementText)>(
|
||||||
|
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) {
|
[&](fir::UnboxedValue x) {
|
||||||
callee = fir::runtime::getRuntimeFunc<mkRTKey(StopStatement)>(
|
callee = fir::runtime::getRuntimeFunc<mkRTKey(StopStatement)>(
|
||||||
|
|
|
@ -51,3 +51,15 @@ subroutine stop_quiet()
|
||||||
! CHECK: fir.call @_Fortran{{.*}}StopStatement(%[[c0]], %[[false]], %[[bi1]])
|
! CHECK: fir.call @_Fortran{{.*}}StopStatement(%[[c0]], %[[false]], %[[bi1]])
|
||||||
! CHECK-NEXT: fir.unreachable
|
! CHECK-NEXT: fir.unreachable
|
||||||
end subroutine
|
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<!fir.char<1,5>>
|
||||||
|
! CHECK-DAG: %[[buff:.*]] = fir.convert %[[lit]] : (!fir.ref<!fir.char<1,5>>) -> !fir.ref<i8>
|
||||||
|
! 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
|
||||||
|
|
Loading…
Reference in New Issue