Clang Project

clang_source_code/test/Driver/cl-fallback.c
1// Note: %s must be preceded by --, otherwise it may be interpreted as a
2// command-line option, e.g. on Mac where %s is commonly under /Users.
3
4// RUN: %clang_cl --target=i686-pc-win32 /fallback /Dfoo=bar /Ubaz /Ifoo /O0 /Ox /GR /GR- /GS /GS- /Gy /Gy- \
5// RUN:   /Gw /Gw- /LD /LDd /EHs /EHs- /Zl /MD /MDd /MTd /MT /FImyheader.h /Zi \
6// RUN:   -garbage -moregarbage \
7// RUN:   -### -- %s 2>&1 \
8// RUN:   | FileCheck %s
9// CHECK: "-fdiagnostics-format" "msvc-fallback"
10// CHECK: ||
11// CHECK: cl.exe
12// CHECK: "/nologo"
13// CHECK: "/c"
14// CHECK: "/W0"
15// CHECK: "-D" "foo=bar"
16// CHECK: "-U" "baz"
17// CHECK: "-I" "foo"
18// CHECK: "/Oi"
19// CHECK: "/Og"
20// CHECK: "/Ot"
21// CHECK: "/Ob2"
22// CHECK: "/Oy"
23// CHECK: "/GF"
24// CHECK: "/GR-"
25// CHECK: "/GS-"
26// CHECK: "/Gy-"
27// CHECK: "/Gw-"
28// CHECK: "/Z7"
29// CHECK: "/FImyheader.h"
30// CHECK: "/LD"
31// CHECK: "/LDd"
32// CHECK: "/EHs"
33// CHECK: "/EHs-"
34// CHECK: "/Zl"
35// CHECK: "/MT"
36// CHECK: "-garbage"
37// CHECK: "-moregarbage"
38// CHECK: "/Tc" "{{.*cl-fallback.c}}"
39// CHECK: "/Fo{{.*cl-fallback.*.obj}}"
40
41// RUN: %clang_cl /fallback /GR- -### -- %s 2>&1 | FileCheck -check-prefix=GR %s
42// GR: cl.exe
43// GR: "/GR-"
44
45// RUN: %clang_cl /fallback /GS- -### -- %s 2>&1 | FileCheck -check-prefix=GS %s
46// GS: cl.exe
47// GS: "/GS-"
48
49// RUN: %clang_cl /fallback /Zc:threadSafeInit -### -- %s 2>&1 | FileCheck -check-prefix=ThreadSafe %s
50// ThreadSafe: /Zc:threadSafeInit
51
52// RUN: %clang_cl /fallback /Zc:threadSafeInit- -### -- %s 2>&1 | FileCheck -check-prefix=NonThreadSafe %s
53// NonThreadSafe: /Zc:threadSafeInit-
54
55// RUN: %clang_cl /fallback /Od -### -- %s 2>&1 | FileCheck -check-prefix=O0 %s
56// O0: cl.exe
57// O0: "/Od"
58// RUN: %clang_cl --target=i686-pc-win32 /fallback /O1 -### -- %s 2>&1 | FileCheck -check-prefix=O1 %s
59// O1: cl.exe
60// O1: "/Og" "/Os" "/Ob2" "/Oy" "/GF" "/Gy"
61// RUN: %clang_cl --target=i686-pc-win32 /fallback /O2 -### -- %s 2>&1 | FileCheck -check-prefix=O2 %s
62// O2: cl.exe
63// O2: "/Oi" "/Og" "/Ot" "/Ob2" "/Oy" "/GF" "/Gy"
64// RUN: %clang_cl --target=i686-pc-win32 /fallback /Os -### -- %s 2>&1 | FileCheck -check-prefix=Os %s
65// Os: cl.exe
66// Os: "/Os"
67// RUN: %clang_cl --target=i686-pc-win32 /fallback /Ox -### -- %s 2>&1 | FileCheck -check-prefix=Ox %s
68// Ox: cl.exe
69// Ox: "/Oi" "/Og" "/Ot" "/Ob2" "/Oy" "/GF"
70
71// Only fall back when actually compiling, not for e.g. /P (preprocess).
72// RUN: %clang_cl /fallback /P -### -- %s 2>&1 | FileCheck -check-prefix=P %s
73// P-NOT: ||
74// P-NOT: "cl.exe"
75
76// RUN: not %clang_cl /fallback /c -- %s 2>&1 | \
77// RUN:     FileCheck -check-prefix=ErrWarn %s
78// ErrWarn: warning: falling back to {{.*}}cl.exe
79
80// RUN: %clang_cl /fallback /c /GR /GR- -### -- %s 2>&1 | \
81// RUN:     FileCheck -check-prefix=NO_RTTI %s
82// NO_RTTI: "-cc1"
83// NO_RTTI: ||
84// NO_RTTI: cl.exe
85// NO_RTTI: "/GR-"
86
87// Don't fall back on non-C or C++ files.
88// RUN: %clang_cl /fallback -### -- %S/Inputs/file.ll 2>&1 | FileCheck -check-prefix=LL %s
89// LL: file.ll
90// LL-NOT: ||
91// LL-NOT: "cl.exe"
92
93
94#error "This fails to compile."
95