File: multiple-input-files.f90

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (65 lines) | stat: -rw-r--r-- 2,880 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

!--------------------------
! FLANG DRIVER (flang)
!--------------------------
! NOTE: Use `-E` so that the compiler driver stops after the 1st compilation phase, preprocessing. That's all we need.

! TEST 1: Both input files are processed (output is printed to stdout)
! RUN: %flang -E %s %S/Inputs/hello.f90 | FileCheck %s --match-full-lines -check-prefix=FLANG

! TEST 2: None of the files is processed (not possible to specify the output file when multiple input files are present)
! RUN: not %flang -E -o - %S/Inputs/hello.f90 %s  2>&1 | FileCheck %s --match-full-lines -check-prefix=ERROR
! RUN: not %flang -E -o %t %S/Inputs/hello.f90 %s 2>&1 | FileCheck %s --match-full-lines -check-prefix=ERROR

!----------------------------------------
! FLANG FRONTEND DRIVER (flang -fc1)
!----------------------------------------
! TEST 3: Both input files are processed
! This particular test case generates output files in the same directory as the input files. We need to copy the input files into a
! temporary directory to avoid polluting the source directory.
! RUN: rm -rf %t-dir && mkdir -p %t-dir && cd %t-dir
! RUN: cp %s . && cp %S/Inputs/hello.f90 .
! RUN: %flang_fc1 -test-io  hello.f90 multiple-input-files.f90 2>&1 \
! RUN:  && FileCheck %s --input-file=multiple-input-files.txt --match-full-lines -check-prefix=FC1-OUTPUT1 \
! RUN:  && FileCheck %s --input-file=hello.txt --match-full-lines -check-prefix=FC1-OUTPUT2

! TEST 4: Only the last input file is processed
! RUN: %flang_fc1 -test-io %s %S/Inputs/hello.f90 -o %t 2>&1 \
! RUN:  && FileCheck %s --input-file=%t --match-full-lines -check-prefix=FC1-OUTPUT3

! TEST 1: By default, `flang` prints the output from all input files to
! stdout
! FLANG-LABEL: Program arithmetic
! FLANG-NEXT:    Integer :: i, j
! FLANG-NEXT:    i = 2; j = 3; i= i * j;
! FLANG-NEXT:  End Program arithmetic

! FLANG-LABEL: program hello
! FLANG-NEXT:  write(*,*), "Hello world!"
! FLANG-NEXT:end program hello

! TEST 2: `-o` does not when multiple input files are present
! ERROR: flang-new: error: cannot specify -o when generating multiple output files

! TEST 3: The output file _was not_ specified - `flang_fc1` will process all
! input files and generate one output file for every input file.
! FC1-OUTPUT1-LABEL: Program arithmetic
! FC1-OUTPUT1-NEXT:    Integer :: i, j
! FC1-OUTPUT1-NEXT:    i = 2; j = 3; i= i * j;
! FC1-OUTPUT1-NEXT:  End Program arithmetic

! FC1-OUTPUT2-LABEL:program hello
! FC1-OUTPUT2-NEXT:  write(*,*), "Hello world!"
! FC1-OUTPUT2-NEXT:end program hello

! TEST 4: The output file _was_ specified - `flang_fc1` will process only
! the last input file and generate the corresponding output.
! FC1-OUTPUT3-LABEL:program hello
! FC1-OUTPUT3-NEXT:  write(*,*), "Hello world!"
! FC1-OUTPUT3-NEXT:end program hello


Program arithmetic
  Integer :: i, j
  i = 2; j = 3; i= i * j;
End Program arithmetic