[flang-commits] [flang] a8d48fe - [flang] Handle character constant for error code in STOP stmt
Valentin Clement via flang-commits
flang-commits at lists.llvm.org
Mon Feb 7 03:20:12 PST 2022
Author: Valentin Clement
Date: 2022-02-07T12:19:55+01:00
New Revision: a8d48fe0fe52468a6bd355824a27db2de1a9595f
URL: https://github.com/llvm/llvm-project/commit/a8d48fe0fe52468a6bd355824a27db2de1a9595f
DIFF: https://github.com/llvm/llvm-project/commit/a8d48fe0fe52468a6bd355824a27db2de1a9595f.diff
LOG: [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
Added:
Modified:
flang/lib/Lower/Runtime.cpp
flang/test/Lower/stop-statement.f90
Removed:
################################################################################
diff --git a/flang/lib/Lower/Runtime.cpp b/flang/lib/Lower/Runtime.cpp
index e5270bf1b393a..32b67ab62aa77 100644
--- a/flang/lib/Lower/Runtime.cpp
+++ b/flang/lib/Lower/Runtime.cpp
@@ -49,7 +49,14 @@ void Fortran::lower::genStopStatement(
llvm::dbgs() << '\n');
expr.match(
[&](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) {
callee = fir::runtime::getRuntimeFunc<mkRTKey(StopStatement)>(
diff --git a/flang/test/Lower/stop-statement.f90 b/flang/test/Lower/stop-statement.f90
index d90e514bdc361..8b8935fc0bfdf 100644
--- a/flang/test/Lower/stop-statement.f90
+++ b/flang/test/Lower/stop-statement.f90
@@ -51,3 +51,15 @@ subroutine stop_quiet()
! 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<!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
More information about the flang-commits
mailing list