Any project that wants to import std; potentially needs to be able to build a module that does export std;. We silenced the error diagnostic if the module identified itself as a system header, but this isn't quite good enough, what we really need is a way to identify a system module. It would be nice for that feature to be shared among the major implementations, so this downgrades the diagnostic from an error to a warning temporarily to give implementers time to determine what that mechanism will look like. We may convert this warning back into an error in a future release of Clang, but it's not guaranteed we will do so.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
From the discussion on the issue:
Do we want this loosening of the restriction to apply to *only* std and the same followed by a number, or to any reserved identifier used in a module? e.g.,
module std; // error today, but will become a warning module _Test; // error today, but do we want this to become a warning as well?my thinking is we probably want all of these to be warnings because it'd be hard to explain why std is reserved but with a warning while _Test is reserved but with an error.
Yeah, I'd treat them equally - while we could subset the reserved names and allow implementations to only use a subset (while leaving the rest as an error for both implementations and consumers alike) that doesn't feel in keeping with the purpose of these names - to be usable by /someone/ and so necessary to allow them to be used.
(hmm - there's some discussion in the description about the fact that this error was already suppressed in "system headers" - why was that suppression inadequate for system implementation modules? (& does that suppression for reserved names risk being over-broad, since every third party library installed on a system is generally considered a "system header", even if they aren't part of the implementation?))
We currently use line markers to "enter" a system header and that's quite fragile. I mentioned we could use #pragma clang system_header, but @ChuanqiXu didn't think that was appropriate because these are not headers, they're modules, and we should have some separation between "system headers" and "system modules". (https://github.com/llvm/llvm-project/issues/61446#issuecomment-1473029776) As for being over-broad, it might be, but this is the approach we usually take (anything that's a "system header" is considered special and gets less diagnostics because the user isn't typically able to change the contents of the header file anyway).
Presumably adding an alias for #pragma clang system_header called system_module wouldn't be too hard? (though the pragma is also being removed from libc++ soon, I think, in favor of -isystem usage, so maybe that's a sign the pragma's not a great way to do)
Presumably the line marker issue would be less significant for a module? Since there's no complex line marking, inclusion, etc, going on - it's just where the actual .cppm file is located/how it's found? (though yeah, that might get weird for building .pcms - since you're going to name the source file directly on the command line, it's not going to be found via any isystem lookup, etc... )
Presumably adding an alias for #pragma clang system_header called system_module wouldn't be too hard? (though the pragma is also being removed from libc++ soon, I think, in favor of -isystem usage, so maybe that's a sign the pragma's not a great way to do)
Yeah, it shouldn't be hard but it looks not good too. I feel the current patch is better/simpler as a workaround.
It wouldn't be hard to add, but the modules group wanted to see if we can find some common feature that all the implementations implement instead of relying on different extensions for different compilers, IIUC. So that could be a pragma, or it could be an attribute attached to the module name, etc.
Presumably the line marker issue would be less significant for a module? Since there's no complex line marking, inclusion, etc, going on - it's just where the actual .cppm file is located/how it's found? (though yeah, that might get weird for building .pcms - since you're going to name the source file directly on the command line, it's not going to be found via any isystem lookup, etc... )
The trouble is maintenance. Someone ran into a problem where they added code to the module and then diagnostics started showing up on the wrong lines because of the line marker.
Sorry I was not available earlier. Thanks for working on this. LGTM but one remark.
clang/docs/ReleaseNotes.rst | ||
---|---|---|
92 | Note this is about the standard modules, which are not precompiled per se. |
clang/docs/ReleaseNotes.rst | ||
---|---|---|
92 | Thanks! I fixed this up on the Clang 17 branch in 711b70d77e99dd4101b9dfa94d9ea0d4149997ab |
Note this is about the standard modules, which are not precompiled per se.