[PowerPC][NFC] Cleanup PPCCTRLoopsVerify pass
[llvm-project.git] / flang / unittests / Runtime / external-hello.cpp
blobeba345481db91c38c3c3936f81ad430b777853fe
1 #include "../../runtime/io-api.h"
2 #include "../../runtime/main.h"
3 #include "../../runtime/stop.h"
4 #include <cstring>
6 using namespace Fortran::runtime::io;
8 void output1() {
9 auto io{IONAME(BeginExternalListOutput)()};
10 const char str[]{"Hello, world!"};
11 IONAME(OutputAscii)(io, str, std::strlen(str));
12 IONAME(OutputInteger64)(io, 678);
13 IONAME(OutputReal64)(io, 0.0);
14 IONAME(OutputReal64)(io, 2.0 / 3.0);
15 IONAME(OutputReal64)(io, 1.0e99);
16 IONAME(OutputReal64)(io, 1.0 / 0.0);
17 IONAME(OutputReal64)(io, -1.0 / 0.0);
18 IONAME(OutputReal64)(io, 0.0 / 0.0);
19 IONAME(OutputComplex64)(io, 123.0, -234.0);
20 IONAME(OutputLogical)(io, false);
21 IONAME(OutputLogical)(io, true);
22 IONAME(EndIoStatement)(io);
25 void input1() {
26 auto io{IONAME(BeginExternalListOutput)()};
27 const char prompt[]{"Enter an integer value:"};
28 IONAME(OutputAscii)(io, prompt, std::strlen(prompt));
29 IONAME(EndIoStatement)(io);
31 io = IONAME(BeginExternalListInput)();
32 std::int64_t n{-666};
33 IONAME(InputInteger)(io, n);
34 IONAME(EndIoStatement)(io);
36 io = IONAME(BeginExternalListOutput)();
37 const char str[]{"Result:"};
38 IONAME(OutputAscii)(io, str, std::strlen(str));
39 IONAME(OutputInteger64)(io, n);
40 IONAME(EndIoStatement)(io);
43 int main(int argc, const char *argv[], const char *envp[]) {
44 RTNAME(ProgramStart)(argc, argv, envp);
45 output1();
46 input1();
47 RTNAME(PauseStatement)();
48 RTNAME(ProgramEndStatement)();
49 return 0;