1! Checks that module search directories specified with `-J/-module-dir` and `-I` are handled correctly
2
3!--------------------------
4! FLANG DRIVER (flang-new)
5!--------------------------
6! RUN: %flang -fsyntax-only -I %S/Inputs -I %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=INCLUDED --allow-empty
7! RUN: %flang -fsyntax-only -I %S/Inputs -J %S/Inputs/module-dir %s 2>&1 | FileCheck %s --check-prefix=INCLUDED --allow-empty
8! RUN: %flang -fsyntax-only -I %S/Inputs -module-dir %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=INCLUDED --allow-empty
9
10! RUN: not %flang -fsyntax-only -I %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=MISSING_MOD2
11! RUN: not %flang -fsyntax-only -J %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=MISSING_MOD2
12! RUN: not %flang -fsyntax-only -module-dir %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=MISSING_MOD2
13
14! RUN: not %flang -fsyntax-only -I %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
15! RUN: not %flang -fsyntax-only -J %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
16! RUN: not %flang -fsyntax-only -module-dir %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
17
18!-----------------------------------------
19! FRONTEND FLANG DRIVER (flang-new -fc1)
20!-----------------------------------------
21! RUN: %flang_fc1 -fsyntax-only -I %S/Inputs -I %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=INCLUDED --allow-empty
22! RUN: %flang_fc1 -fsyntax-only -I %S/Inputs -J %S/Inputs/module-dir %s 2>&1 | FileCheck %s --check-prefix=INCLUDED --allow-empty
23! RUN: %flang_fc1 -fsyntax-only -I %S/Inputs -module-dir %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=INCLUDED --allow-empty
24
25! RUN: not %flang_fc1 -fsyntax-only -I %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=MISSING_MOD2
26! RUN: not %flang_fc1 -fsyntax-only -J %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=MISSING_MOD2
27! RUN: not %flang_fc1 -fsyntax-only -module-dir %S/Inputs %s  2>&1 | FileCheck %s --check-prefix=MISSING_MOD2
28
29! RUN: not %flang_fc1 -fsyntax-only -I %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
30! RUN: not %flang_fc1 -fsyntax-only -J %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
31! RUN: not %flang_fc1 -fsyntax-only -module-dir %S/Inputs/module-dir %s  2>&1 | FileCheck %s --check-prefix=SINGLEINCLUDE
32
33! INCLUDED-NOT: error
34
35! MISSING_MOD2-NOT:error: Cannot read module file for module 'basictestmoduleone''
36! MISSING_MOD2-NOT:error: Derived type 't1' not found
37! MISSING_MOD2:error: Cannot read module file for module 'basictestmoduletwo'
38! MISSING_MOD2:error: Derived type 't2' not found
39
40! SINGLEINCLUDE-NOT:error: Cannot read module file for module 'basictestmoduleone'
41! SINGLEINCLUDE:error: Derived type 't1' not found
42! SINGLEINCLUDE-NOT:error: Cannot read module file for module 'basictestmoduletwo'
43! SINGLEINCLUDE-NOT:error: Derived type 't2' not found
44
45
46program test_search_dirs_for_mod_files
47    USE basictestmoduleone
48    USE basictestmoduletwo
49    type(t1) :: x1 ! t1 defined in Inputs/basictestmoduleone.mod
50    type(t2) :: x2 ! t2 defined in Inputs/module-dir/basictestmoduleone.mod
51end
52