<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/193242>193242</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-cl] `/wd NNNN` (space-separated) is rejected with a driver error while cl.exe accepts it
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
scc-tw
</td>
</tr>
</table>
<pre>
### Summary
`clang-cl` rejects the space-separated MSVC-compatible form `/wd 4996` with a
hard driver error, while `cl.exe` accepts both `/wd4996` and `/wd 4996` and
suppresses the warning in both cases.
`/wd` is currently modelled as joined-only in clang-cl's option table, so the
following token `4996` is not consumed as its operand. Instead the driver:
1. Parses `/wd` as a joined option with an empty value and emits
`error: invalid integral value '' in '/wd'`.
2. Classifies `4996` as a linker input and reports
`warning: 4996: 'linker' input unused [-Wunused-command-line-argument]`.
This affects tooling (including clangd) that consumes a tokenized
`compile_commands.json` produced from MSVC-style argv, where the original
invocation used the space-separated spelling.
### Reproducer
`test.cpp`:
```cpp
[[deprecated("use g() instead")]] void f() {}
int main() { f(); }
```
**cl.exe baseline — both spellings accepted, C4996 suppressed:**
```
> cl /nologo /W3 /c /wd4996 test.cpp
test.cpp
> cl /nologo /W3 /c /wd 4996 test.cpp
test.cpp
```
<img width="1115" height="628" alt="Image" src="https://github.com/user-attachments/assets/2c38312a-4b39-4407-9b72-b0ed413c09d2" />
**clang-cl — glued form works, split-token form is a hard error:**
```
> clang-cl /nologo /W3 /c /wd4996 test.cpp
(no diagnostic)
> clang-cl /nologo /W3 /c /wd 4996 test.cpp
clang-cl: warning: 4996: 'linker' input unused [-Wunused-command-line-argument]
clang-cl: error: invalid integral value '' in '/wd'
```
<img width="1115" height="628" alt="Image" src="https://github.com/user-attachments/assets/06ec4ff3-2465-44bb-99e2-3976942a6a60" />
**`-###` confirms the driver-level parse mismatch:**
```
> clang-cl -### /c /wd4996 test.cpp 2>&1 | findstr Wno-deprecated
... "-Wno-deprecated-declarations" ...
> clang-cl -### /c /wd 4996 test.cpp 2>&1 | findstr Wno-deprecated
(no match)
```
With the glued form, the synthesized cc1 line contains
`-Wno-deprecated-declarations`. With the split-token form, the mapping is
never applied.
<img width="1280" height="1392" alt="Image" src="https://github.com/user-attachments/assets/b0048d43-c014-452d-8c69-810f09e1d096" />
### Expected behavior
`clang-cl` should accept both `/wd4996` and `/wd 4996` and treat them
equivalently.
The same question likely applies to the related MSVC warning-state options:
`/we NNNN`, `/wo NNNN`, and `/w1 NNNN`–`/w4 NNNN`. This issue scopes the
confirmed reproducer to `/wd`; the rest of the family can be tracked
separately if the fix for `/wd` lands cleanly.
### Why this matters beyond the command line
clang tooling and clangd use clang's embedded driver to interpret a compile
database. A faithful tokenized record of the MSVC invocation naturally appears
as:
```json
"arguments": ["clang-cl.exe", "...", "/wd", "4996", "test.cpp"]
```
Under the current behavior the tooling build fails, even though the same
invocation succeeds with `cl.exe`. Rewriting argv to the glued form in the
compile database is a workaround, but it should not be necessary for an option
family `clang-cl` is advertised as compatible with.
### Likely fix
`/wd` appears to be declared as a joined-only option in clang-cl's TableGen
option definitions, so the token following a space is never consumed as its
operand. Switching it to a joined-or-separate form — the spelling clang-cl
already uses for options like `/FI`, which accepts both `/FIheader.h` and
`/FI header.h` — and extending the existing clang-cl driver tests to cover
the split-token spelling should be sufficient. I'll leave the exact TableGen
wording to reviewers.
### Environment
```
clang version 22.1.3 (https://github.com/llvm/llvm-project e9846648fd6183ee6d8cbdb4502213fcf902a211)
Target: x86_64-pc-windows-msvc
Thread model: posix
Microsoft (R) C/C++ Optimizing Compiler Version 19.50.35725 for x64
Windows 11 Pro 10.0.26200
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMWF1v47bS_jXMzUCCRMmyfZELJ7t5scDbPUXb070saHJsc5ciVZKyk_76gyEl2ZtNe9riHOAARqLP-Xxm5hmJEPTRIt6z1QNbvbsTYz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