Stop with non-zero exit status

Looks like GFortran’s parser cannot parse it yet. In LFortran we can parse it:

$ cat b.f90 
program test
STOP 1, QUIET=.TRUE.
end
$ lfortran --show-ast b.f90 
(TranslationUnit [(Program test () [] [] [] [(Stop 0 1 (Logical .true.) ())] [])])

But the quiet=.true. gets lost by the time it gets to ASR:

$ lfortran --show-asr b.f90
(TranslationUnit (SymbolTable 1 {test: (Program (SymbolTable 2 {}) test [] [(Stop (ConstantInteger 1 (Integer 4 [])))])}) [])

And by the time it gets to LLVM, also the non-zero exit code gets lost:

$ lfortran --show-llvm b.f90
; ModuleID = 'LFortran'
source_filename = "LFortran"

@0 = private unnamed_addr constant [6 x i8] c"STOP\0A\00", align 1

define i32 @main() {
.entry:
  call void (i8*, ...) @_lfortran_printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @0, i32 0, i32 0))
  call void @exit(i32 0)
  ret i32 0
}

declare void @_lfortran_printf(i8*, ...)

declare void @exit(i32)

We need to fix it: Implement nonzero exit code and `quiet` in STOP (#597) · Issues · lfortran / lfortran · GitLab

1 Like