xref: /llvm-project/flang/test/Driver/input-from-stdin/input-from-stdin.f90 (revision 9edcf7a28eee1e3b2d22bd3aed9e405e17beacce)
152a3855fSDavid Spickett! Verify that reading from stdin works as expected - Fortran input
252a3855fSDavid Spickett
352a3855fSDavid Spickett!--------------------------
452a3855fSDavid Spickett! FLANG DRIVER (flang)
552a3855fSDavid Spickett!--------------------------
652a3855fSDavid Spickett! Input type is implicit
752a3855fSDavid Spickett! RUN: cat %s | %flang -E -cpp - | FileCheck %s --check-prefix=PP-NOT-DEFINED
852a3855fSDavid Spickett! RUN: cat %s | %flang -DNEW -E -cpp - | FileCheck %s --check-prefix=PP-DEFINED
952a3855fSDavid Spickett! RUN: cat %s | %flang -DNEW -E - | FileCheck %s --check-prefix=PP-NOT-DEFINED
1052a3855fSDavid Spickett! RUN: cat %s | %flang -DNEW -E -nocpp - | FileCheck %s --check-prefix=PP-NOT-DEFINED
1152a3855fSDavid Spickett
1252a3855fSDavid Spickett! Input type is explicit
1352a3855fSDavid Spickett! RUN: cat %s | %flang -E -cpp -x f95-cpp-input - | FileCheck %s --check-prefix=PP-NOT-DEFINED
1452a3855fSDavid Spickett! RUN: cat %s | %flang -DNEW -E -cpp -x f95-cpp-input - | FileCheck %s --check-prefix=PP-DEFINED
1552a3855fSDavid Spickett
1652a3855fSDavid Spickett!---------------------------------------
1752a3855fSDavid Spickett! FLANG FRONTEND DRIVER (flang -fc1)
1852a3855fSDavid Spickett!---------------------------------------
1952a3855fSDavid Spickett! Test `-E`: for the corresponding frontend actions the driver relies on the prescanner API to handle file I/O
20*9edcf7a2SLeandro Lupori! RUN: cat %s | %flang_fc1 -E -cpp | FileCheck %s --check-prefix=PP-NOT-DEFINED
21*9edcf7a2SLeandro Lupori! RUN: cat %s | %flang_fc1 -DNEW -E -cpp | FileCheck %s --check-prefix=PP-DEFINED
2252a3855fSDavid Spickett
2352a3855fSDavid Spickett! Test `-test-io`: for the corresponding frontend action (`InputOutputTestAction`) the driver handles the file I/O on its own
2452a3855fSDavid Spickett! the corresponding action (`PrintPreprocessedAction`)
25*9edcf7a2SLeandro Lupori! RUN: cat %s | %flang_fc1 -test-io -cpp | FileCheck %s --check-prefix=IO --match-full-lines
26*9edcf7a2SLeandro Lupori! RUN: cat %s | %flang_fc1 -DNEW -cpp -test-io | FileCheck %s --check-prefix=IO --match-full-lines
2752a3855fSDavid Spickett
2852a3855fSDavid Spickett! PP-NOT-DEFINED: Program B
2952a3855fSDavid Spickett! PP-DEFINED: Program A
3052a3855fSDavid Spickett
3152a3855fSDavid Spickett! IO: #ifdef NEW
3252a3855fSDavid Spickett! IO-NEXT:   Program A
3352a3855fSDavid Spickett! IO-NEXT: #else
3452a3855fSDavid Spickett! IO-NEXT:   Program B
3552a3855fSDavid Spickett! IO-NEXT: #endif
3652a3855fSDavid Spickett
3752a3855fSDavid Spickett#ifdef NEW
3852a3855fSDavid Spickett  Program A
3952a3855fSDavid Spickett#else
4052a3855fSDavid Spickett  Program B
4152a3855fSDavid Spickett#endif
42