[cfe-dev] What's the case if clang module and c++20 module are enabled at the same time?

Aaron Ballman via cfe-dev cfe-dev at lists.llvm.org
Wed Nov 3 05:34:19 PDT 2021


On Wed, Nov 3, 2021 at 7:51 AM chuanqi.xcq via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
>
> Hi,
>
>    Recently I am developing C++20 semantics in clang. Then I met an interesting bug in
> compare-modules-cxx2a.cpp (https://github.com/llvm/llvm-project/blob/main/clang/test/SemaCXX/compare-modules-cxx2a.cpp).
>
>     The key point here is that the test uses `-std=c++2a` and `-fmodules` both. So my codes which is intended to work for C++20 module now tests for clang module. So here is the reason for the bug.
>
>     Beyond my personal work, it is weired for me that we could use clang module and c++20 module at the same time. (I know the implementation of c++20 is based on clang module).
> So I want to ask: do we have considered the case that we use clang module and c++20 module together? Is it neceesary? And what's the status after the user enable c++20 module and clang module?
>
>     For example, when we enter "clang -std=c++20 -fprebuilt-module-path=%t %s -c" to the command line, both `getLangOpts().CPlusPlusModules` and `getLangOpts().Modules` would evaluate to true, which is really weired.
> Is it intentional? Or is it a bug simply? Now I couldn't avoid the bug by `if (getLangOpts().CPlusPlusModules && !getLangOpts().Modules)`.

Personally, I think this was an oversight. It seems to me that trying
to be in both modules modes at the same time is not something we want
to support, so I'd be in favor of treating these as mutually exclusive
options and the user gets an error if they try.

~Aaron

>
>     I CCed people who looks like interested and related. Remind me if you feel uncomfortable.
>
> Thanks,
> Chuanqi
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


More information about the cfe-dev mailing list