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-world.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-world.f90 %s 2>&1 | FileCheck %s --match-full-lines -check-prefix=ERROR 12! RUN: not %flang -E -o %t %S/Inputs/hello-world.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-world.f90 . 22! RUN: %flang_fc1 -test-io hello-world.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-world.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-world.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: implicit none 39! FLANG-NEXT: write(*,*) 'Hello world!' 40! FLANG-NEXT:end program hello 41 42! TEST 2: `-o` does not when multiple input files are present 43! ERROR: flang-new: error: cannot specify -o when generating multiple output files 44 45! TEST 3: The output file _was not_ specified - `flang_fc1` will process all 46! input files and generate one output file for every input file. 47! FC1-OUTPUT1-LABEL: Program arithmetic 48! FC1-OUTPUT1-NEXT: Integer :: i, j 49! FC1-OUTPUT1-NEXT: i = 2; j = 3; i= i * j; 50! FC1-OUTPUT1-NEXT: End Program arithmetic 51 52! FC1-OUTPUT2-LABEL:program hello 53! FC1-OUTPUT2-NEXT: implicit none 54! FC1-OUTPUT2-NEXT: write(*,*) 'Hello world!' 55! FC1-OUTPUT2-NEXT:end program hello 56 57! TEST 4: The output file _was_ specified - `flang_fc1` will process only 58! the last input file and generate the corresponding output. 59! FC1-OUTPUT3-LABEL:program hello 60! FC1-OUTPUT3-NEXT: implicit none 61! FC1-OUTPUT3-NEXT: write(*,*) 'Hello world!' 62! FC1-OUTPUT3-NEXT:end program hello 63 64 65Program arithmetic 66 Integer :: i, j 67 i = 2; j = 3; i= i * j; 68End Program arithmetic 69