xref: /minix3/external/bsd/llvm/dist/clang/test/Driver/cl-fallback.c (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // Don't attempt slash switches on msys bash.
2f4a2713aSLionel Sambuc // REQUIRES: shell-preserves-root
3f4a2713aSLionel Sambuc 
4f4a2713aSLionel Sambuc // Note: %s must be preceded by --, otherwise it may be interpreted as a
5f4a2713aSLionel Sambuc // command-line option, e.g. on Mac where %s is commonly under /Users.
6f4a2713aSLionel Sambuc 
7*0a6a1f1dSLionel Sambuc // RUN: %clang_cl /fallback /Dfoo=bar /Ubaz /Ifoo /O0 /Ox /GR /GR- /Gy /Gy- \
8*0a6a1f1dSLionel Sambuc // RUN:   /Gw /Gw- /LD /LDd /EHs /EHs- /MD /MDd /MTd /MT /FImyheader.h /Zi \
9*0a6a1f1dSLionel Sambuc // RUN:   -### -- %s 2>&1 \
10*0a6a1f1dSLionel Sambuc // RUN:   | FileCheck %s
11f4a2713aSLionel Sambuc // CHECK: "-fdiagnostics-format" "msvc-fallback"
12f4a2713aSLionel Sambuc // CHECK: ||
13f4a2713aSLionel Sambuc // CHECK: cl.exe
14f4a2713aSLionel Sambuc // CHECK: "/nologo"
15f4a2713aSLionel Sambuc // CHECK: "/c"
16f4a2713aSLionel Sambuc // CHECK: "/W0"
17f4a2713aSLionel Sambuc // CHECK: "-D" "foo=bar"
18f4a2713aSLionel Sambuc // CHECK: "-U" "baz"
19f4a2713aSLionel Sambuc // CHECK: "-I" "foo"
20f4a2713aSLionel Sambuc // CHECK: "/Ox"
21f4a2713aSLionel Sambuc // CHECK: "/GR-"
22*0a6a1f1dSLionel Sambuc // CHECK: "/Gy-"
23*0a6a1f1dSLionel Sambuc // CHECK: "/Gw-"
24*0a6a1f1dSLionel Sambuc // CHECK: "/Z7"
25f4a2713aSLionel Sambuc // CHECK: "/FImyheader.h"
26f4a2713aSLionel Sambuc // CHECK: "/LD"
27f4a2713aSLionel Sambuc // CHECK: "/LDd"
28*0a6a1f1dSLionel Sambuc // CHECK: "/EHs"
29*0a6a1f1dSLionel Sambuc // CHECK: "/EHs-"
30f4a2713aSLionel Sambuc // CHECK: "/MT"
31f4a2713aSLionel Sambuc // CHECK: "/Tc" "{{.*cl-fallback.c}}"
32f4a2713aSLionel Sambuc // CHECK: "/Fo{{.*cl-fallback.*.obj}}"
33f4a2713aSLionel Sambuc 
34*0a6a1f1dSLionel Sambuc // RUN: %clang_cl /fallback /GR- -### -- %s 2>&1 | FileCheck -check-prefix=GR %s
35*0a6a1f1dSLionel Sambuc // GR: cl.exe
36*0a6a1f1dSLionel Sambuc // GR: "/GR-"
37*0a6a1f1dSLionel Sambuc 
38f4a2713aSLionel Sambuc // RUN: %clang_cl /fallback /Od -### -- %s 2>&1 | FileCheck -check-prefix=O0 %s
39f4a2713aSLionel Sambuc // O0: cl.exe
40f4a2713aSLionel Sambuc // O0: "/Od"
41f4a2713aSLionel Sambuc // RUN: %clang_cl /fallback /O1 -### -- %s 2>&1 | FileCheck -check-prefix=O1 %s
42f4a2713aSLionel Sambuc // O1: cl.exe
43f4a2713aSLionel Sambuc // O1: "-O1"
44f4a2713aSLionel Sambuc // RUN: %clang_cl /fallback /O2 -### -- %s 2>&1 | FileCheck -check-prefix=O2 %s
45f4a2713aSLionel Sambuc // O2: cl.exe
46f4a2713aSLionel Sambuc // O2: "-O2"
47f4a2713aSLionel Sambuc // RUN: %clang_cl /fallback /Os -### -- %s 2>&1 | FileCheck -check-prefix=Os %s
48f4a2713aSLionel Sambuc // Os: cl.exe
49f4a2713aSLionel Sambuc // Os: "-Os"
50f4a2713aSLionel Sambuc // RUN: %clang_cl /fallback /Ox -### -- %s 2>&1 | FileCheck -check-prefix=Ox %s
51f4a2713aSLionel Sambuc // Ox: cl.exe
52f4a2713aSLionel Sambuc // Ox: "/Ox"
53*0a6a1f1dSLionel Sambuc 
54*0a6a1f1dSLionel Sambuc // Only fall back when actually compiling, not for e.g. /P (preprocess).
55*0a6a1f1dSLionel Sambuc // RUN: %clang_cl /fallback /P -### -- %s 2>&1 | FileCheck -check-prefix=P %s
56*0a6a1f1dSLionel Sambuc // P-NOT: ||
57*0a6a1f1dSLionel Sambuc // P-NOT: "cl.exe"
58*0a6a1f1dSLionel Sambuc 
59*0a6a1f1dSLionel Sambuc // RUN: not %clang_cl /fallback /c -- %s 2>&1 | \
60*0a6a1f1dSLionel Sambuc // RUN:     FileCheck -check-prefix=ErrWarn %s
61*0a6a1f1dSLionel Sambuc // ErrWarn: warning: falling back to {{.*}}cl.exe
62*0a6a1f1dSLionel Sambuc 
63*0a6a1f1dSLionel Sambuc // RUN: %clang_cl /fallback /c /GR /GR- -### -- %s 2>&1 | \
64*0a6a1f1dSLionel Sambuc // RUN:     FileCheck -check-prefix=NO_RTTI %s
65*0a6a1f1dSLionel Sambuc // NO_RTTI: "-cc1"
66*0a6a1f1dSLionel Sambuc // NO_RTTI: ||
67*0a6a1f1dSLionel Sambuc // NO_RTTI: cl.exe
68*0a6a1f1dSLionel Sambuc // NO_RTTI: "/GR-"
69*0a6a1f1dSLionel Sambuc 
70*0a6a1f1dSLionel Sambuc // Don't fall back on non-C or C++ files.
71*0a6a1f1dSLionel Sambuc // RUN: %clang_cl /fallback -### -- %S/Inputs/file.ll 2>&1 | FileCheck -check-prefix=LL %s
72*0a6a1f1dSLionel Sambuc // LL: file.ll
73*0a6a1f1dSLionel Sambuc // LL-NOT: ||
74*0a6a1f1dSLionel Sambuc // LL-NOT: "cl.exe"
75*0a6a1f1dSLionel Sambuc 
76*0a6a1f1dSLionel Sambuc 
77*0a6a1f1dSLionel Sambuc #error "This fails to compile."
78