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 /fallback /Dfoo=bar /Ubaz /Ifoo /O0 /Ox /GR /GR- /Gy /Gy- \
8 // RUN:   /Gw /Gw- /LD /LDd /EHs /EHs- /MD /MDd /MTd /MT /FImyheader.h /Zi \
9 // RUN:   -### -- %s 2>&1 \
10 // RUN:   | FileCheck %s
11 // CHECK: "-fdiagnostics-format" "msvc-fallback"
12 // CHECK: ||
13 // CHECK: cl.exe
14 // CHECK: "/nologo"
15 // CHECK: "/c"
16 // CHECK: "/W0"
17 // CHECK: "-D" "foo=bar"
18 // CHECK: "-U" "baz"
19 // CHECK: "-I" "foo"
20 // CHECK: "/Ox"
21 // CHECK: "/GR-"
22 // CHECK: "/Gy-"
23 // CHECK: "/Gw-"
24 // CHECK: "/Z7"
25 // CHECK: "/FImyheader.h"
26 // CHECK: "/LD"
27 // CHECK: "/LDd"
28 // CHECK: "/EHs"
29 // CHECK: "/EHs-"
30 // CHECK: "/MT"
31 // CHECK: "/Tc" "{{.*cl-fallback.c}}"
32 // CHECK: "/Fo{{.*cl-fallback.*.obj}}"
33 
34 // RUN: %clang_cl /fallback /GR- -### -- %s 2>&1 | FileCheck -check-prefix=GR %s
35 // GR: cl.exe
36 // GR: "/GR-"
37 
38 // RUN: %clang_cl /fallback /Od -### -- %s 2>&1 | FileCheck -check-prefix=O0 %s
39 // O0: cl.exe
40 // O0: "/Od"
41 // RUN: %clang_cl /fallback /O1 -### -- %s 2>&1 | FileCheck -check-prefix=O1 %s
42 // O1: cl.exe
43 // O1: "-O1"
44 // RUN: %clang_cl /fallback /O2 -### -- %s 2>&1 | FileCheck -check-prefix=O2 %s
45 // O2: cl.exe
46 // O2: "-O2"
47 // RUN: %clang_cl /fallback /Os -### -- %s 2>&1 | FileCheck -check-prefix=Os %s
48 // Os: cl.exe
49 // Os: "-Os"
50 // RUN: %clang_cl /fallback /Ox -### -- %s 2>&1 | FileCheck -check-prefix=Ox %s
51 // Ox: cl.exe
52 // Ox: "/Ox"
53 
54 // Only fall back when actually compiling, not for e.g. /P (preprocess).
55 // RUN: %clang_cl /fallback /P -### -- %s 2>&1 | FileCheck -check-prefix=P %s
56 // P-NOT: ||
57 // P-NOT: "cl.exe"
58 
59 // RUN: not %clang_cl /fallback /c -- %s 2>&1 | \
60 // RUN:     FileCheck -check-prefix=ErrWarn %s
61 // ErrWarn: warning: falling back to {{.*}}cl.exe
62 
63 // RUN: %clang_cl /fallback /c /GR /GR- -### -- %s 2>&1 | \
64 // RUN:     FileCheck -check-prefix=NO_RTTI %s
65 // NO_RTTI: "-cc1"
66 // NO_RTTI: ||
67 // NO_RTTI: cl.exe
68 // NO_RTTI: "/GR-"
69 
70 // Don't fall back on non-C or C++ files.
71 // RUN: %clang_cl /fallback -### -- %S/Inputs/file.ll 2>&1 | FileCheck -check-prefix=LL %s
72 // LL: file.ll
73 // LL-NOT: ||
74 // LL-NOT: "cl.exe"
75 
76 
77 #error "This fails to compile."
78