Issue 240032
Summary [clang-cl] Incorrect warning about unused input file with -Tc together with -EP
Labels new issue
Assignees
Reporter mstorsjo
    When preprocessing with `clang-cl` with `-EP`, clang warns about input files that it doens't recognize as a preprocessable source.

```console
$ cat test.rc
test resource file
$ clang-cl -EP test.rc
clang-cl: warning: test.rc: 'linker' input unused when '-EP' is present [-Wunused-command-line-argument]
```

To avoid this and force clang to preprocess the file, we can pass the `-Tctest.rc` flag, which tells clang that `test.rc` should be treated as C source:
```console
$ clang-cl -EP -Tctest.rc test.rc
clang-cl: warning: test.rc: 'linker' input unused when '-EP' is present [-Wunused-command-line-argument]
test resource file
```

Now clang does preprocess the file, as intended (contrary to when the `-Tc` option wasnt specified), but it still warns that `test.rc` is treated as linker input, which is unused. This warning is incorrect.

If we instead use the `-TC` flag, which tells clang that all input files are to be treated as C source files, there's no warning:
```console
$ clang-cl -EP -TC test.rc
test resource file
```

Also, if we preprocess with `-E` instead of `-EP` (which includes `#line` markers), there's no warning about the input file being treated as a linker input:
```console
$ clang-cl -E test.rc
# 1 "test.rc"
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 455 "<built-in>" 3
# 1 "<command line>" 1
# 1 "<built-in>" 2
# 1 "test.rc" 2
test resource file
```

Therefore, it feels somewhat inconsistent that it warns about the file type with `-EP`, but not with `-E`.

Additionally, MSVC `cl.exe` doesn't produce any such warnings and happily preprocesses any input file with either `-E` or `-EP`.


This issue gets triggered by Meson since https://github.com/mesonbuild/meson/pull/15904.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to