Issue 61446
Summary Add escape hatch for using modules with reserved names
Labels clang:modules, new-feature
Assignees
Reporter mordante
    According to the Standard modules named `std` (and some variations) are reserved for the implementation. While implementing the module `std` in libc++ ([P2465](https://wg21.link/P2465)) Clang considers the code ill-formed due to the usage of a reserved module name. @ChuanqiXu9 provided a work-around by using `# 1 __FILE__ 1 3` in the `.cppm` file. This works. but feels quite fragile. When this line is not on line 1 the diagnostics will show the wrong line number, which is expected. (I ran into that several times, therefore I now have them at line 1.)

It would be great to have a way to tell Clang a specific module is part of the implementation and thus is allowed to use reserved names. For example using a compiler switch (to disable this diagnostic) or something like `#pragma system_file`. I'm not sure what the easiest solution in Clang is. For now this is an issue for libc++, but I expect the same issue will occur when libstdc++ implements its `std` module. (I don't know whether GCC will issue a diagnostic when using reserved module names.)

@AaronBallman I understood from @ChuanqiXu9 that you were involved in the discussion regarding the current behaviour.

Note this is not a blocker for libc++, but it's inconvenient.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to