1 2!-------------------------- 3! FLANG DRIVER (flang) 4!-------------------------- 5! NOTE: Use `-E` so that the compiler driver stops after the 1st compilation phase, preprocessing. That's all we need. 6 7! TEST 1: Both input files are processed (output is printed to stdout) 8! RUN: %flang -E %s %S/Inputs/hello.f90 | FileCheck %s --match-full-lines -check-prefix=FLANG 9 10! TEST 2: None of the files is processed (not possible to specify the output file when multiple input files are present) 11! RUN: not %flang -E -o - %S/Inputs/hello.f90 %s 2>&1 | FileCheck %s --match-full-lines -check-prefix=ERROR 12! RUN: not %flang -E -o %t %S/Inputs/hello.f90 %s 2>&1 | FileCheck %s --match-full-lines -check-prefix=ERROR 13 14!---------------------------------------- 15! FLANG FRONTEND DRIVER (flang -fc1) 16!---------------------------------------- 17! TEST 3: Both input files are processed 18! This particular test case generates output files in the same directory as the input files. We need to copy the input files into a 19! temporary directory to avoid polluting the source directory. 20! RUN: rm -rf %t-dir && mkdir -p %t-dir && cd %t-dir 21! RUN: cp %s . && cp %S/Inputs/hello.f90 . 22! RUN: %flang_fc1 -test-io hello.f90 multiple-input-files.f90 2>&1 \ 23! RUN: && FileCheck %s --input-file=multiple-input-files.txt --match-full-lines -check-prefix=FC1-OUTPUT1 \ 24! RUN: && FileCheck %s --input-file=hello.txt --match-full-lines -check-prefix=FC1-OUTPUT2 25 26! TEST 4: Only the last input file is processed 27! RUN: %flang_fc1 -test-io %s %S/Inputs/hello.f90 -o %t 2>&1 \ 28! RUN: && FileCheck %s --input-file=%t --match-full-lines -check-prefix=FC1-OUTPUT3 29 30! TEST 1: By default, `flang` prints the output from all input files to 31! stdout 32! FLANG-LABEL: Program arithmetic 33! FLANG-NEXT: Integer :: i, j 34! FLANG-NEXT: i = 2; j = 3; i= i * j; 35! FLANG-NEXT: End Program arithmetic 36 37! FLANG-LABEL: program hello 38! FLANG-NEXT: write(*,*), "Hello world!" 39! FLANG-NEXT:end program hello 40 41! TEST 2: `-o` does not when multiple input files are present 42! ERROR: flang{{.*}}: error: cannot specify -o when generating multiple output files 43 44! TEST 3: The output file _was not_ specified - `flang_fc1` will process all 45! input files and generate one output file for every input file. 46! FC1-OUTPUT1-LABEL: Program arithmetic 47! FC1-OUTPUT1-NEXT: Integer :: i, j 48! FC1-OUTPUT1-NEXT: i = 2; j = 3; i= i * j; 49! FC1-OUTPUT1-NEXT: End Program arithmetic 50 51! FC1-OUTPUT2-LABEL:program hello 52! FC1-OUTPUT2-NEXT: write(*,*), "Hello world!" 53! FC1-OUTPUT2-NEXT:end program hello 54 55! TEST 4: The output file _was_ specified - `flang_fc1` will process only 56! the last input file and generate the corresponding output. 57! FC1-OUTPUT3-LABEL:program hello 58! FC1-OUTPUT3-NEXT: write(*,*), "Hello world!" 59! FC1-OUTPUT3-NEXT:end program hello 60 61 62Program arithmetic 63 Integer :: i, j 64 i = 2; j = 3; i= i * j; 65End Program arithmetic 66