xref: /llvm-project/flang/test/Driver/fixed-free-detection.f90 (revision d5d420bb3bcc2eea926fb70fc3e6818c32e1eecc)
1! Ensure the driver correctly switches between fixed and free form based on the file extension.
2! This test exploits the fact that the prescanner treats whitespace differently for free
3! and fixed form input files.
4
5!--------------------------
6! FLANG DRIVER (flang)
7!--------------------------
8! RUN: %flang -E -Xflang -fno-reformat %S/Inputs/free-form-test.f90  2>&1 | FileCheck %s --check-prefix=FREEFORM
9! RUN: %flang -E -Xflang -fno-reformat %S/Inputs/fixed-form-test.f  2>&1 | FileCheck %s --check-prefix=FIXEDFORM
10! RUN: %flang -E -Xflang -fno-reformat %S/Inputs/free-form-test.f90 %S/Inputs/fixed-form-test.f  2>&1 | FileCheck %s --check-prefix=MULTIPLEFORMS
11
12!-----------------------------------------
13! FRONTEND FLANG DRIVER (flang_fc1)
14!-----------------------------------------
15! RUN: %flang_fc1 -E -fno-reformat %S/Inputs/free-form-test.f90  2>&1 | FileCheck %s --check-prefix=FREEFORM
16! RUN: %flang_fc1 -E -fno-reformat %S/Inputs/fixed-form-test.f  2>&1 | FileCheck %s --check-prefix=FIXEDFORM
17! RUN: %flang_fc1 -E -fno-reformat %S/Inputs/free-form-test.f90 %S/Inputs/fixed-form-test.f  2>&1 | FileCheck %s --check-prefix=MULTIPLEFORMS
18
19! FREEFORM:program freeform
20! FREEFORM-NOT:programfixedform
21
22! FIXEDFORM:programfixedform
23! FIXEDFORM-NOT:program freeform
24
25! MULTIPLEFORMS:program freeform
26! MULTIPLEFORMS-NOT:programfixedform
27! MULTIPLEFORMS-NEXT:end
28! MULTIPLEFORMS-NEXT:programfixedform
29! MULTIPLEFORMS-NOT:program freeform
30