setCurrentPosition(Fortran::lower::pft::stmtSourceLoc(funit.endStmt));
if (funit.isMainProgram())
genExitRoutine();
+ else
+ genFIRProcedureExit(funit, funit.getSubprogramSymbol());
funit.finalBlock = nullptr;
LLVM_DEBUG(llvm::dbgs() << "*** Lowering result:\n\n"
<< *builder->getFunction() << '\n');
}
void genFIR(const Fortran::parser::EndProgramStmt &) { genExitRoutine(); }
+ void genFIRProcedureExit(Fortran::lower::pft::FunctionLikeUnit &funit,
+ const Fortran::semantics::Symbol &symbol) {
+ if (Fortran::semantics::IsFunction(symbol)) {
+ TODO(toLocation(), "Function lowering");
+ } else {
+ genExitRoutine();
+ }
+ }
+
void genFIR(const Fortran::parser::CallStmt &stmt) {
TODO(toLocation(), "CallStmt lowering");
}
TODO(toLocation(), "EndSelectStmt lowering");
}
- void genFIR(const Fortran::parser::EndSubroutineStmt &) {
- TODO(toLocation(), "EndSubroutineStmt lowering");
- }
+ // Nop statements - No code, or code is generated at the construct level.
+ void genFIR(const Fortran::parser::EndSubroutineStmt &) {} // nop
void genFIR(const Fortran::parser::EntryStmt &) {
TODO(toLocation(), "EntryStmt lowering");
--- /dev/null
+! RUN: bbc %s --pft-test | FileCheck %s
+! RUN: bbc %s -o "-" -emit-fir | FileCheck %s --check-prefix=FIR
+
+subroutine sub1()
+end subroutine
+
+! CHECK: 1 Subroutine sub1: subroutine sub1()
+! CHECK: 1 EndSubroutineStmt: end subroutine
+! CHECK: End Subroutine sub1
+
+! FIR-LABEL: func @_QPsub1() {
+! FIR: return
+! FIR: }