llvm-project/flang/test/Driver/missing-input.f90

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
1.3 KiB
Fortran
Raw Normal View History

[flang][driver] Add the new flang compiler and frontend drivers Summary: This is the first patch implementing the new Flang driver as outlined in [1], [2] & [3]. It creates Flang driver (`flang-new`) and Flang frontend driver (`flang-new -fc1`). These will be renamed as `flang` and `flang -fc1` once the current Flang throwaway driver, `flang`, can be replaced with `flang-new`. Currently only 2 options are supported: `-help` and `--version`. `flang-new` is implemented in terms of libclangDriver, defaulting the driver mode to `FlangMode` (added to libclangDriver in [4]). This ensures that the driver runs in Flang mode regardless of the name of the binary inferred from argv[0]. The design of the new Flang compiler and frontend drivers is inspired by it counterparts in Clang [3]. Currently, the new Flang compiler and frontend drivers re-use Clang libraries: clangBasic, clangDriver and clangFrontend. To identify Flang options, this patch adds FlangOption/FC1Option enums. Driver::printHelp is updated so that `flang-new` prints only Flang options. The new Flang driver is disabled by default. To enable it, set `-DBUILD_FLANG_NEW_DRIVER=ON` when configuring CMake and add clang to `LLVM_ENABLE_PROJECTS` (e.g. -DLLVM_ENABLE_PROJECTS=“clang;flang;mlir”). [1] “RFC: new Flang driver - next steps” http://lists.llvm.org/pipermail/flang-dev/2020-July/000470.html [2] “RFC: Adding a fortran mode to the clang driver for flang” http://lists.llvm.org/pipermail/cfe-dev/2019-June/062669.html [3] “RFC: refactoring libclangDriver/libclangFrontend to share with Flang” http://lists.llvm.org/pipermail/cfe-dev/2020-July/066393.html [4] https://reviews.llvm.org/rG6bf55804924d5a1d902925ad080b1a2b57c5c75c co-authored-by: Andrzej Warzynski <andrzej.warzynski@arm.com> Reviewed By: richard.barton.arm, sameeranjoshi Differential Revision: https://reviews.llvm.org/D86089
2020-09-11 17:17:31 +08:00
! REQUIRES: new-flang-driver
! Test the behaviour of the driver when input is missing or is invalid. Note
! that with the compiler driver (flang-new), the input _has_ to be specified.
! Indeed, the driver decides what "job/command" to create based on the input
! file's extension. No input file means that it doesn't know what to do
! (compile? preprocess? link?). The frontend driver (flang-new -fc1) simply
! assumes that "no explicit input == read from stdin"
!--------------------------
! FLANG DRIVER (flang-new)
!--------------------------
! RUN: not %flang-new 2>&1 | FileCheck %s --check-prefix=FLANG-NO-FILE
! RUN: not %flang-new %t 2>&1 | FileCheck %s --check-prefix=FLANG-NONEXISTENT-FILE
!-----------------------------------------
! FLANG FRONTEND DRIVER (flang-new -fc1)
!-----------------------------------------
! RUN: not %flang-new -fc1 %t 2>&1 | FileCheck %s --check-prefix=FLANG-FC1-NONEXISTENT-FILE
! RUN: not %flang-new -fc1 %S 2>&1 | FileCheck %s --check-prefix=FLANG-FC1-DIR
!-----------------------
! EXPECTED OUTPUT
!-----------------------
! FLANG-NO-FILE: flang-new: error: no input files
! FLANG-NONEXISTENT-FILE: flang-new: error: no such file or directory: {{.*}}
! FLANG-NONEXISTENT-FILE: flang-new: error: no input files
! FLANG-FC1-NONEXISTENT-FILE: error: {{.*}} does not exist
! FLANG-FC1-DIR: error: {{.*}} is not a regular file