Issue 61641
Summary `clang++ -E -dM -` fails with either `/etc/clang/clang++.cfg` or an explicit `-std=c++NN` argument
Labels
Assignees
Reporter thesamesam
    The driver code for preprocessing currently forces C mode when stdin is used as an argument, even when the used driver is `clang++` (or otherwise originally in C++ mode).

When invoked as `clang++`, `clang++` reads `/etc/clang/clang++.cfg` accordingly where C++ specific parameters might be passed.

The special handling has been in Clang since 1688f1a7e0add08f7799485e9eb41a7ed440391d and still exists in the same form now:
https://github.com/llvm/llvm-project/blob/89a1af749166627704cdf9d676455d32616c2c06/clang/lib/Driver/Driver.cpp#L2606

This originally came up at https://reviews.llvm.org/D133375#4214214.

Steps to reproduce (method 1, config file):
```console
mkdir -p /etc/clang
echo "-std=c++17" >> /etc/clang/clang++.cfg
clang++ -E -dM -
```

Steps to reproduce (method 2, explicit argument):
```console
echo "int main();" | clang++ -std=c++17  -E -dM -
```

This is problematic for e.g. Meson which tries to invoke the active C++ compiler to determine any predefined macros. This is not specific to configuration files, but is worse with it. This issue didn't occur when using the legacy `CLANG_DEFAULT_STD_CXX` CMake option though.

cc @tambry @MaskRay @mgorny @eli-schwartz
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to