Issue 174536
Summary [C++20] [Modules] Relax restriction on language flags
Labels clang:modules
Assignees
Reporter ChuanqiXu9
    Currently, for the example,

```C++
export module a;
// EOF
```

```C++
export module b;
import a;
...
```

If we compile them with:

```
$ clang++ -std=c++20 a.cppm -fmodule-output=a.pcm -c -o a.o
$ clang++ -std=c++23 b.cppm -fmodule-file=a=a.pcm -fsyntax-only
```

The compiler will reject it.

But it doesn't make a lot of sense. Since for the example,

```C++
export module a;
// EOF
```

I believe, no matter what the language level is to produce its BMI. Its user won't care about it. (Given the producer and the consumer are the same compiler). And also we don't need to worry about the consistency, on the one hand, we still have other mechanism to detect the inconsistency, e.g., if we have multiple duplicated declarations, we're still able to find it, on the other hand, we didn't forbid the use of macros in different TUs.

The realistic motivation of this is, many projects have many third party libraries. These third party libraries may be compiled by a specific C++ version but not others. Then it will be pretty problematic and annoying for users if modules will ask they to compile their thirdparty libraries with different language versions.

So my thought is, we can relax the restriction on language flags for named modules. I feel this is fine as module units are standard alone translation units after all. I failed to find any bad cases. CC @zygoloid do you have any concerns or any bad cases if we don't force the producer and the consumer use the same set of language flags? From my understanding, this requirements come from header modules. But named module units are standard alone TU.


_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to