1 // Don't attempt slash switches on msys bash.
2 // REQUIRES: shell-preserves-root
3 
4 // Note: %s must be preceded by --, otherwise it may be interpreted as a
5 // command-line option, e.g. on Mac where %s is commonly under /Users.
6 
7 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=DEFAULT %s
8 // DEFAULT: "-o" "cl-outputs.obj"
9 
10 // RUN: %clang_cl /Foa -### -- %s 2>&1 | FileCheck -check-prefix=FoNAME %s
11 // FoNAME:  "-o" "a.obj"
12 
13 // RUN: %clang_cl /Foa.ext /Fob.ext -### -- %s 2>&1 | FileCheck -check-prefix=FoNAMEEXT %s
14 // FoNAMEEXT:  "-o" "b.ext"
15 
16 // RUN: %clang_cl /Fofoo.dir/ -### -- %s 2>&1 | FileCheck -check-prefix=FoDIR %s
17 // FoDIR:  "-o" "foo.dir{{[/\\]+}}cl-outputs.obj"
18 
19 // RUN: %clang_cl /Fofoo.dir/a -### -- %s 2>&1 | FileCheck -check-prefix=FoDIRNAME %s
20 // FoDIRNAME:  "-o" "foo.dir{{[/\\]+}}a.obj"
21 
22 // RUN: %clang_cl /Fofoo.dir/a.ext -### -- %s 2>&1 | FileCheck -check-prefix=FoDIRNAMEEXT %s
23 // FoDIRNAMEEXT:  "-o" "foo.dir{{[/\\]+}}a.ext"
24 
25 // RUN: %clang_cl /Fo.. -### -- %s 2>&1 | FileCheck -check-prefix=FoCRAZY %s
26 // FoCRAZY:  "-o" "..obj"
27 
28 // RUN: %clang_cl /Fo -### 2>&1 | FileCheck -check-prefix=FoMISSINGARG %s
29 // FoMISSINGARG: error: argument to '/Fo' is missing (expected 1 value)
30 
31 // RUN: %clang_cl /Foa.obj -### -- %s %s 2>&1 | FileCheck -check-prefix=CHECK-MULTIPLESOURCEERROR %s
32 // CHECK-MULTIPLESOURCEERROR: error: cannot specify '/Foa.obj' when compiling multiple source files
33 
34 // RUN: %clang_cl /Fomydir/ -### -- %s %s 2>&1 | FileCheck -check-prefix=CHECK-MULTIPLESOURCEOK %s
35 // CHECK-MULTIPLESOURCEOK: "-o" "mydir{{[/\\]+}}cl-outputs.obj"
36 
37 
38 // RUN: %clang_cl -### -- %s 2>&1 | FileCheck -check-prefix=DEFAULTEXE %s
39 // DEFAULTEXE: cl-outputs.exe
40 
41 // RUN: %clang_cl /LD -### -- %s 2>&1 | FileCheck -check-prefix=DEFAULTDLL %s
42 // RUN: %clang_cl /LDd -### -- %s 2>&1 | FileCheck -check-prefix=DEFAULTDLL %s
43 // DEFAULTDLL: "-out:cl-outputs.dll"
44 // DEFAULTDLL: "-implib:cl-outputs.lib"
45 
46 // RUN: %clang_cl /Fefoo -### -- %s 2>&1 | FileCheck -check-prefix=FeNOEXT %s
47 // FeNOEXT: "-out:foo.exe"
48 
49 // RUN: %clang_cl /Fefoo /LD -### -- %s 2>&1 | FileCheck -check-prefix=FeNOEXTDLL %s
50 // RUN: %clang_cl /Fefoo /LDd -### -- %s 2>&1 | FileCheck -check-prefix=FeNOEXTDLL %s
51 // FeNOEXTDLL: "-out:foo.dll"
52 // FeNOEXTDLL: "-implib:foo.lib"
53 
54 // RUN: %clang_cl /Fefoo.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeEXT %s
55 // FeEXT: "-out:foo.ext"
56 
57 // RUN: %clang_cl /LD /Fefoo.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeEXTDLL %s
58 // RUN: %clang_cl /LDd /Fefoo.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeEXTDLL %s
59 // FeEXTDLL: "-out:foo.ext"
60 // FeEXTDLL: "-implib:foo.lib"
61 
62 // RUN: %clang_cl /Fefoo.dir/ -### -- %s 2>&1 | FileCheck -check-prefix=FeDIR %s
63 // FeDIR: "-out:foo.dir{{[/\\]+}}cl-outputs.exe"
64 
65 // RUN: %clang_cl /LD /Fefoo.dir/ -### -- %s 2>&1 | FileCheck -check-prefix=FeDIRDLL %s
66 // RUN: %clang_cl /LDd /Fefoo.dir/ -### -- %s 2>&1 | FileCheck -check-prefix=FeDIRDLL %s
67 // FeDIRDLL: "-out:foo.dir{{[/\\]+}}cl-outputs.dll"
68 // FeDIRDLL: "-implib:foo.dir{{[/\\]+}}cl-outputs.lib"
69 
70 // RUN: %clang_cl /Fefoo.dir/a -### -- %s 2>&1 | FileCheck -check-prefix=FeDIRNAME %s
71 // FeDIRNAME: "-out:foo.dir{{[/\\]+}}a.exe"
72 
73 // RUN: %clang_cl /LD /Fefoo.dir/a -### -- %s 2>&1 | FileCheck -check-prefix=FeDIRNAMEDLL %s
74 // RUN: %clang_cl /LDd /Fefoo.dir/a -### -- %s 2>&1 | FileCheck -check-prefix=FeDIRNAMEDLL %s
75 // FeDIRNAMEDLL: "-out:foo.dir{{[/\\]+}}a.dll"
76 // FeDIRNAMEDLL: "-implib:foo.dir{{[/\\]+}}a.lib"
77 
78 // RUN: %clang_cl /Fefoo.dir/a.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeDIRNAMEEXT %s
79 // FeDIRNAMEEXT: "-out:foo.dir{{[/\\]+}}a.ext"
80 
81 // RUN: %clang_cl /LD /Fefoo.dir/a.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeDIRNAMEEXTDLL %s
82 // RUN: %clang_cl /LDd /Fefoo.dir/a.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeDIRNAMEEXTDLL %s
83 // FeDIRNAMEEXTDLL: "-out:foo.dir{{[/\\]+}}a.ext"
84 // FeDIRNAMEEXTDLL: "-implib:foo.dir{{[/\\]+}}a.lib"
85 
86 // RUN: %clang_cl /Fe -### 2>&1 | FileCheck -check-prefix=FeMISSINGARG %s
87 // FeMISSINGARG: error: argument to '/Fe' is missing (expected 1 value)
88 
89 // RUN: %clang_cl /Fefoo /Febar -### -- %s 2>&1 | FileCheck -check-prefix=FeOVERRIDE %s
90 // FeOVERRIDE: "-out:bar.exe"
91 
92 
93 // RUN: %clang_cl /FA -### -- %s 2>&1 | FileCheck -check-prefix=FA %s
94 // FA: "-o" "cl-outputs.asm"
95 // RUN: %clang_cl /FA /Fafoo -### -- %s 2>&1 | FileCheck -check-prefix=FaNAME %s
96 // RUN: %clang_cl /Fafoo -### -- %s 2>&1 | FileCheck -check-prefix=FaNAME %s
97 // FaNAME:  "-o" "foo.asm"
98 // RUN: %clang_cl /FA /Faa.ext /Fab.ext -### -- %s 2>&1 | FileCheck -check-prefix=FaNAMEEXT %s
99 // FaNAMEEXT:  "-o" "b.ext"
100 // RUN: %clang_cl /FA /Fafoo.dir/ -### -- %s 2>&1 | FileCheck -check-prefix=FaDIR %s
101 // FaDIR:  "-o" "foo.dir{{[/\\]+}}cl-outputs.asm"
102 // RUN: %clang_cl /FA /Fafoo.dir/a -### -- %s 2>&1 | FileCheck -check-prefix=FaDIRNAME %s
103 // FaDIRNAME:  "-o" "foo.dir{{[/\\]+}}a.asm"
104 // RUN: %clang_cl /FA /Fafoo.dir/a.ext -### -- %s 2>&1 | FileCheck -check-prefix=FaDIRNAMEEXT %s
105 // FaDIRNAMEEXT:  "-o" "foo.dir{{[/\\]+}}a.ext"
106 // RUN: %clang_cl /Faa.asm -### -- %s %s 2>&1 | FileCheck -check-prefix=FaMULTIPLESOURCE %s
107 // FaMULTIPLESOURCE: error: cannot specify '/Faa.asm' when compiling multiple source files
108