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.
4 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=TRIGRAPHS-DEFAULT %s
5 // cc1 will disable trigraphs for -fms-compatibility as long as -ftrigraphs
6 // isn't explicitly passed.
7 // TRIGRAPHS-DEFAULT-NOT: "-ftrigraphs"
9 // RUN: %clang_cl /c -### /Zc:trigraphs -- %s 2>&1 | FileCheck -check-prefix=TRIGRAPHS-ON %s
10 // TRIGRAPHS-ON: "-ftrigraphs"
12 // RUN: %clang_cl /c -### /Zc:trigraphs- -- %s 2>&1 | FileCheck -check-prefix=TRIGRAPHS-OFF %s
13 // TRIGRAPHS-OFF: "-fno-trigraphs"
15 // RUN: %clang_cl /c -### /Zc:sizedDealloc -- %s 2>&1 | FileCheck -check-prefix=SIZED-DEALLOC-ON %s
16 // SIZED-DEALLOC-ON: "-fsized-deallocation"
18 // RUN: %clang_cl /c -### /Zc:sizedDealloc- -- %s 2>&1 | FileCheck -check-prefix=SIZED-DEALLOC-OFF %s
19 // SIZED-DEALLOC-OFF-NOT: "-fsized-deallocation"
21 // RUN: %clang_cl /c /std:c++17 -### /Zc:alignedNew -- %s 2>&1 | FileCheck -check-prefix=ALIGNED-NEW-ON %s
22 // ALIGNED-NEW-ON: "-faligned-allocation"
24 // RUN: %clang_cl /c /std:c++17 -### /Zc:alignedNew- -- %s 2>&1 | FileCheck -check-prefix=ALIGNED-NEW-OFF %s
25 // ALIGNED-NEW-OFF-NOT: "-faligned-allocation"
27 // RUN: %clang_cl /c -### /kernel -- %s 2>&1 | FileCheck -check-prefixes=KERNEL-NO-RTTI,KERNEL-NO-EXCEPTIONS %s
28 // KERNEL-NO-RTTI: "-fno-rtti"
29 // KERNEL-NO-EXCEPTIONS-NOT: "-fcxx-exceptions" "-fexceptions"
31 // RUN: not %clang_cl /c -### --target=i686-pc-windows-msvc /kernel /arch:SSE -- %s 2>&1 | FileCheck -check-prefixes=KERNEL-SSE %s
32 // RUN: not %clang_cl /c -### --target=i686-pc-windows-msvc /kernel /arch:SSE2 -- %s 2>&1 | FileCheck -check-prefixes=KERNEL-SSE2 %s
33 // RUN: not %clang_cl /c -### --target=i686-pc-windows-msvc /kernel /arch:AVX -- %s 2>&1 | FileCheck -check-prefixes=KERNEL-AVX %s
34 // RUN: not %clang_cl /c -### --target=i686-pc-windows-msvc /kernel /arch:AVX2 -- %s 2>&1 | FileCheck -check-prefixes=KERNEL-AVX2 %s
35 // RUN: not %clang_cl /c -### --target=i686-pc-windows-msvc /kernel /arch:AVX512 -- %s 2>&1 | FileCheck -check-prefixes=KERNEL-AVX512 %s
36 // KERNEL-SSE: error: invalid argument '/arch:SSE' not allowed with '/kernel'
37 // KERNEL-SSE2: error: invalid argument '/arch:SSE2' not allowed with '/kernel'
38 // KERNEL-AVX: error: invalid argument '/arch:AVX' not allowed with '/kernel'
39 // KERNEL-AVX2: error: invalid argument '/arch:AVX2' not allowed with '/kernel'
40 // KERNEL-AVX512: error: invalid argument '/arch:AVX512' not allowed with '/kernel'
42 // RUN: %clang_cl /c -### /kernel /EHsc -- %s 2>&1 | FileCheck -check-prefixes=KERNEL-EHSC %s
43 // RUN: not %clang_cl /c -### /kernel /GR -- %s 2>&1 | FileCheck -check-prefixes=KERNEL-GR %s
44 // KERNEL-EHSC-NOT: "-fcxx-exceptions" "-fexceptions"
45 // KERNEL-GR: error: invalid argument '/GR' not allowed with '/kernel'
47 // RUN: not %clang_cl /c -### --target=x86_64-pc-windows-msvc /kernel /arch:AVX -- %s 2>&1 | FileCheck -check-prefixes=KERNEL-X64-AVX %s
48 // RUN: not %clang_cl /c -### --target=x86_64-pc-windows-msvc /kernel /arch:AVX2 -- %s 2>&1 | FileCheck -check-prefixes=KERNEL-X64-AVX2 %s
49 // RUN: not %clang_cl /c -### --target=x86_64-pc-windows-msvc /kernel /arch:AVX512 -- %s 2>&1 | FileCheck -check-prefixes=KERNEL-X64-AVX512 %s
50 // KERNEL-X64-AVX: error: invalid argument '/arch:AVX' not allowed with '/kernel'
51 // KERNEL-X64-AVX2: error: invalid argument '/arch:AVX2' not allowed with '/kernel'
52 // KERNEL-X64-AVX512: error: invalid argument '/arch:AVX512' not allowed with '/kernel'
54 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=STRICTSTRINGS-DEFAULT %s
55 // STRICTSTRINGS-DEFAULT-NOT: -Werror=c++11-compat-deprecated-writable-strings
56 // RUN: %clang_cl /c -### /Zc:strictStrings -- %s 2>&1 | FileCheck -check-prefix=STRICTSTRINGS-ON %s
57 // STRICTSTRINGS-ON: -Werror=c++11-compat-deprecated-writable-strings
58 // RUN: %clang_cl /c -### /Zc:strictStrings- -- %s 2>&1 | FileCheck -check-prefix=STRICTSTRINGS-OFF %s
59 // STRICTSTRINGS-OFF: argument unused during compilation
62 // RUN: %clang_cl /c -### /Zc:foobar -- %s 2>&1 | FileCheck -check-prefix=FOOBAR-ON %s
63 // FOOBAR-ON: argument unused during compilation
64 // RUN: %clang_cl /c -### /Zc:foobar- -- %s 2>&1 | FileCheck -check-prefix=FOOBAR-ON %s
65 // FOOBAR-OFF: argument unused during compilation
67 // These are ignored if enabled, and warn if disabled.
69 // RUN: %clang_cl /c -### /Zc:forScope -- %s 2>&1 | FileCheck -check-prefix=FORSCOPE-ON %s
70 // FORSCOPE-ON-NOT: argument unused during compilation
71 // RUN: %clang_cl /c -### /Zc:forScope- -- %s 2>&1 | FileCheck -check-prefix=FORSCOPE-OFF %s
72 // FORSCOPE-OFF: argument unused during compilation
74 // RUN: %clang_cl /c -### /Zc:wchar_t -- %s 2>&1 | FileCheck -check-prefix=WCHAR_T-ON %s
75 // WCHAR_T-ON-NOT: argument unused during compilation
76 // RUN: %clang_cl /c -### /Zc:wchar_t- -- %s 2>&1 | FileCheck -check-prefix=WCHAR_T-OFF %s
77 // WCHAR_T-OFF: "-fno-wchar"
79 // RUN: %clang_cl /c -### /Zc:auto -- %s 2>&1 | FileCheck -check-prefix=AUTO-ON %s
80 // AUTO-ON-NOT: argument unused during compilation
81 // RUN: %clang_cl /c -### /Zc:auto- -- %s 2>&1 | FileCheck -check-prefix=AUTO-OFF %s
82 // AUTO-OFF: argument unused during compilation
84 // RUN: %clang_cl /c -### /Zc:inline -- %s 2>&1 | FileCheck -check-prefix=INLINE-ON %s
85 // INLINE-ON-NOT: argument unused during compilation
86 // RUN: %clang_cl /c -### /Zc:inline- -- %s 2>&1 | FileCheck -check-prefix=INLINE-OFF %s
87 // INLINE-OFF: argument unused during compilation
89 // RUN: %clang_cl /c -### /Zc:ternary -- %s 2>&1 | FileCheck -check-prefix=TERNARY-ON %s
90 // TERNARY-ON-NOT: argument unused during compilation
91 // RUN: %clang_cl /c -### /Zc:ternary- -- %s 2>&1 | FileCheck -check-prefix=TERNARY-OFF %s
92 // TERNARY-OFF: argument unused during compilation
94 // thread safe statics are off for versions < 19.
95 // RUN: %clang_cl /c -### -fms-compatibility-version=18 -- %s 2>&1 | FileCheck -check-prefix=NoThreadSafeStatics %s
96 // RUN: %clang_cl /Zc:threadSafeInit /Zc:threadSafeInit- /c -### -- %s 2>&1 | FileCheck -check-prefix=NoThreadSafeStatics %s
97 // NoThreadSafeStatics: "-fno-threadsafe-statics"
99 // RUN: %clang_cl /Zc:threadSafeInit /c -### -- %s 2>&1 | FileCheck -check-prefix=ThreadSafeStatics %s
100 // ThreadSafeStatics-NOT: "-fno-threadsafe-statics"
102 // RUN: %clang_cl /Zc:dllexportInlines- /c -### -- %s 2>&1 | FileCheck -check-prefix=NoDllExportInlines %s
103 // NoDllExportInlines: "-fno-dllexport-inlines"
104 // RUN: %clang_cl /Zc:dllexportInlines /c -### -- %s 2>&1 | FileCheck -check-prefix=DllExportInlines %s
105 // DllExportInlines-NOT: "-fno-dllexport-inlines"
107 // We recognize -f[no-]delayed-template-parsing.
108 // /Zc:twoPhase[-] has the opposite meaning.
109 // RUN: %clang_cl -c -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDDEFAULT %s
110 // DELAYEDDEFAULT: "-fdelayed-template-parsing"
111 // RUN: %clang_cl -c -fdelayed-template-parsing -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDON %s
112 // RUN: %clang_cl -c /Zc:twoPhase- -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDON %s
113 // DELAYEDON: "-fdelayed-template-parsing"
114 // RUN: %clang_cl -c -fno-delayed-template-parsing -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDOFF %s
115 // RUN: %clang_cl -c /Zc:twoPhase -### -- %s 2>&1 | FileCheck -check-prefix=DELAYEDOFF %s
116 // DELAYEDOFF-NOT: "-fdelayed-template-parsing"
118 // RUN: %clang_cl -c -### /std:c++latest -- %s 2>&1 | FileCheck -check-prefix CHECK-LATEST-CHAR8_T %s
119 // CHECK-LATEST-CHAR8_T-NOT: "-fchar8_t"
120 // RUN: %clang_cl -c -### /Zc:char8_t -- %s 2>&1 | FileCheck -check-prefix CHECK-CHAR8_T %s
121 // CHECK-CHAR8_T: "-fchar8_t"
122 // RUN: %clang_cl -c -### /Zc:char8_t- -- %s 2>&1 | FileCheck -check-prefix CHECK-CHAR8_T_ %s
123 // CHECK-CHAR8_T_: "-fno-char8_t"
127 // These never warn, but don't have an effect yet.
129 // RUN: %clang_cl /c \
130 // RUN: /Zc:__cplusplus \
132 // RUN: /Zc:forScope \
134 // RUN: /Zc:rvalueCast \
135 // RUN: /Zc:ternary \
136 // RUN: -### -- %s 2>&1 | FileCheck -check-prefix=IGNORED %s
137 // IGNORED-NOT: argument unused during compilation
138 // IGNORED-NOT: no such file or directory
140 // Negated form warns:
141 // RUN: %clang_cl /c \
142 // RUN: /Zc:rvalueCast- \
143 // RUN: -### -- %s 2>&1 | FileCheck -check-prefix=NOTIGNORED %s
144 // NOTIGNORED: argument unused during compilation